示例#1
0
  HeightMapEditor::HeightMapEditor(ADWIF::Editor * parent, Qt::WindowFlags f): QWidget(parent, f), myEditor(parent)
  {
    myUi = myUi.create();
    myUi->setupUi(this);

    myUi->graphBuilder->setPropertyBrowser(myUi->propertyBrowser);

    layout()->setSizeConstraint(QLayout::SetDefaultConstraint);

    QObject::connect(myUi->buttonRender, SIGNAL(clicked()), this, SLOT(onRenderButtonClicked()));
    QObject::connect(myUi->buttonShowSrc, SIGNAL(clicked()), this, SLOT(onShowSrcButtonClicked()));

//     myUi->renderView->setViewport(new QGLWidget(myUi->renderView));
    myUi->renderView->setScene(new QGraphicsScene(myUi->renderView));
    myUi->renderView->setRenderHints(QPainter::Antialiasing);
    myUi->renderView->scene()->clear();
  }
示例#2
0
  HeightMapEditor::HeightMapEditor(ADWIF::Editor * parent, Qt::WindowFlags f):
    QWidget(parent, f), myEditor(parent), myCellSize(200,200)
  {
    myUi = myUi.create();
    myUi->setupUi(this);

    myUi->graphBuilder->setPropertyBrowser(myUi->propertyBrowser);

    layout()->setSizeConstraint(QLayout::SetDefaultConstraint);

    QObject::connect(myUi->buttonRender, SIGNAL(clicked()), this, SLOT(onRenderButtonClicked()));
    QObject::connect(myUi->buttonShowSrc, SIGNAL(clicked()), this, SLOT(onShowSrcButtonClicked()));
    QObject::connect(myUi->renderView, SIGNAL(onViewChanged(QRectF)), this, SLOT(onViewChanged(QRectF)));

    myUi->renderView->setCellSize(myCellSize);
    myUi->renderView->setScene(new QGraphicsScene(myUi->renderView));
    myUi->renderView->setRenderHints(QPainter::RenderHint::SmoothPixmapTransform);
    QBrush sceneBrush(Qt::lightGray, Qt::BrushStyle::BDiagPattern);
    myUi->renderView->scene()->setBackgroundBrush(sceneBrush);
    myUi->renderView->scene()->clear();

    myUi->splitterMain->setSizes({ myUi->splitterSub->minimumWidth(),
      geometry().width() - myUi->splitterSub->minimumWidth() });

    PhysFS::ifstream fs("map/heightgraph.json");
    std::string json;
    json.assign(std::istreambuf_iterator<std::string::value_type>(fs),
                std::istreambuf_iterator<std::string::value_type>());
    Json::Value value;
    Json::Reader reader;

    if (reader.parse(json, value))
    {
      myUi->graphBuilder->fromJson(value);
    }
  }