diff --git a/src/Gui/GLPainter.cpp b/src/Gui/GLPainter.cpp index d87a2e827..0a73b151b 100644 --- a/src/Gui/GLPainter.cpp +++ b/src/Gui/GLPainter.cpp @@ -302,6 +302,11 @@ Polyline::Polyline(View3DInventorViewer* v) : viewer(v) closed = true; stippled = false; line = 2.0; + + rgb_r = 1.0f; + rgb_g = 1.0f; + rgb_b = 1.0f; + rgb_a = 1.0f; } Polyline::Polyline() @@ -311,6 +316,11 @@ Polyline::Polyline() closed = true; stippled = false; line = 2.0; + + rgb_r = 1.0f; + rgb_g = 1.0f; + rgb_b = 1.0f; + rgb_a = 1.0f; } Polyline::~Polyline() @@ -340,10 +350,10 @@ void Polyline::setCoords(int x, int y) void Polyline::setColor(int r, int g, int b, int a) { - rgb_a = a; - rgb_b = b; - rgb_g = g; rgb_r = r; + rgb_g = g; + rgb_b = b; + rgb_a = a; } void Polyline::setClosed(bool c) @@ -366,6 +376,12 @@ void Polyline::addNode(const QPoint& p) _cNodeVector.push_back(p); } +void Polyline::popNode() +{ + if (!_cNodeVector.empty()) + _cNodeVector.pop_back(); +} + void Polyline::clear() { _cNodeVector.clear(); diff --git a/src/Gui/GLPainter.h b/src/Gui/GLPainter.h index 765c0a010..256c2f4e4 100644 --- a/src/Gui/GLPainter.h +++ b/src/Gui/GLPainter.h @@ -135,6 +135,7 @@ public: void setClosed(bool c); void setCloseStippled(bool c); void addNode(const QPoint& p); + void popNode(); void clear(); void paintGL(); }; diff --git a/src/Gui/MouseSelection.cpp b/src/Gui/MouseSelection.cpp index 5eb4bd4bd..e391ef691 100644 --- a/src/Gui/MouseSelection.cpp +++ b/src/Gui/MouseSelection.cpp @@ -48,7 +48,6 @@ using namespace Gui; AbstractMouseSelection::AbstractMouseSelection() : _pcView3D(0) { m_bInner = true; - mustRedraw = false; } void AbstractMouseSelection::grabMouseModel(Gui::View3DInventorViewer* viewer) @@ -73,10 +72,7 @@ void AbstractMouseSelection::releaseMouseModel() void AbstractMouseSelection::redraw() { - // Note: For any reason it does not work to do a redraw in the actualRedraw() method of the - // viewer class. So, we do the redraw when the user continues moving the cursor. E.g. have - // a look to PolyPickerSelection::draw() - mustRedraw = true; + // obsolete } int AbstractMouseSelection::handleEvent(const SoEvent* const ev, const SbViewportRegion& vp) @@ -272,6 +268,8 @@ void PolyPickerSelection::initialize() _pcView3D->addGraphicsItem(&polyline); _pcView3D->setRenderType(View3DInventorViewer::Image); _pcView3D->redraw(); + + lastConfirmed = false; } void PolyPickerSelection::terminate() @@ -325,7 +323,7 @@ int PolyPickerSelection::mouseButtonEvent(const SoMouseButtonEvent* const e, con polyline.clear(); }; polyline.addNode(pos); - polyline.setCoords(pos.x(), pos.y()); + lastConfirmed = true; m_iXnew = pos.x(); m_iYnew = pos.y(); m_iXold = pos.x(); m_iYold = pos.y(); } @@ -406,10 +404,15 @@ int PolyPickerSelection::locationEvent(const SoLocation2Event* const e, const QP QCursor::setPos(newPos); #endif } - polyline.setCoords(clPoint.x(), clPoint.y()); + + if (!lastConfirmed) + polyline.popNode(); + polyline.addNode(clPoint); + lastConfirmed = false; + + draw(); } - - draw(); + m_iXnew = clPoint.x(); m_iYnew = clPoint.y(); diff --git a/src/Gui/MouseSelection.h b/src/Gui/MouseSelection.h index 7c8c544a7..7fe42a688 100644 --- a/src/Gui/MouseSelection.h +++ b/src/Gui/MouseSelection.h @@ -99,7 +99,6 @@ protected: int m_iXold, m_iYold; int m_iXnew, m_iYnew; SbBool m_bInner; - SbBool mustRedraw; std::vector _clPoly; }; @@ -145,6 +144,7 @@ protected: virtual int popupMenu(); Gui::Polyline polyline; + bool lastConfirmed; }; // ----------------------------------------------------------------------------------- diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index 64aff418d..49dd640b7 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -58,9 +58,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -835,7 +837,11 @@ void CmdMeshPolyCut::activated(int iMsg) 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->setColor(0.0f,0.0f,1.0f); + clip->setLineWidth(1.0f); + viewer->navigationStyle()->startSelection(clip); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::clipMeshCallback); } else { diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index ee878513e..d2d3e19d2 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -425,7 +425,7 @@ void ViewProviderPoints::clipPointsCallback(void * ud, SoEventCallback * n) } } - view->getSoRenderManager()->render(); + view->redraw(); } void ViewProviderPoints::cut(const std::vector& picked, Gui::View3DInventorViewer &Viewer)