Commit d833dfaa authored by Paul Asmuth's avatar Paul Asmuth
Browse files

common: rename ElementTree -> Document

parent a8454be0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ add_library(plotfxlib STATIC
    common/graphics/rasterize.cc
    common/graphics/png.cc
    common/element_factory.cc
    common/element_tree.cc
    common/document.cc
    common/utils/random.cc
    common/utils/csv.cc
    common/utils/bufferutil.cc
+7 −7
Original line number Diff line number Diff line
@@ -27,17 +27,17 @@
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#include "document.h"
#include "plist/plist_parser.h"
#include "element_factory.h"
#include "element_tree.h"
#include "graphics/layer.h"
#include "graphics/layout.h"

namespace plotfx {

ReturnCode buildElementTree(
ReturnCode buildDocument(
    const PropertyList& plist,
    ElementTree* tree) {
    Document* tree) {
  for (size_t i = 0; i < plist.size(); ++i) {
    const auto& elem_name = plist[i].name;
    const auto& elem_config = plist[i].child.get();
@@ -53,9 +53,9 @@ ReturnCode buildElementTree(
  return ReturnCode::success();
}

ReturnCode buildElementTree(
ReturnCode buildDocument(
    const std::string& spec,
    ElementTree* tree) {
    Document* tree) {
  PropertyList plist;
  plist::PropertyListParser plist_parser(spec.data(), spec.size());
  if (!plist_parser.parse(&plist)) {
@@ -65,11 +65,11 @@ ReturnCode buildElementTree(
        plist_parser.get_error());
  }

  return buildElementTree(plist, tree);
  return buildDocument(plist, tree);
}

ReturnCode renderElements(
    const ElementTree& tree,
    const Document& tree,
    Layer* frame) {
  Rectangle clip(0, 0, frame->width, frame->height);

+6 −6
Original line number Diff line number Diff line
@@ -34,20 +34,20 @@
namespace plotfx {
class Layer;

struct ElementTree {
struct Document {
  std::vector<ElementRef> roots;
};

ReturnCode buildElementTree(
ReturnCode buildDocument(
    const PropertyList& plist,
    ElementTree* tree);
    Document* tree);

ReturnCode buildElementTree(
ReturnCode buildDocument(
    const std::string& spec,
    ElementTree* tree);
    Document* tree);

ReturnCode renderElements(
    const ElementTree& tree,
    const Document& tree,
    Layer* frame);

} // namespace plotfx
+4 −4
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
#include <sys/resource.h>
#include <sys/file.h>
#include "plotfx.h"
#include "common/element_tree.h"
#include "common/document.h"
#include "graphics/layer.h"
#include <utils/flagparser.h>
#include <utils/fileutil.h>
@@ -99,15 +99,15 @@ int main(int argc, const char** argv) {
  }

  auto spec = FileUtil::read(flag_in).toString(); // FIXME
  plotfx::ElementTree elems;
  if (auto rc = buildElementTree(spec, &elems); !rc.isSuccess()) {
  plotfx::Document doc;
  if (auto rc = buildDocument(spec, &doc); !rc.isSuccess()) {
    printError(rc);
    return EXIT_FAILURE;
  }

  Layer frame{1200, 600};
  frame.clear(Colour{1, 1, 1, 1});
  if (auto rc = renderElements(elems, &frame); !rc.isSuccess()) {
  if (auto rc = renderElements(doc, &frame); !rc.isSuccess()) {
    printError(rc);
    return EXIT_FAILURE;
  }