本文整理汇总了C++中GlMainWidget::doSelect方法的典型用法代码示例。如果您正苦于以下问题:C++ GlMainWidget::doSelect方法的具体用法?C++ GlMainWidget::doSelect怎么用?C++ GlMainWidget::doSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlMainWidget
的用法示例。
在下文中一共展示了GlMainWidget::doSelect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
//===============================================================
bool MouseElementDeleter::eventFilter(QObject *widget, QEvent *e) {
QMouseEvent *qMouseEv = (QMouseEvent *) e;
if(qMouseEv != NULL) {
node tmpNode;
edge tmpEdge;
ElementType type;
GlMainWidget *glMainWidget = (GlMainWidget *) widget;
if(e->type() == QEvent::MouseMove) {
if (glMainWidget->doSelect(qMouseEv->x(), qMouseEv->y(), type, tmpNode, tmpEdge)) {
glMainWidget->setCursor(QCursor(QPixmap(":/i_del.png")));
}
else {
glMainWidget->setCursor(Qt::ArrowCursor);
}
return false;
}
else if (e->type() == QEvent::MouseButtonPress && qMouseEv->button()==Qt::LeftButton) {
if (glMainWidget->doSelect(qMouseEv->x(), qMouseEv->y(), type, tmpNode, tmpEdge)) {
Observable::holdObservers();
Graph* graph = glMainWidget->getGraph();
// allow to undo
graph->push();
switch(type) {
case NODE:
graph->delNode(tmpNode);
break;
case EDGE:
graph->delEdge(tmpEdge);
break;
}
glMainWidget->redraw();
Observable::unholdObservers();
return true;
}
}
}
return false;
}
示例2: eventFilter
// Event filter of the interactor component (main function of the interactor component)
bool InteractorPluginComponent::eventFilter(QObject *widget, QEvent *e) {
if (e->type() == QEvent::MouseButtonRelease) {
QMouseEvent * qMouseEv = (QMouseEvent *) e;
GlMainWidget *glMainWidget = (GlMainWidget *) widget;
if (qMouseEv->button()== Qt::LeftButton) {
// Enter here if we have released the left button of the mouse
// doSelect function return node/edge under the mouse
node tmpNode;
edge tmpEdge;
ElementType type;
bool result = glMainWidget->doSelect(qMouseEv->x(), qMouseEv->y(), type, tmpNode, tmpEdge);
if (result) {
// Enter here if we have node/edge under the mouse
// Store selection property
Graph *graph=glMainWidget->getScene()->getGlGraphComposite()->getInputData()->getGraph();
string selectionPropertyName=glMainWidget->getScene()->getGlGraphComposite()->getInputData()->getElementSelectedPropName();
BooleanProperty* selection=graph->getProperty<BooleanProperty>(selectionPropertyName);
// Before do any think on the graph, we push the current state of the graph (this activate the undo/redo system)
graph->push();
// Deselect all nodes/edges
selection->setAllNodeValue(false);
selection->setAllEdgeValue(false);
switch(type) {
case NODE:
// Set selection at true for selected node
selection->setNodeValue(tmpNode, true);
break;
case EDGE:
// Set selection at false for selected edge
selection->setEdgeValue(tmpEdge, true);
break;
}
// We have treated the event so we return true
// (this event will not be passed to others interactorComponent)
return true;
}
}
}
// We don't have treated the event so we return false
// (this event will be passed to others interactorComponent)
return false;
}