示例#1
0
void LineEditDialog::accept()
{
	std::vector<size_t> selectedIndeces = this->getSelectedIndeces(_selPly->stringList());

	if (!selectedIndeces.empty())
	{
		std::string prox_string = this->proximityEdit->text().toStdString();
		double prox = (prox_string.empty()) ? 0.0 : strtod( prox_string.c_str(), 0 );
		std::string ply_name =
		        (plyNameEdit->text().toStdString().empty()) ? "" : plyNameEdit->text().
		        toStdString();
		emit connectPolylines(_geoName,
		                      selectedIndeces,
		                      prox,
		                      ply_name,
		                      this->closePlyCheckBox->isChecked(),
		                      this->createSfcCheckBox->isChecked());
		this->done(QDialog::Accepted);
	}
	else
		OGSError::box("No polylines selected", "Error");
}
示例#2
0
void GeoTreeView::contextMenuEvent( QContextMenuEvent* event )
{
    QModelIndex index = this->selectionModel()->currentIndex();
    auto* item = static_cast<TreeItem*>(index.internalPointer());

    auto* list = dynamic_cast<GeoObjectListItem*>(item);
    QMenu menu;

    // The current index is a list of points/polylines/surfaces
    if (list != nullptr)
    {
        QAction* connectPlyAction(nullptr);
        if (list->getType() == GeoLib::GEOTYPE::POLYLINE)
        {
            connectPlyAction = menu.addAction("Connect Polylines...");
            connect(connectPlyAction, SIGNAL(triggered()), this,
                    SLOT(connectPolylines()));
        }
        menu.addSeparator();
        //QAction* removeAction = menu.addAction("Remove " + item->data(0).toString());
        //connect(removeAction, SIGNAL(triggered()), this, SLOT(removeList()));
    }
    else
    {
        if (!item)  // Otherwise sometimes it crashes when (unmotivated ;-) ) clicking in a treeview
            return;

        auto* parent = dynamic_cast<GeoObjectListItem*>(item->parentItem());

        // The current index refers to a geo-object
        if (parent != nullptr)
        {
            QMenu* cond_menu = new QMenu("Set FEM Condition");
            //menu.addMenu(cond_menu);
            QAction* addCondAction = cond_menu->addAction("On object...");
            QAction* addCondPointAction = cond_menu->addAction("On all points...");
            QAction* addNameAction = menu.addAction("Set name...");
            connect(addCondAction, SIGNAL(triggered()), this, SLOT(setObjectAsCondition()));
            connect(addNameAction, SIGNAL(triggered()), this, SLOT(setNameForElement()));

            if (parent->getType() == GeoLib::GEOTYPE::POINT)
                addCondPointAction->setEnabled(false);
            else
                connect(addCondPointAction, SIGNAL(triggered()), this, SLOT(setObjectPointsAsCondition()));

        }
        // The current index refers to the name of a geometry-object
        else if (item->childCount() > 0)
        {
            if (item->child(0)->data(0).toString().compare("Points") == 0) // clumsy way to find out
            {
                //QAction* saveAction = menu.addAction("Save geometry...");
                QAction* mapAction = menu.addAction("Map geometry...");
                //QAction* addCNDAction = menu.addAction("Load FEM Conditions...");
                //QAction* saveCondAction    = menu.addAction("Save FEM conditions...");
                menu.addSeparator();
                //QAction* removeAction = menu.addAction("Remove geometry");
                //connect(saveAction, SIGNAL(triggered()), this, SLOT(writeToFile()));
                connect(mapAction, SIGNAL(triggered()), this, SLOT(mapGeometry()));
                //connect(addCNDAction, SIGNAL(triggered()), this, SLOT(loadFEMConditions()));
                //connect(saveCondAction, SIGNAL(triggered()), this, SLOT(saveFEMConditions()));
                //connect(removeAction, SIGNAL(triggered()), this, SLOT(removeList()));
            }
        }
    }

    menu.exec(event->globalPos());
}