diff --git a/src/Gui/ViewProvider.h b/src/Gui/ViewProvider.h index 2d4cb6c80..1e0e2c587 100644 --- a/src/Gui/ViewProvider.h +++ b/src/Gui/ViewProvider.h @@ -181,10 +181,18 @@ public: * you can handle most of the events in the viewer by yourself */ //@{ -protected: enum EditMode {Default = 0, - Transform = 1 + Transform, + Cutting, + Color, + Mirror, + Fillet, + Sketch, + Pad, + Pocket, + Revolve }; +protected: /// is called by the document when the provider goes in edit mode virtual bool setEdit(int ModNum); /// is called when you loose the edit mode diff --git a/src/Gui/ViewProviderAnnotation.cpp b/src/Gui/ViewProviderAnnotation.cpp index c2b83de3e..5224277d2 100644 --- a/src/Gui/ViewProviderAnnotation.cpp +++ b/src/Gui/ViewProviderAnnotation.cpp @@ -369,8 +369,7 @@ bool ViewProviderAnnotationLabel::doubleClicked(void) void ViewProviderAnnotationLabel::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { - QAction* act = menu->addAction(QObject::tr("Move annotation"), receiver, member); - act->setData(QVariant((int)ViewProvider::Transform)); + menu->addAction(QObject::tr("Move annotation"), receiver, member); } void ViewProviderAnnotationLabel::dragStartCallback(void *data, SoDragger *) diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index e247ef825..ee02a3421 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -197,7 +197,7 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop) bool ViewProviderGeometryObject::doubleClicked(void) { - Gui::Application::Instance->activeDocument()->setEdit(this, (int)ViewProvider::Transform); + Gui::Application::Instance->activeDocument()->setEdit(this, (int)ViewProvider::Default); return true; } diff --git a/src/Mod/Drawing/Gui/ViewProviderPage.cpp b/src/Mod/Drawing/Gui/ViewProviderPage.cpp index 172139511..55528e9cb 100644 --- a/src/Mod/Drawing/Gui/ViewProviderPage.cpp +++ b/src/Mod/Drawing/Gui/ViewProviderPage.cpp @@ -109,7 +109,6 @@ void ViewProviderDrawingPage::setupContextMenu(QMenu* menu, QObject* receiver, c { QAction* act; act = menu->addAction(QObject::tr("Show drawing"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); } bool ViewProviderDrawingPage::setEdit(int ModNum) diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 4d5993f24..3b5ba3f17 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -484,11 +484,15 @@ std::vector ViewProviderMesh::getDisplayModes(void) const bool ViewProviderMesh::setEdit(int ModNum) { + if (ModNum == ViewProvider::Transform) + return ViewProviderGeometryObject::setEdit(ModNum); return true; } void ViewProviderMesh::unsetEdit(int ModNum) { + if (ModNum == ViewProvider::Transform) + ViewProviderGeometryObject::unsetEdit(ModNum); } bool ViewProviderMesh::createToolMesh(const std::vector& rclPoly, const SbViewVolume& vol, diff --git a/src/Mod/Mesh/Gui/ViewProvider.h b/src/Mod/Mesh/Gui/ViewProvider.h index e425f011c..6390eb53a 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.h +++ b/src/Mod/Mesh/Gui/ViewProvider.h @@ -125,8 +125,7 @@ public: /** @name Editing */ //@{ - bool doubleClicked(void){return false;} - void setupContextMenu(QMenu*, QObject*, const char*) {} + bool doubleClicked(void){ return false; } void selectComponent(unsigned long facet); void deselectComponent(unsigned long facet); void selectFacet(unsigned long facet); diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index 795792821..5c75fff96 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -675,11 +675,15 @@ void TaskFilletEdges::clicked(int) bool TaskFilletEdges::accept() { - return widget->accept(); + bool ok = widget->accept(); + if (ok) + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + return ok; } bool TaskFilletEdges::reject() { + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); return true; } diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index ca2e9f6e6..a42c41841 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -508,12 +508,12 @@ void ViewProviderPartExt::setupContextMenu(QMenu* menu, QObject* receiver, const { Gui::ViewProviderGeometryObject::setupContextMenu(menu, receiver, member); QAction* act = menu->addAction(QObject::tr("Set colors..."), receiver, member); - act->setData(QVariant(getClassTypeId().getKey())); + act->setData(QVariant((int)ViewProvider::Color)); } bool ViewProviderPartExt::setEdit(int ModNum) { - if (ModNum == (int)getClassTypeId().getKey()) { + if (ModNum == ViewProvider::Color) { // When double-clicking on the item for this pad the // object unsets and sets its edit mode without closing // the task panel @@ -534,7 +534,7 @@ bool ViewProviderPartExt::setEdit(int ModNum) void ViewProviderPartExt::unsetEdit(int ModNum) { - if (ModNum == (int)getClassTypeId().getKey()) { + if (ModNum == ViewProvider::Color) { } else { Gui::ViewProviderGeometryObject::unsetEdit(ModNum); diff --git a/src/Mod/Part/Gui/ViewProviderMirror.cpp b/src/Mod/Part/Gui/ViewProviderMirror.cpp index 7712839f6..e99287ba0 100644 --- a/src/Mod/Part/Gui/ViewProviderMirror.cpp +++ b/src/Mod/Part/Gui/ViewProviderMirror.cpp @@ -65,14 +65,13 @@ void ViewProviderMirror::setupContextMenu(QMenu* menu, QObject* receiver, const { QAction* act; act = menu->addAction(QObject::tr("Edit mirror plane"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - act = menu->addAction(QObject::tr("Transform"), receiver, member); - act->setData(QVariant((int)ViewProvider::Transform)); + act->setData(QVariant((int)ViewProvider::Mirror)); + ViewProviderPart::setupContextMenu(menu, receiver, member); } bool ViewProviderMirror::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Mirror) { // get the properties from the mirror feature Part::Mirroring* mf = static_cast(getObject()); Base::BoundBox3d bbox = mf->Shape.getBoundingBox(); @@ -135,7 +134,7 @@ bool ViewProviderMirror::setEdit(int ModNum) void ViewProviderMirror::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Mirror) { SoCenterballManip* manip = static_cast(pcEditNode->getChild(0)); SbVec3f move = manip->translation.getValue(); @@ -206,19 +205,18 @@ void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const { QAction* act; act = menu->addAction(QObject::tr("Edit fillet edges"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - act = menu->addAction(QObject::tr("Transform"), receiver, member); - act->setData(QVariant((int)ViewProvider::Transform)); + act->setData(QVariant((int)ViewProvider::Fillet)); + PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); } bool ViewProviderFillet::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Fillet) { if (Gui::Control().activeDialog()) return false; Part::Fillet* fillet = static_cast(getObject()); Gui::Control().showDialog(new PartGui::TaskFilletEdges(fillet)); - return false; + return true; } else { ViewProviderPart::setEdit(ModNum); @@ -228,7 +226,8 @@ bool ViewProviderFillet::setEdit(int ModNum) void ViewProviderFillet::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Fillet) { + Gui::Control().closeDialog(); } else { ViewProviderPart::unsetEdit(ModNum); diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 3452aa51e..2722c8ed3 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -146,7 +146,7 @@ void CmdPartDesignPad::activated(int iMsg) if (support) doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); } - doCommand(Gui,"Gui.activeDocument().setEdit('%s',2)",FeatName.c_str()); + doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); //commitCommand(); adjustCameraPosition(); @@ -227,7 +227,7 @@ void CmdPartDesignPocket::activated(int iMsg) doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument()); doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); } - doCommand(Gui,"Gui.activeDocument().setEdit('%s',2)",FeatName.c_str()); + doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument()); copyVisual(FeatName.c_str(), "LineColor", support->getNameInDocument()); @@ -301,7 +301,7 @@ void CmdPartDesignRevolution::activated(int iMsg) if (support) doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument()); } - doCommand(Gui,"Gui.activeDocument().setEdit('%s',2)",FeatName.c_str()); + doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); if (support) { copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument()); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 84ebeadd5..562579a5d 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -44,7 +44,7 @@ ViewProvider::~ViewProvider() bool ViewProvider::doubleClicked(void) { - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',2)",this->pcObject->getNameInDocument()); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument()); return true; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp index 8c6dbf34c..79d6f1ee7 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp @@ -58,50 +58,54 @@ void ViewProviderPad::setupContextMenu(QMenu* menu, QObject* receiver, const cha { QAction* act; act = menu->addAction(QObject::tr("Edit pad"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - act = menu->addAction(QObject::tr("Transform"), receiver, member); - act->setData(QVariant((int)ViewProvider::Transform)); + act->setData(QVariant((int)ViewProvider::Pad)); + PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); } bool ViewProviderPad::setEdit(int ModNum) { - // When double-clicking on the item for this pad the - // object unsets and sets its edit mode without closing - // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgPadParameters *padDlg = qobject_cast(dlg); - if (padDlg && padDlg->getPadView() != this) - padDlg = 0; // another pad left open its task panel - if (dlg && !padDlg) { - QMessageBox msgBox; - msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - Gui::Control().closeDialog(); + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pad) { + // When double-clicking on the item for this pad the + // object unsets and sets its edit mode without closing + // the task panel + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + TaskDlgPadParameters *padDlg = qobject_cast(dlg); + if (padDlg && padDlg->getPadView() != this) + padDlg = 0; // another pad left open its task panel + if (dlg && !padDlg) { + QMessageBox msgBox; + msgBox.setText(QObject::tr("A dialog is already open in the task panel")); + msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + if (ret == QMessageBox::Yes) + Gui::Control().closeDialog(); + else + return false; + } + + // clear the selection (convenience) + Gui::Selection().clearSelection(); + if (ModNum == 1) + Gui::Command::openCommand("Change pad parameters"); + + // start the edit dialog + if (padDlg) + Gui::Control().showDialog(padDlg); else - return false; + Gui::Control().showDialog(new TaskDlgPadParameters(this)); + + return true; + } + else { + return ViewProviderPart::setEdit(ModNum); } - - // clear the selection (convenience) - Gui::Selection().clearSelection(); - if(ModNum == 1) - Gui::Command::openCommand("Change pad parameters"); - - // start the edit dialog - if (padDlg) - Gui::Control().showDialog(padDlg); - else - Gui::Control().showDialog(new TaskDlgPadParameters(this)); - - return true; } void ViewProviderPad::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pad) { // and update the pad //getSketchObject()->getDocument()->recompute(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp b/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp index 62aa0442e..0ad8876c6 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp @@ -54,54 +54,59 @@ std::vector ViewProviderPocket::claimChildren(void)const return temp; } + void ViewProviderPocket::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { QAction* act; act = menu->addAction(QObject::tr("Edit pocket"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - act = menu->addAction(QObject::tr("Transform"), receiver, member); - act->setData(QVariant((int)ViewProvider::Transform)); + act->setData(QVariant((int)ViewProvider::Pocket)); + PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); } bool ViewProviderPocket::setEdit(int ModNum) { - // When double-clicking on the item for this pad the - // object unsets and sets its edit mode without closing - // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgPocketParameters *padDlg = qobject_cast(dlg); - if (padDlg && padDlg->getPocketView() != this) - padDlg = 0; // another pad left open its task panel - if (dlg && !padDlg) { - QMessageBox msgBox; - msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - Gui::Control().closeDialog(); + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pocket) { + // When double-clicking on the item for this pad the + // object unsets and sets its edit mode without closing + // the task panel + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + TaskDlgPocketParameters *padDlg = qobject_cast(dlg); + if (padDlg && padDlg->getPocketView() != this) + padDlg = 0; // another pad left open its task panel + if (dlg && !padDlg) { + QMessageBox msgBox; + msgBox.setText(QObject::tr("A dialog is already open in the task panel")); + msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + if (ret == QMessageBox::Yes) + Gui::Control().closeDialog(); + else + return false; + } + + // clear the selection (convenience) + Gui::Selection().clearSelection(); + if(ModNum == 1) + Gui::Command::openCommand("Change pocket parameters"); + + // start the edit dialog + if (padDlg) + Gui::Control().showDialog(padDlg); else - return false; + Gui::Control().showDialog(new TaskDlgPocketParameters(this)); + + return true; + } + else { + return PartGui::ViewProviderPart::setEdit(ModNum); } - - // clear the selection (convenience) - Gui::Selection().clearSelection(); - if(ModNum == 1) - Gui::Command::openCommand("Change pocket parameters"); - - // start the edit dialog - if (padDlg) - Gui::Control().showDialog(padDlg); - else - Gui::Control().showDialog(new TaskDlgPocketParameters(this)); - - return true; } void ViewProviderPocket::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pocket) { // and update the pad //getSketchObject()->getDocument()->recompute(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp index e2e5a5442..7e17cf6c9 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp @@ -59,50 +59,54 @@ void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, co { QAction* act; act = menu->addAction(QObject::tr("Edit revolution"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - act = menu->addAction(QObject::tr("Transform"), receiver, member); - act->setData(QVariant((int)ViewProvider::Transform)); + act->setData(QVariant((int)ViewProvider::Revolve)); + PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); } bool ViewProviderRevolution::setEdit(int ModNum) { - // When double-clicking on the item for this pad the - // object unsets and sets its edit mode without closing - // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgRevolutionParameters *padDlg = qobject_cast(dlg); - if (padDlg && padDlg->getRevolutionView() != this) - padDlg = 0; // another pad left open its task panel - if (dlg && !padDlg) { - QMessageBox msgBox; - msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - Gui::Control().closeDialog(); + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Revolve) { + // When double-clicking on the item for this pad the + // object unsets and sets its edit mode without closing + // the task panel + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + TaskDlgRevolutionParameters *padDlg = qobject_cast(dlg); + if (padDlg && padDlg->getRevolutionView() != this) + padDlg = 0; // another pad left open its task panel + if (dlg && !padDlg) { + QMessageBox msgBox; + msgBox.setText(QObject::tr("A dialog is already open in the task panel")); + msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + if (ret == QMessageBox::Yes) + Gui::Control().closeDialog(); + else + return false; + } + + // clear the selection (convenience) + Gui::Selection().clearSelection(); + if (ModNum == 1) + Gui::Command::openCommand("Change revolution parameters"); + + // start the edit dialog + if (padDlg) + Gui::Control().showDialog(padDlg); else - return false; + Gui::Control().showDialog(new TaskDlgRevolutionParameters(this)); + + return true; + } + else { + return PartGui::ViewProviderPart::setEdit(ModNum); } - - // clear the selection (convenience) - Gui::Selection().clearSelection(); - if(ModNum == 1) - Gui::Command::openCommand("Change revolution parameters"); - - // start the edit dialog - if (padDlg) - Gui::Control().showDialog(padDlg); - else - Gui::Control().showDialog(new TaskDlgRevolutionParameters(this)); - - return true; } void ViewProviderRevolution::unsetEdit(int ModNum) { - if (ModNum == ViewProvider::Default) { + if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Revolve) { // and update the pad //getSketchObject()->getDocument()->recompute(); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 409c2f1c2..6a3df12ba 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -2573,8 +2573,7 @@ void ViewProviderSketch::attach(App::DocumentObject *pcFeat) void ViewProviderSketch::setupContextMenu(QMenu *menu, QObject *receiver, const char *member) { - QAction *act = menu->addAction(QObject::tr("Edit sketch"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); + menu->addAction(QObject::tr("Edit sketch"), receiver, member); } bool ViewProviderSketch::setEdit(int ModNum)