本文整理汇总了C++中GlMainWidget::redraw方法的典型用法代码示例。如果您正苦于以下问题:C++ GlMainWidget::redraw方法的具体用法?C++ GlMainWidget::redraw怎么用?C++ GlMainWidget::redraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlMainWidget
的用法示例。
在下文中一共展示了GlMainWidget::redraw方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool FishEyeInteractorComponent::eventFilter(QObject *obj, QEvent *e) {
GlMainWidget *glWidget = (GlMainWidget*)obj;
Camera *camera=&glWidget->getScene()->getGraphCamera();
activateFishEye = false;
if (e->type() == QEvent::MouseMove ||
e->type() == QEvent::MouseButtonPress ||
e->type() == QEvent::MouseButtonRelease) {
activateFishEye = true;
QMouseEvent *me = (QMouseEvent *) e;
float x = glWidget->width() - me->x();
float y = me->y();
Coord screenCoords(x, y, 0);
fisheyeCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords));
glWidget->redraw();
return true;
}
else if (e->type() == QEvent::Wheel) {
activateFishEye = true;
QWheelEvent *wheelEvent = (QWheelEvent *) e;
int numDegrees = wheelEvent->delta() / 8;
int numSteps = numDegrees / 15;
if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ControlModifier)) {
activateFishEye = true;
configWidget->setFishEyeRadius(configWidget->getFishEyeRadius() + configWidget->getFishEyeRadiusIncrementStep() * numSteps);
glWidget->redraw();
return true;
}
else if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ShiftModifier)) {
activateFishEye = true;
float newHeight = configWidget->getFishEyeHeight() + configWidget->getFishEyeHeightIncrementStep() * numSteps;
if (newHeight < 0) {
newHeight = 0;
}
configWidget->setFishEyeHeight(newHeight);
glWidget->redraw();
return true;
}
return false;
}
return false;
}
示例2: 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;
}
示例3: eventFilter
//.........这里部分代码省略.........
} else {
operation = TRANSLATE;
glMainWidget->setCursor(QCursor(Qt::SizeAllCursor));
}
}
mode = COORD_AND_SIZE;
if (qMouseEv->modifiers() & Qt::ShiftModifier)
mode = COORD;
if (qMouseEv->modifiers() &
#if defined(__APPLE__)
Qt::AltModifier
#else
Qt::ControlModifier
#endif
)
mode = SIZE;
initEdition();
break;
}
case Qt::MidButton:
undoEdition();
glMainWidget->setCursor(QCursor(Qt::ArrowCursor));
break;
default:
return false;
}
glMainWidget->redraw();
return true;
}
if (e->type() == QEvent::MouseButtonRelease && qMouseEv->button() == Qt::LeftButton &&
operation != NONE) {
stopEdition();
// restore colors
for (unsigned int i = 0; i < 8; ++i) {
_controls[i].setFillColor(Color(255, 40, 40, 200));
_controls[i].setOutlineColor(Color(128, 20, 20, 200));
}
glMainWidget->setCursor(QCursor(Qt::ArrowCursor));
glMainWidget->draw();
return true;
}
if (e->type() == QEvent::KeyPress) {
// first ensure that something is selected
bool hasSelection = _selection->hasNonDefaultValuatedNodes(_graph) ||
_selection->hasNonDefaultValuatedEdges(_graph);
if (hasSelection) {
switch (static_cast<QKeyEvent *>(e)->key()) {
case Qt::Key_Left:
mMouseTranslate(editPosition[0] - 1, editPosition[1], glMainWidget);
break;
case Qt::Key_Right:
mMouseTranslate(editPosition[0] + 1, editPosition[1], glMainWidget);
break;
示例4: eventFilter
bool MouseEdgeBuilder::eventFilter(QObject *widget, QEvent *e) {
GlMainWidget *glMainWidget = static_cast<GlMainWidget *>(widget);
if (e->type() == QEvent::MouseButtonPress) {
QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e);
SelectedEntity selectedEntity;
GlGraphInputData *inputData=glMainWidget->getScene()->getGlGraphComposite()->getInputData();
Graph * _graph = inputData->getGraph();
LayoutProperty* mLayout = inputData->getElementLayout();
if (qMouseEv->buttons()==Qt::LeftButton) {
if (!_started) {
bool result=glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity);
if (result && (selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED)) {
_started=true;
initObserver(_graph);
_source=node(selectedEntity.getComplexEntityId());
_curPos=_startPos=mLayout->getNodeValue(_source);
return true;
}
return false;
}
else {
bool result = glMainWidget->pickNodesEdges(qMouseEv->x(),qMouseEv->y(),selectedEntity);
if (result && (selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED)) {
Observable::holdObservers();
_started=false;
clearObserver();
// allow to undo
_graph->push();
addLink(widget,_source,node(selectedEntity.getComplexEntityId()));
Observable::unholdObservers();
}
else {
Coord point(glMainWidget->width() - qMouseEv->x(), qMouseEv->y(), 0);
_bends.push_back(glMainWidget->getScene()->getGraphCamera().viewportTo3DWorld(glMainWidget->screenToViewport(point)));
glMainWidget->redraw();
}
}
return true;
}
if (qMouseEv->buttons()==Qt::MidButton) {
_bends.clear();
_started=false;
_source=node();
clearObserver();
glMainWidget->draw();
return true;
}
}
if (e->type() == QEvent::MouseMove) {
QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e);
if (!_started) {
SelectedEntity selectedEntity;
bool hoveringOverNode = glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED;
if (!hoveringOverNode) {
glMainWidget->setCursor(QCursor(Qt::ArrowCursor));
return false;
}
else {
glMainWidget->setCursor(QCursor(Qt::CrossCursor));
}
}
else {
SelectedEntity selectedEntity;
if(glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED) {
glMainWidget->setCursor(QCursor(Qt::CrossCursor));
}
else {
glMainWidget->setCursor(QCursor(Qt::ArrowCursor));
}
Coord point(glMainWidget->width() - qMouseEv->x(), qMouseEv->y(), 0);
point = glMainWidget->getScene()->getGraphCamera().viewportTo3DWorld(glMainWidget->screenToViewport(point));
_curPos.set(point[0], point[1], point[2]);
glMainWidget->redraw();
}
return true;
}
return false;
}
示例5: eventFilter
//========================================================================================
bool MouseEdgeBendEditor::eventFilter(QObject *widget, QEvent *e) {
QMouseEvent * qMouseEv = (QMouseEvent *) e;
if(qMouseEv == NULL)
return false;
// Double click to create a new control point
if(e->type() == QEvent::MouseButtonDblClick && qMouseEv->button() == Qt::LeftButton && haveSelection(glMainWidget)) {
_operation = NEW_OP;
mMouseCreate(qMouseEv->x(), qMouseEv->y(), glMainWidget);
return true;
}
if (e->type() == QEvent::MouseButtonPress) {
if(!glMainWidget)
glMainWidget = (GlMainWidget *) widget;
initProxies(glMainWidget);
bool hasSelection = haveSelection(glMainWidget);
editPosition[0] = qMouseEv->x();
editPosition[1] = qMouseEv->y();
editPosition[2] = 0;
switch(qMouseEv->buttons()) {
case Qt::LeftButton : {
if (!hasSelection) {
// event occurs outside the selection rectangle
// so from now we delegate the job to a MouseEdgeSelector object
// which should intercept the event
_operation = NONE_OP;
}
else {
bool entityIsSelected = glMainWidget->pickGlEntities((int)editPosition[0] - 3, (int)editPosition[1] - 3, 6, 6, select, layer);
if(!entityIsSelected) {
// We have click outside an entity
_operation = NONE_OP;
}
else {
selectedEntity=circleString->findKey(select[0].getSimpleEntity());
if (qMouseEv->modifiers() &
#if defined(__APPLE__)
Qt::AltModifier
#else
Qt::ControlModifier
#endif
) {
_operation = DELETE_OP;
mMouseDelete();
}
else {
_graph->push();
_operation = TRANSLATE_OP;
glMainWidget->setCursor(QCursor(Qt::SizeAllCursor));
mode = COORD;
}
return true;
}
}
break;
}
default: {
return false;
}
}
glMainWidget->redraw();
}
if (e->type() == QEvent::MouseButtonRelease &&
qMouseEv->button() == Qt::LeftButton &&
_operation != NONE_OP) {
GlMainWidget *glMainWidget = (GlMainWidget *) widget;
if(selectedEntity=="targetTriangle") {
SelectedEntity selectedEntity;
if (glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED) {
glMainWidget->getScene()->getGlGraphComposite()->getGraph()->setEnds(mEdge,glMainWidget->getScene()->getGlGraphComposite()->getGraph()->ends(mEdge).first,node(selectedEntity.getComplexEntityId()));
}
}
else if(selectedEntity=="sourceCircle") {
SelectedEntity selectedEntity;
if (glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED) {
glMainWidget->getScene()->getGlGraphComposite()->getGraph()->setEnds(mEdge,node(selectedEntity.getComplexEntityId()),glMainWidget->getScene()->getGlGraphComposite()->getGraph()->ends(mEdge).second);
}
}
selectedEntity="";
//.........这里部分代码省略.........
示例6: eventFilter
//=====================================================================
bool MouseBoxZoomer::eventFilter(QObject *widget, QEvent *e) {
GlMainWidget *glw = static_cast<GlMainWidget *>(widget);
GlGraphInputData *inputData = glw->getScene()->getGlGraphComposite()->getInputData();
if (e->type() == QEvent::MouseButtonPress) {
QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e);
if (qMouseEv->buttons() == mButton &&
(kModifier == Qt::NoModifier ||
qMouseEv->modifiers() & kModifier)) {
if (!started) {
x = qMouseEv->x();
y = glw->height() - qMouseEv->y();
w = 0;
h = 0;
started = true;
graph = inputData->getGraph();
}
else {
if (inputData->getGraph() != graph) {
graph = NULL;
started = false;
}
}
return true;
}
if (qMouseEv->buttons()==Qt::MidButton) {
started = false;
glw->redraw();
return true;
}
return false;
}
if (e->type() == QEvent::MouseMove) {
QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e);
if ((qMouseEv->buttons() & mButton) &&
(kModifier == Qt::NoModifier ||
qMouseEv->modifiers() & kModifier)) {
if (inputData->getGraph() != graph) {
graph = NULL;
started = false;
}
if (started) {
if ((qMouseEv->x() > 0) && (qMouseEv->x() < glw->width()))
w = qMouseEv->x() - x;
if ((qMouseEv->y() > 0) && (qMouseEv->y() < glw->height()))
h = y - (glw->height() - qMouseEv->y());
glw->redraw();
return true;
}
}
}
if (e->type() == QEvent::MouseButtonDblClick) {
GlBoundingBoxSceneVisitor bbVisitor(inputData);
glw->getScene()->getLayer("Main")->acceptVisitor(&bbVisitor);
QtGlSceneZoomAndPanAnimator zoomAnPan(glw, bbVisitor.getBoundingBox());
zoomAnPan.animateZoomAndPan();
return true;
}
if (e->type() == QEvent::MouseButtonRelease) {
QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e);
if ((qMouseEv->button() == mButton &&
(kModifier == Qt::NoModifier ||
qMouseEv->modifiers() & kModifier))) {
if (inputData->getGraph() != graph) {
graph = NULL;
started = false;
}
if (started) {
started = false;
if(!(w==0 && h==0)) {
int width = glw->width();
int height = glw->height();
Coord bbMin(width-x, height - y+h);
Coord bbMax(width-(x+w), height - y);
if (abs(bbMax[0] - bbMin[0]) > 1 && abs(bbMax[1] - bbMin[1]) > 1) {
BoundingBox sceneBB;
sceneBB.expand(glw->getScene()->getGraphCamera().viewportTo3DWorld(glw->screenToViewport(bbMin)));
sceneBB.expand(glw->getScene()->getGraphCamera().viewportTo3DWorld(glw->screenToViewport(bbMax)));
QtGlSceneZoomAndPanAnimator zoomAnPan(glw, sceneBB);
zoomAnPan.animateZoomAndPan();
//.........这里部分代码省略.........