Exemplo n.º 1
0
void TileCollisionDock::tileObjectGroupChanged(Tile *tile)
{
    if (mTile != tile)
        return;
    if (mApplyingChanges)
        return;

    mSynchronizing = true;

    mDummyMapDocument->undoStack()->clear();
    auto selectedTool = mToolManager->selectedTool();

    LayerModel *layerModel = mDummyMapDocument->layerModel();
    delete layerModel->takeLayerAt(nullptr, 1);

    ObjectGroup *objectGroup;
    if (tile->objectGroup())
        objectGroup = tile->objectGroup()->clone();
    else
        objectGroup = new ObjectGroup;

    objectGroup->setDrawOrder(ObjectGroup::IndexOrder);

    layerModel->insertLayer(nullptr, 1, objectGroup);
    mDummyMapDocument->setCurrentLayer(objectGroup);

    mToolManager->selectTool(selectedTool);

    mSynchronizing = false;
}
Exemplo n.º 2
0
void ResizeTileLayer::undo()
{
    Q_ASSERT(mDone);
    LayerModel *layerModel = mMapDocument->layerModel();
    layerModel->replaceLayer(mResizedLayer, mOriginalLayer);
    mDone = false;
}
Exemplo n.º 3
0
void ResizeTileLayer::redo()
{
    Q_ASSERT(!mDone);
    LayerModel *layerModel = mMapDocument->layerModel();
    layerModel->replaceLayer(mOriginalLayer, mResizedLayer);
    mDone = true;
}
Exemplo n.º 4
0
void LayerManager::doPostRenderCallBack(bool yesno) {
    QStandardItem *root = _tree->invisibleRootItem();
    for (int layerIndex = 0; layerIndex < root->rowCount(); ++layerIndex) {
        LayerModel *lyr = static_cast<LayerModel *>(root->child(layerIndex));
        lyr->renderReady(yesno);
    }
}
Exemplo n.º 5
0
void LayerDock::sliderValueChanged(int opacity)
{
    if (!mMapDocument)
        return;

    // When the slider changes value just because we're updating it, it
    // shouldn't try to set the layer opacity.
    if (mUpdatingSlider)
        return;

    const int layerIndex = mMapDocument->currentLayerIndex();
    if (layerIndex == -1)
        return;

    const Layer *layer = mMapDocument->map()->layerAt(layerIndex);

    if ((int) (layer->opacity() * 100) != opacity) {
        mChangingLayerOpacity = true;
        LayerModel *layerModel = mMapDocument->layerModel();
        layerModel->setData(layerModel->index(layerIndex),
                            qreal(opacity) / 100,
                            LayerModel::OpacityRole);
        mChangingLayerOpacity = false;
    }
}
Exemplo n.º 6
0
bool LayerManager::doPostRenderCallBack() {
    bool renderReady = true;
    QStandardItem *root = _tree->invisibleRootItem();
    for (int layerIndex = 0; layerIndex < root->rowCount(); ++layerIndex) {
        LayerModel *lyr = static_cast<LayerModel *>(root->child(layerIndex));
        renderReady &= lyr->renderReady();
    }
    return renderReady;
}
Exemplo n.º 7
0
Ilwis::Ui::LayerModel* LayerManager::findLayerByName(const QString& name) {
	QStandardItem *rootItem = _tree->invisibleRootItem();
	for (int layerIndex = 0; layerIndex < rootItem->rowCount(); ++layerIndex) {
		LayerModel *layer = static_cast<LayerModel *>(rootItem->child(layerIndex));
		if (layer->text() == name)
			return layer;
		layer = layer->findLayerByName(name);
		if (layer)
			return layer;
	}
	return 0;
}
Exemplo n.º 8
0
LayerModel * LayerManager::findLayer(int nodeid)
{
    QStandardItem *rootItem = _tree->invisibleRootItem();
    for (int layerIndex = 0; layerIndex < rootItem->rowCount(); ++layerIndex) {
        LayerModel *layer = static_cast<LayerModel *>(rootItem->child(layerIndex));
        if (layer->nodeId() == nodeid)
            return layer;
        layer = layer->findLayer(nodeid);
        if (layer)
            return layer;
    }
    return 0;
}
Exemplo n.º 9
0
Layer *ResizeLayer::swapLayer(Layer *layer)
{
    const int currentIndex = mMapDocument->currentLayer();

    LayerModel *layerModel = mMapDocument->layerModel();
    Layer *replaced = layerModel->takeLayerAt(mIndex);
    layerModel->insertLayer(mIndex, layer);

    if (mIndex == currentIndex)
        mMapDocument->setCurrentLayer(mIndex);

    return replaced;
}
Exemplo n.º 10
0
LayerModel *LayerManager::create(QStandardItem *parentLayer, const QString &type, LayerManager *lm, const QString& layername, const QString& description, const IOOptions &options)
{
    if ( parentLayer == 0)
        parentLayer = lm->layerTree()->invisibleRootItem();
    if ( parentLayer){
        auto iter = _createLayers.find(type);
        if ( iter != _createLayers.end()){
            auto createFunc   = (*iter).second;
            LayerModel *layer = createFunc(lm, parentLayer,layername, description, options);
			layer->nodeId(lm->nextId());
            layer->fillData(); 
            qint32 lowernodeid = options.contains("lowernodeid") ? options["lowernodid"].toInt() : iUNDEF;
            addLayer(parentLayer, layer, lm,lowernodeid);
            return layer;
        }
    }
    return 0;
}
Exemplo n.º 11
0
bool GridLayer::prepare(int prepTypes)
{
    if (isPrepared(LayerModel::ptGEOMETRY))
        return true;

    LayerModel *lm = findLayerByName("Primary Grid");
    if (lm) {
        if (lm->prepare(prepTypes)) {
            lm = findLayerByName("Secondary Grid");
            bool ok =  lm->prepare(prepTypes);
            if (ok)
                _prepared |= (LayerModel::ptGEOMETRY);

            return ok;
        }
    }
    return false;
}
Exemplo n.º 12
0
void LayerDock::setLayerOpacity(int opacity)
{
    if (!mMapDocument)
        return;

    const int layerIndex = mMapDocument->currentLayerIndex();
    if (layerIndex == -1)
        return;

    const Layer *layer = mMapDocument->map()->layerAt(layerIndex);

    if ((int) (layer->opacity() * 100) != opacity) {
        LayerModel *layerModel = mMapDocument->layerModel();
        const int row = layerModel->layerIndexToRow(layerIndex);
        layerModel->setData(layerModel->index(row),
                            qreal(opacity) / 100,
                            LayerModel::OpacityRole);
    }
}
Exemplo n.º 13
0
void SlotInspectorSection::displayLayerModel(const LayerModel& lm)
{
    auto lm_id = lm.id();

    // Layout
    auto frame = new QFrame;
    auto lay = new QGridLayout;
    lay->setContentsMargins(0, 0, 0, 0);
    lay->setSpacing(0);
    frame->setLayout(lay);
    frame->setFrameShape(QFrame::StyledPanel);

    // LM label
    QString name = lm.objectName();
    name.resize(name.indexOf("Layer"));
    auto id = lm.processModel().id();

    lay->addWidget(new QLabel {QString{name + ".%1"} .arg(*id.val()) }, 0, 0);

    // To front button
    auto pb = new QPushButton {tr("Front")};

    connect(pb, &QPushButton::clicked,
            [=]() {
        PutLayerModelToFront cmd{m_model, lm_id};
        cmd.redo();
    });
    lay->addWidget(pb, 1, 0);

    // Delete button
    auto deleteButton = new QPushButton{{tr("Delete")}};
    connect(deleteButton, &QPushButton::pressed, this, [=] ()
    {
        auto cmd = new RemoveLayerModelFromSlot{m_model, lm_id};
        emit m_parent->commandDispatcher()->submitCommand(cmd);
    });
    lay->addWidget(deleteButton, 1, 1);


    m_lmSection->addContent(frame);
}
Exemplo n.º 14
0
QString LayerManager::layerData(const Coordinate & crdIn, const QString & attrName, QVariantList & items) 
{
	QString result;
    QStandardItem *rootItem = _tree->invisibleRootItem();
    for (int layerIndex = 0; layerIndex < rootItem->rowCount(); ++layerIndex) {
        LayerModel *layer = static_cast<LayerModel *>(rootItem->child(layerIndex));
		if (layer->isValid()) {
            QString txt = layer->layerData(crdIn, attrName, items);
			if (result != "" && txt != "")
				result += ";";
            result += txt;
		}
	}
	for (auto& cov : _mapInfoExtraLayer) {
		QString txt = cov->layerData(crdIn, attrName, items);
		if (result != "" && txt != "")
			result += ";";
		result += txt;
	}
	return result;
}
Exemplo n.º 15
0
void SlotInspectorSection::on_layerModelRemoved(const LayerModel& removed)
{
    // OPTIMIZEME
    m_lmSection->removeAll();
    for (const auto& lm : m_model.layers)
    {
        if (lm.id() != removed.id())
        {
            displayLayerModel(lm);
        }
    }
}
Exemplo n.º 16
0
void  LayerManager::addLayer(QStandardItem *parentLayer, LayerModel *layer, LayerManager *lm, int lowernodid) {
    bool added = false;
    for (int childIndex = 0; childIndex < parentLayer->rowCount(); ++childIndex) {
        LayerModel * childLayer = static_cast<LayerModel *>(parentLayer->child(childIndex)); 
        if (layer->order() == iUNDEF) { // if the to be added layer has no predefined order, basically a normal data layer
            if (lowernodid != iUNDEF )  { // if the position to be added has an order
                if (childLayer->nodeId() == lowernodid) { // see if the to be added layer has the same number
                    lm->layerTree()->insertRow(childLayer->row(), layer); // if so it will be added above the child; basically an apped below all the data layers
                    added = true;
                }
            } else if (childLayer->order() != iUNDEF) { // if the current child has an order, we already know that the added layer has no order, append the layer below the data layers
                if (parentLayer->index().isValid()) { // the index of the top parent ,invisible root, is by definition invalid. We know that there is always a forground layer at level 0 so we must insert at 1 in that case
                    parentLayer->insertRow(0, layer);
                }else
                    parentLayer->insertRow(1, layer);
                 added = true;
            } 
        }
        else {
            if (childLayer->order() <= layer->order()) { // insert at top
                lm->layerTree()->insertRow(childLayer->row(), layer);
                added = true;
            }
        }
        if (added)
            break;
    }
    if (!added) // insert at bottom
        parentLayer->appendRow(layer);

    emit lm->allCoveragesChanged();
    emit lm->updateAxis();

}
Exemplo n.º 17
0
void Timeline::SetScene(SceneModel* scene)
{
    if (mScene == scene)
    {
        return;
    }

    // unload all layers
    QVBoxLayout* l = (QVBoxLayout*)mTimeLinePanel->layout();
    while(QLayoutItem* item = l->itemAt(0))
    {
        l->removeItem(item);
    }

    l = (QVBoxLayout*)mPropertyPanel->layout();
    while(QLayoutItem* item = l->itemAt(0))
    {
        l->removeItem(item);
    }

    for (size_t i = 0; i < mLayers.size(); ++i)
    {
        Layer* layer = mLayers[i];
        delete layer->GetPropertyWindow();
        delete layer;
    }
    mLayers.clear();

    mScene = scene;
    if (mScene)
    {
        for (size_t i = 0; i < mScene->GetLayers().size(); ++i)
        {
            LayerModel* layerModel = mScene->GetLayers()[i];
            if (layerModel)
            {
                switch(layerModel->GetType())
                {
                    case LayerModel::LayerTypeRaster:
                        {
                            RasterLayerModel* rlm = (RasterLayerModel*)layerModel;
                            RasterLayer* layer = new RasterLayer(this, rlm);
                            mLayers.push_back(layer);
                        }
                        break;
                    case LayerModel::LayerTypeTrace:
                        {
                            TraceLayerModel* lm = (TraceLayerModel*)layerModel;
                            TraceLayer* layer = new TraceLayer(this, lm);
                            mLayers.push_back(layer);
                        }
                        break;
                }
            }
        }
        delete mCompositeImage;
        mCompositeImage = new QImage(scene->GetWidth(), scene->GetHeight(), QImage::Format_RGBA8888);
    }

    UpdateLayersUi();
    SetLayerIndex((int)mLayers.size() - 1);
    UpdateMaxFrames();
}
Exemplo n.º 18
0
LayerModel *LayerManager::create(QStandardItem *parentLayer, const ICoverage &cov, LayerManager *lm, const IOOptions &options)
{
    if (cov->coordinateSystem()->isUnknown() && lm->rootLayer()->screenCsy().isValid()){
        QString mes = QString("coordinate system 'unknown' not compatible with coordinate system of the layerview");
        kernel()->issues()->log(mes, IssueObject::itWarning);
        return 0;
    }
    if (parentLayer == 0)
        parentLayer = lm->layerTree()->invisibleRootItem();

	QString type = TypeHelper::type2name(cov->ilwisType());
	if (options.contains("createtype")) {
		type = options["createtype"].toString();
	}
    auto iter = _createLayers.find(type);
    if ( iter != _createLayers.end()){
        auto createFunc   = (*iter).second;
        QString layername = options.contains("layername") ? options["layername"].toString(): cov->name();
        LayerModel *layer = createFunc(lm, parentLayer,layername, cov->description(),options);
		if (!lm->rootLayer()->screenCsy().isValid()) {// first real layer sets the csy
			lm->rootLayer()->screenCsy(cov->coordinateSystem());
            lm->rootLayer()->coverageEnvelope(cov->envelope());
            if (cov->ilwisType() == itRASTER) {
                IRasterCoverage rc = cov.as<RasterCoverage>();
                if (rc->georeference()->grfType<UndeterminedGeoReference>()) {
                    Envelope envUndetermned(Coordinate(0, 0), Coordinate(rc->size().xsize(), rc->size().ysize())); // none.grf bounds
                    lm->rootLayer()->coverageEnvelope(envUndetermned);
                }
            }
	  		lm->setLayerListName(layername);
		}
        else {
            // adjust rootlayer envelop to fit all layers
            Coordinate crd1_trans;
            Coordinate crd2_trans;
            Envelope envelop = cov->envelope();
            if (!cov->coordinateSystem()->isEqual(lm->rootLayer()->screenCsy().ptr())) {
                Coordinate crn1 = envelop.min_corner();
                Coordinate crn2 = envelop.max_corner();

                crd1_trans = lm->rootLayer()->screenCsy()->coord2coord(cov->coordinateSystem(), crn1);
                crd2_trans = lm->rootLayer()->screenCsy()->coord2coord(cov->coordinateSystem(), crn2);
            }
            else {
                crd1_trans = envelop.min_corner();
                crd2_trans = envelop.max_corner();
            }
            Envelope orgenv = lm->rootLayer()->coverageEnvelope();
            if (!(orgenv.contains(crd1_trans) && orgenv.contains(crd2_trans))) {
                orgenv += crd1_trans;
                orgenv += crd2_trans;

                lm->rootLayer()->coverageEnvelope(orgenv);
                if (cov->ilwisType() == itRASTER) {
                    // TODO: check georef none ?
                }
            }
        }
        qint32 lowernodeid = options.contains("lowernodeid") ? options["lowernodeid"].toInt() : iUNDEF;
		layer->nodeId(lm->nextId());
		layer->fillData();
        addLayer(parentLayer, layer, lm, lowernodeid);

		lm->lastAddedCoverageLayer(layer);
    
        return layer;
    }
    return 0;

}