replace boolean to check for inside/outside cutting with enum values

This commit is contained in:
wmayer
2018-09-18 18:25:51 +02:00
parent 2290a37a83
commit 644cfa06bb
16 changed files with 248 additions and 72 deletions

View File

@@ -1118,6 +1118,7 @@ SET(FreeCADGui_CPP_SRCS
GuiConsole.cpp
Macro.cpp
MergeDocuments.cpp
Namespace.h
resource.cpp
Control.cpp
SpaceballEvent.cpp

View File

@@ -25,7 +25,9 @@
#define GUI_GLPAINTER_H
#ifdef FC_OS_WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#endif
#ifdef FC_OS_MACOSX

View File

@@ -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;
}
}
// -----------------------------------------------------------------------------------

View File

@@ -24,11 +24,13 @@
#ifndef MOUSESELECTION_H
#define MOUSESELECTION_H
#include <bitset>
#include <vector>
#include <Inventor/SbLinear.h>
#include <Inventor/SbVec2f.h>
#include <QCursor>
#include "GLPainter.h"
#include <Gui/GLPainter.h>
#include <Gui/Namespace.h>
// forwards
class QMouseEvent;
@@ -68,8 +70,8 @@ public:
const std::vector<SbVec2s>& 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<SbVec2s> _clPoly;
};
@@ -161,8 +163,18 @@ public:
PolyClipSelection();
virtual ~PolyClipSelection();
inline void setRole(SelectionRole pos, bool on) {
selectionBits.set(static_cast<size_t>(pos), on);
}
inline bool testRole(SelectionRole pos) const {
return selectionBits.test(static_cast<size_t>(pos));
}
protected:
virtual int popupMenu();
private:
std::bitset<8> selectionBits;
};
// -----------------------------------------------------------------------------------

42
src/Gui/Namespace.h Normal file
View File

@@ -0,0 +1,42 @@
/***************************************************************************
* Copyright (c) 2018 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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

View File

@@ -1315,10 +1315,10 @@ SbBool NavigationStyle::isSelecting() const
return (mouseSelection ? true : false);
}
const std::vector<SbVec2s>& NavigationStyle::getPolygon(SbBool* clip_inner) const
const std::vector<SbVec2s>& 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);

View File

@@ -36,6 +36,7 @@
#include <QCursor>
#include <QEvent>
#include <Base/BaseClass.h>
#include <Gui/Namespace.h>
// forward declarations
class SoEvent;
@@ -157,7 +158,7 @@ public:
void startSelection(SelectionMode = Lasso);
void stopSelection();
SbBool isSelecting() const;
const std::vector<SbVec2s>& getPolygon(SbBool* clip_inner=0) const;
const std::vector<SbVec2s>& getPolygon(SelectionRole* role=0) const;
void setOrbitStyle(OrbitStyle style);
OrbitStyle getOrbitStyle() const;
@@ -238,7 +239,7 @@ protected:
//@{
AbstractMouseSelection* mouseSelection;
std::vector<SbVec2s> pcPolygon;
SbBool clipInner;
SelectionRole selectedRole;
//@}
/** @name Spinning data */

View File

@@ -1175,9 +1175,9 @@ bool View3DInventorViewer::isSelecting() const
return navigation->isSelecting();
}
const std::vector<SbVec2s>& View3DInventorViewer::getPolygon(SbBool* clip_inner) const
const std::vector<SbVec2s>& 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<SbVec2f> View3DInventorViewer::getGLPolygon(const std::vector<SbVec2
return poly;
}
std::vector<SbVec2f> View3DInventorViewer::getGLPolygon(SbBool* clip_inner) const
std::vector<SbVec2f> View3DInventorViewer::getGLPolygon(SelectionRole* role) const
{
const std::vector<SbVec2s>& pnts = navigation->getPolygon(clip_inner);
const std::vector<SbVec2s>& pnts = navigation->getPolygon(role);
return getGLPolygon(pnts);
}

View File

@@ -38,6 +38,7 @@
#include <QImage>
#include <Gui/Selection.h>
#include <Gui/Namespace.h>
class SoTranslation;
class SoTransform;
@@ -217,9 +218,9 @@ public:
void startSelection(SelectionMode = Lasso);
void stopSelection();
bool isSelecting() const;
std::vector<SbVec2f> getGLPolygon(SbBool* clip_inner=0) const;
std::vector<SbVec2f> getGLPolygon(SelectionRole* role=0) const;
std::vector<SbVec2f> getGLPolygon(const std::vector<SbVec2s>&) const;
const std::vector<SbVec2s>& getPolygon(SbBool* clip_inner=0) const;
const std::vector<SbVec2s>& getPolygon(SelectionRole* role=0) const;
//@}
/// Returns the screen coordinates of the origin of the path's tail object

View File

@@ -916,8 +916,8 @@ void DefineNodesCallback(void * ud, SoEventCallback * n)
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,ud);
n->setHandled();
SbBool clip_inner;
std::vector<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
Gui::SelectionRole role;
std::vector<SbVec2f> clPoly = view->getGLPolygon(&role);
if (clPoly.size() < 3)
return;
if (clPoly.front() != clPoly.back())

View File

@@ -141,8 +141,8 @@ void TaskCreateNodeSet::DefineNodesCallback(void * ud, SoEventCallback * n)
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback,ud);
n->setHandled();
SbBool clip_inner;
std::vector<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
Gui::SelectionRole role;
std::vector<SbVec2f> 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<SbVec2f>::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)

View File

@@ -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;

View File

@@ -27,6 +27,7 @@
# include <stdlib.h>
# include <QAction>
# include <QMenu>
# include <QTimer>
# include <Inventor/SbBox2s.h>
# include <Inventor/SbLine.h>
# include <Inventor/SbPlane.h>
@@ -813,6 +814,58 @@ void ViewProviderMesh::showOpenEdges(bool show)
(void)show;
}
namespace MeshGui {
class MeshSplit {
public:
MeshSplit(ViewProviderMesh* mesh,
const std::vector<SbVec2f>& 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<Mesh::Feature*>(doc->addObject("Mesh::Feature"));
Mesh::Feature* org = static_cast<Mesh::Feature*>(mesh->getObject());
cpy->Label.setValue(org->Label.getValue());
cpy->Mesh.setValue(org->Mesh.getValue());
return static_cast<ViewProviderMesh*>(gui->getViewProvider(cpy));
}
private:
ViewProviderMesh* mesh;
Gui::ViewVolumeProjection proj;
std::vector<SbVec2f> 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<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
Gui::SelectionRole role;
std::vector<SbVec2f> 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<Gui::ViewProvider*> views = view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId());
if (!views.empty()) {
Gui::Application::Instance->activeDocument()->openCommand("Cut");
bool commitCommand = false;
for (std::vector<Gui::ViewProvider*>::iterator it = views.begin(); it != views.end(); ++it) {
ViewProviderMesh* self = static_cast<ViewProviderMesh*>(*it);
if (self->getEditingMode() > -1) {
@@ -843,11 +897,31 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n)
Gui::ViewVolumeProjection proj(vv);
proj.setTransform(static_cast<Mesh::Feature*>(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<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
Gui::SelectionRole role;
std::vector<SbVec2f> 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<Gui::ViewProvider*> 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<Gui::ViewProvider*>::iterator it = views.begin(); it != views.end(); ++it) {
ViewProviderMesh* self = static_cast<ViewProviderMesh*>(*it);
if (self->getEditingMode() > -1) {
@@ -883,11 +958,31 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n)
Gui::ViewVolumeProjection proj(vv);
proj.setTransform(static_cast<Mesh::Feature*>(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<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
Gui::SelectionRole role;
std::vector<SbVec2f> 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<SbVec2f> clPoly = view->getGLPolygon(&clip_inner);
Gui::SelectionRole role;
std::vector<SbVec2f> 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);
}
}
}

View File

@@ -158,6 +158,8 @@ public:
std::vector<unsigned long> getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const;
std::vector<unsigned long> getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const;
std::vector<unsigned long> getVisibleFacets(const SbViewportRegion&, SoCamera*) const;
virtual void cutMesh(const std::vector<SbVec2f>& picked, const Base::ViewProjMethod& proj, SbBool inner);
virtual void trimMesh(const std::vector<SbVec2f>& picked, const Base::ViewProjMethod& proj, SbBool inner);
virtual void removeFacets(const std::vector<unsigned long>&);
/*! The size of the array must be equal to the number of facets. */
void setFacetTransparency(const std::vector<float>&);
@@ -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<SbVec2f>& picked, const Base::ViewProjMethod& proj, SbBool inner);
virtual void trimMesh(const std::vector<SbVec2f>& 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);

View File

@@ -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";

View File

@@ -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<Mesh::Feature*>(*it)->Mesh.finishEditing();
}
else if (side == Outer) {
else if (role == Gui::SelectionRole::Outer) {
mesh->trim(polygon2d, proj, Mesh::MeshObject::OUTER);
static_cast<Mesh::Feature*>(*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<Mesh::Feature*>(*it)->Mesh.finishEditing();