diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 706aba5e99..92838b4fa8 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -1118,6 +1118,7 @@ SET(FreeCADGui_CPP_SRCS GuiConsole.cpp Macro.cpp MergeDocuments.cpp + Namespace.h resource.cpp Control.cpp SpaceballEvent.cpp diff --git a/src/Gui/GLPainter.h b/src/Gui/GLPainter.h index 4a5acfdfbe..af69c24e31 100644 --- a/src/Gui/GLPainter.h +++ b/src/Gui/GLPainter.h @@ -25,7 +25,9 @@ #define GUI_GLPAINTER_H #ifdef FC_OS_WIN32 +#ifndef NOMINMAX #define NOMINMAX +#endif #include #endif #ifdef FC_OS_MACOSX diff --git a/src/Gui/MouseSelection.cpp b/src/Gui/MouseSelection.cpp index 488304efcf..06c0c97f7f 100644 --- a/src/Gui/MouseSelection.cpp +++ b/src/Gui/MouseSelection.cpp @@ -51,7 +51,7 @@ AbstractMouseSelection::AbstractMouseSelection() : _pcView3D(0) m_iYold = 0; m_iXnew = 0; m_iYnew = 0; - m_bInner = true; + m_selectedRole = SelectionRole::None; } void AbstractMouseSelection::grabMouseModel(Gui::View3DInventorViewer* viewer) @@ -434,6 +434,8 @@ int PolyPickerSelection::keyboardEvent(const SoKeyboardEvent* const) PolyClipSelection::PolyClipSelection() { + selectionBits.set(1); + selectionBits.set(2); } PolyClipSelection::~PolyClipSelection() @@ -445,8 +447,13 @@ int PolyClipSelection::popupMenu() QMenu menu; QAction* ci = menu.addAction(QObject::tr("Inner")); QAction* co = menu.addAction(QObject::tr("Outer")); + QAction* cs = menu.addAction(QObject::tr("Split")); QAction* ca = menu.addAction(QObject::tr("Cancel")); + ci->setVisible(testRole(SelectionRole::Inner)); + co->setVisible(testRole(SelectionRole::Outer)); + cs->setVisible(testRole(SelectionRole::Split)); + if (getPositions().size() < 3) { ci->setEnabled(false); co->setEnabled(false); @@ -455,17 +462,25 @@ int PolyClipSelection::popupMenu() QAction* id = menu.exec(QCursor::pos()); if (id == ci) { - m_bInner = true; + m_selectedRole = SelectionRole::Inner; return Finish; } else if (id == co) { - m_bInner = false; + m_selectedRole = SelectionRole::Outer; return Finish; } - else if (id == ca) + else if (id == cs) { + m_selectedRole = SelectionRole::Split; + return Finish; + } + else if (id == ca) { + m_selectedRole = SelectionRole::None; return Cancel; - else + } + else { + m_selectedRole = SelectionRole::None; return Restart; + } } // ----------------------------------------------------------------------------------- diff --git a/src/Gui/MouseSelection.h b/src/Gui/MouseSelection.h index 1fb3aa59a6..132326bbb0 100644 --- a/src/Gui/MouseSelection.h +++ b/src/Gui/MouseSelection.h @@ -24,11 +24,13 @@ #ifndef MOUSESELECTION_H #define MOUSESELECTION_H +#include #include #include #include #include -#include "GLPainter.h" +#include +#include // forwards class QMouseEvent; @@ -68,8 +70,8 @@ public: const std::vector& getPositions() const { return _clPoly; } - SbBool isInner() const { - return m_bInner; + SelectionRole selectedRole() const { + return m_selectedRole; } void redraw(); @@ -82,23 +84,23 @@ public: protected: virtual int mouseButtonEvent(const SoMouseButtonEvent* const, const QPoint&) { return 0; - }; - virtual int locationEvent(const SoLocation2Event* const, const QPoint&) { + } + virtual int locationEvent(const SoLocation2Event* const, const QPoint&) { return 0; - }; - virtual int keyboardEvent(const SoKeyboardEvent* const) { + } + virtual int keyboardEvent(const SoKeyboardEvent* const){ return 0; - }; + } /// drawing stuff - virtual void draw() {}; + virtual void draw() {} protected: Gui::View3DInventorViewer* _pcView3D; QCursor m_cPrevCursor; int m_iXold, m_iYold; int m_iXnew, m_iYnew; - SbBool m_bInner; + SelectionRole m_selectedRole; std::vector _clPoly; }; @@ -161,8 +163,18 @@ public: PolyClipSelection(); virtual ~PolyClipSelection(); + inline void setRole(SelectionRole pos, bool on) { + selectionBits.set(static_cast(pos), on); + } + inline bool testRole(SelectionRole pos) const { + return selectionBits.test(static_cast(pos)); + } + protected: virtual int popupMenu(); + +private: + std::bitset<8> selectionBits; }; // ----------------------------------------------------------------------------------- diff --git a/src/Gui/Namespace.h b/src/Gui/Namespace.h new file mode 100644 index 0000000000..4ad28616cd --- /dev/null +++ b/src/Gui/Namespace.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2018 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef GUI_NAMESPACE_H +#define GUI_NAMESPACE_H + + +namespace Gui { + +enum SelectionRole { + None = 0, + Inner = 1, + Outer = 2, + Split = 3, + Custom0 = 4, + Custom1 = 5, + Custom2 = 6, +}; + +} // namespace Gui + +#endif // GUI_NAMESPACE_H diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index fe92f8995f..489834fb3b 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -1315,10 +1315,10 @@ SbBool NavigationStyle::isSelecting() const return (mouseSelection ? true : false); } -const std::vector& NavigationStyle::getPolygon(SbBool* clip_inner) const +const std::vector& NavigationStyle::getPolygon(SelectionRole* role) const { - if (clip_inner) - *clip_inner = this->clipInner; + if (role) + *role = this->selectedRole; return pcPolygon; } @@ -1429,7 +1429,7 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev) } else if (hd==AbstractMouseSelection::Finish) { pcPolygon = mouseSelection->getPositions(); - clipInner = mouseSelection->isInner(); + selectedRole = mouseSelection->selectedRole(); delete mouseSelection; mouseSelection = 0; syncWithEvent(ev); diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 7f51dcae34..6144c73952 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -36,6 +36,7 @@ #include #include #include +#include // forward declarations class SoEvent; @@ -157,7 +158,7 @@ public: void startSelection(SelectionMode = Lasso); void stopSelection(); SbBool isSelecting() const; - const std::vector& getPolygon(SbBool* clip_inner=0) const; + const std::vector& getPolygon(SelectionRole* role=0) const; void setOrbitStyle(OrbitStyle style); OrbitStyle getOrbitStyle() const; @@ -238,7 +239,7 @@ protected: //@{ AbstractMouseSelection* mouseSelection; std::vector pcPolygon; - SbBool clipInner; + SelectionRole selectedRole; //@} /** @name Spinning data */ diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 9e4f3f02e9..7584292eac 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1175,9 +1175,9 @@ bool View3DInventorViewer::isSelecting() const return navigation->isSelecting(); } -const std::vector& View3DInventorViewer::getPolygon(SbBool* clip_inner) const +const std::vector& View3DInventorViewer::getPolygon(SelectionRole* role) const { - return navigation->getPolygon(clip_inner); + return navigation->getPolygon(role); } SbVec2f View3DInventorViewer::screenCoordsOfPath(SoPath* path) const @@ -1263,9 +1263,9 @@ std::vector View3DInventorViewer::getGLPolygon(const std::vector View3DInventorViewer::getGLPolygon(SbBool* clip_inner) const +std::vector View3DInventorViewer::getGLPolygon(SelectionRole* role) const { - const std::vector& pnts = navigation->getPolygon(clip_inner); + const std::vector& pnts = navigation->getPolygon(role); return getGLPolygon(pnts); } diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index e9d517109c..bdef962a6b 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -38,6 +38,7 @@ #include #include +#include class SoTranslation; class SoTransform; @@ -217,9 +218,9 @@ public: void startSelection(SelectionMode = Lasso); void stopSelection(); bool isSelecting() const; - std::vector getGLPolygon(SbBool* clip_inner=0) const; + std::vector getGLPolygon(SelectionRole* role=0) const; std::vector getGLPolygon(const std::vector&) const; - const std::vector& getPolygon(SbBool* clip_inner=0) const; + const std::vector& getPolygon(SelectionRole* role=0) const; //@} /// Returns the screen coordinates of the origin of the path's tail object diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 085ab42e1a..54ba1230de 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -916,8 +916,8 @@ void DefineNodesCallback(void * ud, SoEventCallback * n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,ud); n->setHandled(); - SbBool clip_inner; - std::vector clPoly = view->getGLPolygon(&clip_inner); + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) return; if (clPoly.front() != clPoly.back()) diff --git a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp index 5b5515ab1f..9d14e38e3f 100644 --- a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp @@ -141,8 +141,8 @@ void TaskCreateNodeSet::DefineNodesCallback(void * ud, SoEventCallback * n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,ud); n->setHandled(); - SbBool clip_inner; - std::vector clPoly = view->getGLPolygon(&clip_inner); + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) return; if (clPoly.front() != clPoly.back()) @@ -155,8 +155,7 @@ void TaskCreateNodeSet::DefineNodesCallback(void * ud, SoEventCallback * n) for (std::vector::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it) polygon.Add(Base::Vector2d((*it)[0],(*it)[1])); - taskBox->DefineNodes(polygon,proj,clip_inner); - + taskBox->DefineNodes(polygon,proj,role == Gui::SelectionRole::Inner ? true : false); } void TaskCreateNodeSet::DefineNodes(const Base::Polygon2d &polygon,const Gui::ViewVolumeProjection &proj,bool inner) diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index b3dce9fe98..80e13ab637 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -743,7 +743,8 @@ void CmdMeshPolySegm::activated(int) Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Clip); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::segmMeshCallback); + viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), + MeshGui::ViewProviderMeshFaceSet::segmMeshCallback); } else { return; @@ -898,10 +899,12 @@ void CmdMeshPolyCut::activated(int) viewer->setEditing(true); Gui::PolyClipSelection* clip = new Gui::PolyClipSelection(); + clip->setRole(Gui::SelectionRole::Split, true); clip->setColor(0.0f,0.0f,1.0f); clip->setLineWidth(1.0f); viewer->navigationStyle()->startSelection(clip); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::clipMeshCallback); + viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), + MeshGui::ViewProviderMeshFaceSet::clipMeshCallback); } else { return; @@ -954,9 +957,14 @@ void CmdMeshPolyTrim::activated(int) if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); - viewer->startSelection(Gui::View3DInventorViewer::Clip); + + Gui::PolyClipSelection* clip = new Gui::PolyClipSelection(); + clip->setRole(Gui::SelectionRole::Split, true); + clip->setColor(0.0f,0.0f,1.0f); + clip->setLineWidth(1.0f); + viewer->navigationStyle()->startSelection(clip); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), - MeshGui::ViewProviderMeshFaceSet::trimMeshCallback); + MeshGui::ViewProviderMeshFaceSet::trimMeshCallback); } else { return; @@ -1066,7 +1074,8 @@ void CmdMeshPolySplit::activated(int) Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Clip); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::partMeshCallback); + viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), + MeshGui::ViewProviderMeshFaceSet::partMeshCallback); } else { return; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 260318173e..1b0255ac06 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -27,6 +27,7 @@ # include # include # include +# include # include # include # include @@ -813,6 +814,58 @@ void ViewProviderMesh::showOpenEdges(bool show) (void)show; } +namespace MeshGui { +class MeshSplit { +public: + MeshSplit(ViewProviderMesh* mesh, + const std::vector& poly, + const Gui::ViewVolumeProjection& proj) + : mesh(mesh) + , poly(poly) + , proj(proj) + { + + } + ~MeshSplit() { + + } + void cutMesh() { + Gui::Document* gui = mesh->getDocument(); + gui->openCommand("Cut"); + ViewProviderMesh* copy = makeCopy(); + mesh->cutMesh(poly, proj, false); + copy->cutMesh(poly, proj, true); + gui->commitCommand(); + delete this; + } + void trimMesh() { + Gui::Document* gui = mesh->getDocument(); + gui->openCommand("Trim"); + ViewProviderMesh* copy = makeCopy(); + mesh->trimMesh(poly, proj, false); + copy->trimMesh(poly, proj, true); + gui->commitCommand(); + delete this; + } + ViewProviderMesh* makeCopy() const { + Gui::Document* gui = mesh->getDocument(); + App::Document* doc = gui->getDocument(); + + Mesh::Feature* cpy = static_cast(doc->addObject("Mesh::Feature")); + Mesh::Feature* org = static_cast(mesh->getObject()); + cpy->Label.setValue(org->Label.getValue()); + cpy->Mesh.setValue(org->Mesh.getValue()); + + return static_cast(gui->getViewProvider(cpy)); + } + +private: + ViewProviderMesh* mesh; + Gui::ViewVolumeProjection proj; + std::vector poly; +}; +} + void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) { // show the wait cursor because this could take quite some time @@ -824,8 +877,8 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), clipMeshCallback,ud); n->setHandled(); - SbBool clip_inner; - std::vector clPoly = view->getGLPolygon(&clip_inner); + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) return; if (clPoly.front() != clPoly.back()) @@ -834,6 +887,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) std::vector views = view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); if (!views.empty()) { Gui::Application::Instance->activeDocument()->openCommand("Cut"); + bool commitCommand = false; for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { ViewProviderMesh* self = static_cast(*it); if (self->getEditingMode() > -1) { @@ -843,11 +897,31 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) Gui::ViewVolumeProjection proj(vv); proj.setTransform(static_cast(self->getObject())-> Placement.getValue().toMatrix()); - self->cutMesh(clPoly, proj, clip_inner); + if (role == Gui::SelectionRole::Inner) { + self->cutMesh(clPoly, proj, true); + commitCommand = true; + } + else if (role == Gui::SelectionRole::Outer) { + self->cutMesh(clPoly, proj, false); + commitCommand = true; + } + else if (role == Gui::SelectionRole::Split) { + // We must delay the split because it adds a new + // node to the scenegraph which cannot be done while + // traversing it + Gui::TimerFunction* func = new Gui::TimerFunction(); + func->setAutoDelete(true); + MeshSplit* split = new MeshSplit(self, clPoly, proj); + func->setFunction(boost::bind(&MeshSplit::cutMesh, split)); + QTimer::singleShot(0, func, SLOT(timeout())); + } } } - Gui::Application::Instance->activeDocument()->commitCommand(); + if (commitCommand) + Gui::Application::Instance->activeDocument()->commitCommand(); + else + Gui::Application::Instance->activeDocument()->abortCommand(); view->redraw(); } @@ -864,8 +938,8 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), trimMeshCallback,ud); n->setHandled(); - SbBool clip_inner; - std::vector clPoly = view->getGLPolygon(&clip_inner); + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) return; if (clPoly.front() != clPoly.back()) @@ -873,7 +947,8 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n) std::vector views = view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); if (!views.empty()) { - Gui::Application::Instance->activeDocument()->openCommand("Cut"); + Gui::Application::Instance->activeDocument()->openCommand("Trim"); + bool commitCommand = false; for (std::vector::iterator it = views.begin(); it != views.end(); ++it) { ViewProviderMesh* self = static_cast(*it); if (self->getEditingMode() > -1) { @@ -883,11 +958,31 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n) Gui::ViewVolumeProjection proj(vv); proj.setTransform(static_cast(self->getObject())-> Placement.getValue().toMatrix()); - self->trimMesh(clPoly, proj, clip_inner); + if (role == Gui::SelectionRole::Inner) { + self->trimMesh(clPoly, proj, true); + commitCommand = true; + } + else if (role == Gui::SelectionRole::Outer) { + self->trimMesh(clPoly, proj, false); + commitCommand = true; + } + else if (role == Gui::SelectionRole::Split) { + // We must delay the split because it adds a new + // node to the scenegraph which cannot be done while + // traversing it + Gui::TimerFunction* func = new Gui::TimerFunction(); + func->setAutoDelete(true); + MeshSplit* split = new MeshSplit(self, clPoly, proj); + func->setFunction(boost::bind(&MeshSplit::trimMesh, split)); + QTimer::singleShot(0, func, SLOT(timeout())); + } } } - Gui::Application::Instance->activeDocument()->commitCommand(); + if (commitCommand) + Gui::Application::Instance->activeDocument()->commitCommand(); + else + Gui::Application::Instance->activeDocument()->abortCommand(); view->redraw(); } @@ -904,8 +999,8 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), partMeshCallback,ud); cb->setHandled(); - SbBool clip_inner; - std::vector clPoly = view->getGLPolygon(&clip_inner); + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) return; if (clPoly.front() != clPoly.back()) @@ -941,7 +1036,10 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb) plm.invert(); MeshCore::MeshKernel copyToolMesh(toolMesh); copyToolMesh.Transform(plm.toMatrix()); - that->splitMesh(copyToolMesh, cNormal, clip_inner); + if (role == Gui::SelectionRole::Inner) + that->splitMesh(copyToolMesh, cNormal, true); + else + that->splitMesh(copyToolMesh, cNormal, false); } } } @@ -965,8 +1063,8 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), segmMeshCallback,ud); cb->setHandled(); - SbBool clip_inner; - std::vector clPoly = view->getGLPolygon(&clip_inner); + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) return; if (clPoly.front() != clPoly.back()) @@ -1002,7 +1100,10 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb) plm.invert(); MeshCore::MeshKernel copyToolMesh(toolMesh); copyToolMesh.Transform(plm.toMatrix()); - that->segmentMesh(copyToolMesh, cNormal, clip_inner); + if (role == Gui::SelectionRole::Inner) + that->segmentMesh(copyToolMesh, cNormal, true); + else + that->segmentMesh(copyToolMesh, cNormal, false); } } } diff --git a/src/Mod/Mesh/Gui/ViewProvider.h b/src/Mod/Mesh/Gui/ViewProvider.h index 8adc3b0354..e5636eb449 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.h +++ b/src/Mod/Mesh/Gui/ViewProvider.h @@ -158,6 +158,8 @@ public: std::vector getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const; std::vector getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const; std::vector getVisibleFacets(const SbViewportRegion&, SoCamera*) const; + virtual void cutMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner); + virtual void trimMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner); virtual void removeFacets(const std::vector&); /*! The size of the array must be equal to the number of facets. */ void setFacetTransparency(const std::vector&); @@ -174,8 +176,6 @@ protected: void onChanged(const App::Property* prop); virtual void showOpenEdges(bool); void setOpenEdgeColorFrom(const App::Color& col); - virtual void cutMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner); - virtual void trimMesh(const std::vector& picked, const Base::ViewProjMethod& proj, SbBool inner); virtual void splitMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner); virtual void segmentMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner); virtual void faceInfo(unsigned long facet); diff --git a/src/Mod/Mesh/Gui/Workbench.cpp b/src/Mod/Mesh/Gui/Workbench.cpp index 84940f6fe8..95f3458f8b 100644 --- a/src/Mod/Mesh/Gui/Workbench.cpp +++ b/src/Mod/Mesh/Gui/Workbench.cpp @@ -192,9 +192,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* cutting = new Gui::MenuItem; cutting->setCommand("Cutting"); *cutting << "Mesh_PolyCut" - << "Mesh_PolySplit" - << "Mesh_PolySegm" << "Mesh_PolyTrim" + //<< "Mesh_PolySegm" << "Mesh_TrimByPlane" << "Mesh_SectionByPlane"; diff --git a/src/Mod/MeshPart/Gui/Command.cpp b/src/Mod/MeshPart/Gui/Command.cpp index f4bc43201d..1a768cd556 100644 --- a/src/Mod/MeshPart/Gui/Command.cpp +++ b/src/Mod/MeshPart/Gui/Command.cpp @@ -102,26 +102,20 @@ void CmdMeshPartTrimByPlane::activated(int) msgBox.setText(qApp->translate("MeshPart_TrimByPlane","Select the side you want to keep.")); QPushButton* inner = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Inner"), QMessageBox::ActionRole); QPushButton* outer = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Outer"), QMessageBox::ActionRole); - QPushButton* both = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Both"), QMessageBox::ActionRole); + QPushButton* split = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Split"), QMessageBox::ActionRole); msgBox.setDefaultButton(inner); msgBox.exec(); QAbstractButton* click = msgBox.clickedButton(); - enum Side { - Inner, - Outer, - Both - }; - - Side side; + Gui::SelectionRole role; if (inner == click) { - side = Inner; + role = Gui::SelectionRole::Inner; } else if (outer == click) { - side = Outer; + role = Gui::SelectionRole::Outer; } - else if (both == click) { - side = Both; + else if (split == click) { + role = Gui::SelectionRole::Split; } else { // abort @@ -168,15 +162,15 @@ void CmdMeshPartTrimByPlane::activated(int) polygon2d.Add(Base::Vector2d(p3.x, p3.y)); polygon2d.Add(Base::Vector2d(p4.x, p4.y)); - if (side == Inner) { + if (role == Gui::SelectionRole::Inner) { mesh->trim(polygon2d, proj, Mesh::MeshObject::INNER); static_cast(*it)->Mesh.finishEditing(); } - else if (side == Outer) { + else if (role == Gui::SelectionRole::Outer) { mesh->trim(polygon2d, proj, Mesh::MeshObject::OUTER); static_cast(*it)->Mesh.finishEditing(); } - else if (side == Both) { + else if (role == Gui::SelectionRole::Split) { Mesh::MeshObject copy(*mesh); mesh->trim(polygon2d, proj, Mesh::MeshObject::INNER); static_cast(*it)->Mesh.finishEditing();