本文整理汇总了C++中GlMainWidget::height方法的典型用法代码示例。如果您正苦于以下问题:C++ GlMainWidget::height方法的具体用法?C++ GlMainWidget::height怎么用?C++ GlMainWidget::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlMainWidget
的用法示例。
在下文中一共展示了GlMainWidget::height方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
//========================================================================================
bool MouseSelectionEditor::eventFilter(QObject *widget, QEvent *e) {
QMouseEvent *qMouseEv = static_cast<QMouseEvent *>(e);
GlMainWidget *glMainWidget = static_cast<GlMainWidget *>(widget);
if (e->type() == QEvent::MouseButtonPress) {
initProxies(glMainWidget);
computeFFD(glMainWidget);
int H;
H = glMainWidget->height();
editCenter = centerRect.getCenter();
editCenter[2] = 0;
editCenter[1] = glMainWidget->screenToViewport(H) - editCenter[1];
// editCenter[0] = W - editCenter[0];
editPosition[0] = qMouseEv->x();
editPosition[1] = qMouseEv->y();
editPosition[2] = 0;
editLayoutCenter = _layoutCenter;
vector<SelectedEntity> select;
switch (qMouseEv->buttons()) {
case Qt::LeftButton: {
// first ensure that something is selected
bool hasSelection = _selection->hasNonDefaultValuatedNodes(_graph) ||
_selection->hasNonDefaultValuatedEdges(_graph);
if (!hasSelection ||
(!glMainWidget->pickGlEntities(int(editPosition[0]) - 3, int(editPosition[1]) - 3, 6, 6,
select, layer))) {
// event occurs outside the selection rectangle
// so from now we delegate the job to a MouseSelector object
// which should intercept the event
operation = NONE;
glMainWidget->setCursor(QCursor(Qt::CrossCursor));
return false;
}
glMainWidget->setCursor(QCursor(Qt::PointingHandCursor));
int shapeId = -1;
bool advShape = false;
for (unsigned int i = 0; (i < select.size()) && (shapeId == -1); ++i) {
for (int j = 0; j < 8; ++j) {
if (select[i].getSimpleEntity() == &_controls[j]) {
shapeId = i;
}
}
for (int j = 0; j < 6; ++j) {
if (select[i].getSimpleEntity() == &_advControls[j]) {
advShape = true;
shapeId = i;
}
}
}
if (shapeId != -1) {
if (!advShape) {
static_cast<GlCircle *>(select[shapeId].getSimpleEntity())
->setFillColor(Color(40, 255, 40, 200));
static_cast<GlCircle *>(select[shapeId].getSimpleEntity())
->setOutlineColor(Color(20, 128, 20, 200));
}
getOperation(select[shapeId].getSimpleEntity());
switch (operation) {
case ALIGN_TOP:
case ALIGN_BOTTOM:
case ALIGN_LEFT:
case ALIGN_RIGHT:
case ALIGN_VERTICALLY:
case ALIGN_HORIZONTALLY:
mAlign(operation, glMainWidget);
return true;
case ROTATE_Z:
case ROTATE_XY:
case NONE:
case STRETCH_X:
case STRETCH_Y:
case STRETCH_XY:
case TRANSLATE:
default:
break;
}
} else {
if (qMouseEv->modifiers() &
#if defined(__APPLE__)
Qt::AltModifier
#else
Qt::ControlModifier
#endif
) {
operation = ROTATE_XY;
//.........这里部分代码省略.........
示例2: eventFilter
bool GoogleMapViewNavigator::eventFilter(QObject *widget, QEvent *e) {
GoogleMapsView *googleMapsView=static_cast<GoogleMapsView*>(view());
if(googleMapsView->viewType()==GoogleMapsView::GoogleRoadMap ||
googleMapsView->viewType()==GoogleMapsView::GoogleSatellite ||
googleMapsView->viewType()==GoogleMapsView::GoogleTerrain ||
googleMapsView->viewType()==GoogleMapsView::GoogleHybrid) {
QMouseEvent *qMouseEv = dynamic_cast<QMouseEvent *>(e);
QWheelEvent *qWheelEv = dynamic_cast<QWheelEvent *>(e);
if(qMouseEv || qWheelEv) {
GoogleMapsView* googleMapsView=static_cast<GoogleMapsView*>(view());
QApplication::sendEvent(googleMapsView->getGoogleMap(), e);
}
return false;
}
else if (googleMapsView->viewType()==GoogleMapsView::Globe) {
if (e->type() == QEvent::Wheel &&
(((QWheelEvent *) e)->orientation() == Qt::Vertical)) {
#define WHEEL_DELTA 120
GlMainWidget *g = (GlMainWidget *) widget;
g->getScene()->zoomXY(((QWheelEvent *) e)->delta() / WHEEL_DELTA,
g->width()/2., g->height()/2.);
view()->draw();
return true;
}
if (e->type() == QEvent::MouseButtonPress && !inRotation) {
if(((QMouseEvent*)e)->button()==Qt::LeftButton) {
x = ((QMouseEvent *) e)->x();
y = ((QMouseEvent *) e)->y();
inRotation=true;
return true;
}
}
if(e->type() == QEvent::MouseButtonRelease) {
if(((QMouseEvent*)e)->button()==Qt::LeftButton) {
inRotation=false;
return true;
}
}
if (e->type() == QEvent::MouseMove && inRotation) {
GlMainWidget *g = (GlMainWidget *) widget;
Camera &camera=g->getScene()->getGraphCamera();
Coord c1=camera.getEyes()-camera.getCenter();
Coord c2=camera.getEyes()-camera.getCenter()+camera.getUp();
trans(c1,c2,-0.005*(((QMouseEvent *) e)->y()-y),-0.005*(((QMouseEvent *) e)->x()-x));
camera.setCenter(Coord(0,0,0));
camera.setEyes(c1);
camera.setUp(c2-camera.getEyes());
x = ((QMouseEvent *) e)->x();
y = ((QMouseEvent *) e)->y();
view()->draw();
return true;
}
if (e->type() == QEvent::KeyPress) {
GlMainWidget *g = (GlMainWidget *) widget;
float angle1=0;
float angle2=0;
switch(((QKeyEvent *) e)->key()) {
case Qt::Key_Left:
angle2=-0.05f;
break;
case Qt::Key_Right:
angle2=0.05f;
break;
case Qt::Key_Up:
angle1=0.05f;
break;
case Qt::Key_Down:
angle1=-0.05f;
break;
}
Camera &camera=g->getScene()->getGraphCamera();
Coord c1=camera.getEyes()-camera.getCenter();
Coord c2=camera.getEyes()-camera.getCenter()+camera.getUp();
trans(c1,c2,angle1,angle2);
camera.setCenter(Coord(0,0,0));
camera.setEyes(c1);
camera.setUp(c2-camera.getEyes());
view()->draw();
return true;
}
return false;
}
//.........这里部分代码省略.........
示例3: 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();
//.........这里部分代码省略.........