/** * This event handler is called when the mouse move events occur. */ void GLWidget3D::mouseMoveEvent(QMouseEvent *e) { if (ctrlPressed) { if (e->buttons() & Qt::LeftButton) { // Rotate camera.rotate(e->x(), e->y()); } else if (e->buttons() & Qt::MidButton) { // Move camera.move(e->x(), e->y()); } else if (e->buttons() & Qt::RightButton) { // Zoom camera.zoom(e->x(), e->y()); } clearSketch(); } else { drawLineTo(e->pos()); } update(); }
void MainWindow::createActions() { //saveToXML = new QAction(QIcon(":/images/save.png"), tr("&Save..."), this); //saveToXML = new QAction(("&Save..."), this); //saveToXML->setShortcuts(QKeySequence::Save); //saveToXML->setStatusTip(tr("Save your current sketch to an XML file")); //saveToXML->setText("Save"); //connect(saveToXML, SIGNAL(triggered()), this, SLOT(saveTreeToXML())); newSketch = new QAction(("&New"), this); newSketch->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); newSketch->setStatusTip(tr("Start a new sketch")); connect(newSketch, SIGNAL(triggered()), this, SLOT(clearSketch())); generate = new QAction(("&Generate"), this); generate->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G)); generate->setStatusTip(tr("Generate a tree from your current sketch")); connect(generate, SIGNAL(triggered()), this, SLOT(generateFromCurrent())); generate->setEnabled(false); generationOption = new QAction(("&Options"), this); generationOption->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); generationOption->setStatusTip(tr("Choose settings for the tree generation process")); connect(generationOption, SIGNAL(triggered()), this, SLOT(generationOptions())); newVariation = new QAction(("&New Variation"), this); //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G)); newVariation->setStatusTip(tr("Generate a new variation of the last type of tree you generated")); connect(newVariation, SIGNAL(triggered()), this, SLOT(generateNewVariation())); newVariation->setEnabled(false); displayFoliage = new QCheckBox(("&Foliage"), this); displayFoliage->setChecked(true); //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G)); displayFoliage->setStatusTip(tr("Display foliage")); connect(displayFoliage, SIGNAL(toggled(bool)), this, SLOT(toggleFoliage( bool))); displayFoliage->setEnabled(false); displayFoliage->setChecked(true); displayTexture = new QCheckBox(("&Texture"), this); displayTexture->setChecked(true); //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G)); displayTexture->setStatusTip(tr("Display texture")); connect(displayTexture, SIGNAL(toggled(bool)), this, SLOT(toggleTexture(bool))); displayTexture->setEnabled(false); displayTexture->setChecked(true); displaySubdivisionSurface = new QCheckBox(("&Subdivision Surface"), this); //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G)); displaySubdivisionSurface->setStatusTip(tr("Generate a subdivision surface for the trunk and branches")); displaySubdivisionSurface->setChecked(true); connect(displaySubdivisionSurface, SIGNAL(toggled(bool)), this, SLOT(displayAsMesh(bool))); displaySubdivisionSurface->setEnabled(false); SubdivSpinBox = new QSpinBox(); SubdivSpinBox->setSingleStep(1); SubdivSpinBox->setMaximumWidth(40); SubdivSpinBox->setValue(subdivs); SubdivSpinBox->setMaximum(3); SubdivSpinBox->setEnabled(false); connect(SubdivSpinBox, SIGNAL( valueChanged(int)), this, SLOT(SubdivSliderChange(int))); undo = new QAction(QIcon("./Resources/Icons/Undo.png"),("&Undo"), this); undo->setStatusTip(tr("Undo your last action")); connect(undo, SIGNAL(triggered()), this, SLOT(undoAction())); redo = new QAction(QIcon("./Resources/Icons/Redo.png"),("&Redo"), this); redo->setStatusTip(tr("Redo your last undone action")); connect(redo, SIGNAL(triggered()), this, SLOT(redoAction())); //viewXML = new QAction(("&Display XML file..."), this); //connect(viewXML, SIGNAL(triggered()), this, SLOT(viewXMLAction())); //viewLST = new QAction(("&Display LST file..."), this); //connect(viewLST, SIGNAL(triggered()), this, SLOT(viewLSTAction())); lineMode = new QToolButton(this); lineMode->setText("Line Mode"); lineMode->setIcon(QIcon("./Resources/Icons/LineMode.png")); lineMode->setStatusTip(tr("Change to line drawing mode in the sketch interface")); connect(lineMode, SIGNAL(clicked()), this, SLOT(setLineMode())); lineMode->setCheckable(true); lineMode->setChecked(true); lineMode->setAutoExclusive(true); selectMode = new QToolButton(this); selectMode->setText("Select Mode"); selectMode->setIcon(QIcon("./Resources/Icons/SelectMode.png")); selectMode->setStatusTip(tr("Change to selection mode in the sketch interface")); connect(selectMode, SIGNAL(clicked()), this, SLOT(setSelectMode())); selectMode->setCheckable(true); selectMode->setAutoExclusive(true); pencilMode = new QToolButton(this); pencilMode->setText("Pencil Mode"); pencilMode->setIcon(QIcon("./Resources/Icons/PencilMode.png")); pencilMode->setStatusTip(tr("Change to pencil drawing mode in the sketch interface")); connect(pencilMode, SIGNAL(clicked()), this, SLOT(setPencilMode())); pencilMode->setCheckable(true); pencilMode->setAutoExclusive(true); brushSize = new QComboBox(this); QIntValidator *val = new QIntValidator(brushSize); val->setRange(3, 30); brushSize->setValidator(val); connect(brushSize, SIGNAL(activated(const QString&)), this, SLOT(setBrushSize(const QString&))); for (int i=0; i<BRUSH_SIZE_COUNT; ++i) { QString s; s.setNum(BRUSH_SIZE_OPTION[i]); brushSize->insertItem(i+1, s); } brushLabel = new QLabel(this); brushLabel->setText(" Brush size: "); texSynthOption = new QAction(("&Synthesize Texture"), this); // texSynthOption->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); texSynthOption->setStatusTip(tr("Synthesize a new texture from a sample")); connect(texSynthOption, SIGNAL(triggered()), this,SLOT(SynthesizeTexture())); }