PreviewWindow::PreviewWindow(QWidget *proxyParent, MainWindow *parent, const QGLFormat &format) : QGLWidget(new CoreProfileContext(format), proxyParent), _parent(*parent), _scene(parent->scene()), _selection(parent->selection()), _mousePriorities(DefaultPriorities), _rebuildMeshes(false) { setMouseTracking(true); setFocusPolicy(Qt::ClickFocus); new QShortcut(QKeySequence("A"), this, SLOT(toggleSelectAll())); new QShortcut(QKeySequence("G"), this, SLOT(grabGizmo())); new QShortcut(QKeySequence("Ctrl+C"), this, SLOT(recomputeCentroids())); new QShortcut(QKeySequence("Ctrl+R"), this, SLOT(computeSmoothNormals())); new QShortcut(QKeySequence("Ctrl+Shift+R"), this, SLOT(computeHardNormals())); new QShortcut(QKeySequence("Ctrl+F"), this, SLOT(freezeTransforms())); new QShortcut(QKeySequence("Ctrl+D"), this, SLOT(duplicateSelection())); new QShortcut(QKeySequence("Ctrl+A"), this, SLOT(addModel())); new QShortcut(QKeySequence("Delete"), this, SLOT(deleteSelection())); new QShortcut(QKeySequence("Ctrl+Tab"), this, SLOT(togglePreview())); QShortcut *tShortcut = new QShortcut(QKeySequence("W"), this); QShortcut *rShortcut = new QShortcut(QKeySequence("E"), this); QShortcut *sShortcut = new QShortcut(QKeySequence("R"), this); QShortcut *xShortcut = new QShortcut(QKeySequence("X"), this); QShortcut *yShortcut = new QShortcut(QKeySequence("Y"), this); QShortcut *zShortcut = new QShortcut(QKeySequence("Z"), this); QShortcut *lShortcut = new QShortcut(QKeySequence("Q"), this); QSignalMapper *gizmoMapper = new QSignalMapper(); connect(tShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map())); connect(rShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map())); connect(sShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map())); gizmoMapper->setMapping(tShortcut, 0); gizmoMapper->setMapping(rShortcut, 1); gizmoMapper->setMapping(sShortcut, 2); connect(gizmoMapper, SIGNAL(mapped(int)), &_gizmo, SLOT(setMode(int))); gizmoMapper = new QSignalMapper(); connect(xShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map())); connect(yShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map())); connect(zShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map())); gizmoMapper->setMapping(xShortcut, 0); gizmoMapper->setMapping(yShortcut, 1); gizmoMapper->setMapping(zShortcut, 2); connect(gizmoMapper, SIGNAL(mapped(int)), &_gizmo, SLOT(fixAxis(int))); connect(lShortcut, SIGNAL(activated()), &_gizmo, SLOT(toggleTranslateLocal())); connect(&_gizmo, SIGNAL(redraw()), this, SLOT(updateGL())); connect(&_gizmo, SIGNAL(transformFinished(Mat4f)), this, SLOT(transformFinished(Mat4f))); }
// End the move, this freezes the current transforms void RadiantSelectionSystem::endMove() { freezeTransforms(); // greebo: Deselect all faces if we are in brush and drag mode if ((Mode() == ePrimitive || Mode() == eGroupPart) && ManipulatorMode() == eDrag) { SelectAllComponentWalker faceSelector(false, SelectionSystem::eFace); Node_traverseSubgraph(GlobalSceneGraph().root(), faceSelector); } // Remove all degenerated brushes from the scene graph (should emit a warning) foreachSelected(RemoveDegenerateBrushWalker()); _pivotMoving = false; pivotChanged(); // Update the views SceneChangeNotify(); // If we started an undoable operation, end it now and tell the console what happened if (_undoBegun) { std::ostringstream command; if (ManipulatorMode() == eTranslate) { command << "translateTool"; outputTranslation(command); } else if (ManipulatorMode() == eRotate) { command << "rotateTool"; outputRotation(command); } else if (ManipulatorMode() == eScale) { command << "scaleTool"; outputScale(command); } else if (ManipulatorMode() == eDrag) { command << "dragTool"; } _undoBegun = false; // Finish the undo move GlobalUndoSystem().finish(command.str()); } }
// Shortcut call for an instantly applied scaling of the current selection void RadiantSelectionSystem::scaleSelected(const Vector3& scaling) { // Apply the transformation and freeze the changes startMove(); scale(scaling); freezeTransforms(); }
// Shortcut call for an instantly applied translation of the current selection void RadiantSelectionSystem::translateSelected(const Vector3& translation) { // Apply the transformation and freeze the changes startMove(); translate(translation); freezeTransforms(); }
// Shortcut call for an instantly applied rotation of the current selection void RadiantSelectionSystem::rotateSelected(const Quaternion& rotation) { // Apply the transformation and freeze the changes startMove(); rotate(rotation); freezeTransforms(); }