+ fix broken PolyPickerSelection
This commit is contained in:
parent
6b01685808
commit
e404490651
|
@ -302,6 +302,11 @@ Polyline::Polyline(View3DInventorViewer* v) : viewer(v)
|
||||||
closed = true;
|
closed = true;
|
||||||
stippled = false;
|
stippled = false;
|
||||||
line = 2.0;
|
line = 2.0;
|
||||||
|
|
||||||
|
rgb_r = 1.0f;
|
||||||
|
rgb_g = 1.0f;
|
||||||
|
rgb_b = 1.0f;
|
||||||
|
rgb_a = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyline::Polyline()
|
Polyline::Polyline()
|
||||||
|
@ -311,6 +316,11 @@ Polyline::Polyline()
|
||||||
closed = true;
|
closed = true;
|
||||||
stippled = false;
|
stippled = false;
|
||||||
line = 2.0;
|
line = 2.0;
|
||||||
|
|
||||||
|
rgb_r = 1.0f;
|
||||||
|
rgb_g = 1.0f;
|
||||||
|
rgb_b = 1.0f;
|
||||||
|
rgb_a = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyline::~Polyline()
|
Polyline::~Polyline()
|
||||||
|
@ -340,10 +350,10 @@ void Polyline::setCoords(int x, int y)
|
||||||
|
|
||||||
void Polyline::setColor(int r, int g, int b, int a)
|
void Polyline::setColor(int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
rgb_a = a;
|
|
||||||
rgb_b = b;
|
|
||||||
rgb_g = g;
|
|
||||||
rgb_r = r;
|
rgb_r = r;
|
||||||
|
rgb_g = g;
|
||||||
|
rgb_b = b;
|
||||||
|
rgb_a = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Polyline::setClosed(bool c)
|
void Polyline::setClosed(bool c)
|
||||||
|
@ -366,6 +376,12 @@ void Polyline::addNode(const QPoint& p)
|
||||||
_cNodeVector.push_back(p);
|
_cNodeVector.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Polyline::popNode()
|
||||||
|
{
|
||||||
|
if (!_cNodeVector.empty())
|
||||||
|
_cNodeVector.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
void Polyline::clear()
|
void Polyline::clear()
|
||||||
{
|
{
|
||||||
_cNodeVector.clear();
|
_cNodeVector.clear();
|
||||||
|
|
|
@ -135,6 +135,7 @@ public:
|
||||||
void setClosed(bool c);
|
void setClosed(bool c);
|
||||||
void setCloseStippled(bool c);
|
void setCloseStippled(bool c);
|
||||||
void addNode(const QPoint& p);
|
void addNode(const QPoint& p);
|
||||||
|
void popNode();
|
||||||
void clear();
|
void clear();
|
||||||
void paintGL();
|
void paintGL();
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,6 @@ using namespace Gui;
|
||||||
AbstractMouseSelection::AbstractMouseSelection() : _pcView3D(0)
|
AbstractMouseSelection::AbstractMouseSelection() : _pcView3D(0)
|
||||||
{
|
{
|
||||||
m_bInner = true;
|
m_bInner = true;
|
||||||
mustRedraw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractMouseSelection::grabMouseModel(Gui::View3DInventorViewer* viewer)
|
void AbstractMouseSelection::grabMouseModel(Gui::View3DInventorViewer* viewer)
|
||||||
|
@ -73,10 +72,7 @@ void AbstractMouseSelection::releaseMouseModel()
|
||||||
|
|
||||||
void AbstractMouseSelection::redraw()
|
void AbstractMouseSelection::redraw()
|
||||||
{
|
{
|
||||||
// Note: For any reason it does not work to do a redraw in the actualRedraw() method of the
|
// obsolete
|
||||||
// viewer class. So, we do the redraw when the user continues moving the cursor. E.g. have
|
|
||||||
// a look to PolyPickerSelection::draw()
|
|
||||||
mustRedraw = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractMouseSelection::handleEvent(const SoEvent* const ev, const SbViewportRegion& vp)
|
int AbstractMouseSelection::handleEvent(const SoEvent* const ev, const SbViewportRegion& vp)
|
||||||
|
@ -272,6 +268,8 @@ void PolyPickerSelection::initialize()
|
||||||
_pcView3D->addGraphicsItem(&polyline);
|
_pcView3D->addGraphicsItem(&polyline);
|
||||||
_pcView3D->setRenderType(View3DInventorViewer::Image);
|
_pcView3D->setRenderType(View3DInventorViewer::Image);
|
||||||
_pcView3D->redraw();
|
_pcView3D->redraw();
|
||||||
|
|
||||||
|
lastConfirmed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyPickerSelection::terminate()
|
void PolyPickerSelection::terminate()
|
||||||
|
@ -325,7 +323,7 @@ int PolyPickerSelection::mouseButtonEvent(const SoMouseButtonEvent* const e, con
|
||||||
polyline.clear();
|
polyline.clear();
|
||||||
};
|
};
|
||||||
polyline.addNode(pos);
|
polyline.addNode(pos);
|
||||||
polyline.setCoords(pos.x(), pos.y());
|
lastConfirmed = true;
|
||||||
m_iXnew = pos.x(); m_iYnew = pos.y();
|
m_iXnew = pos.x(); m_iYnew = pos.y();
|
||||||
m_iXold = pos.x(); m_iYold = 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);
|
QCursor::setPos(newPos);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
polyline.setCoords(clPoint.x(), clPoint.y());
|
|
||||||
|
if (!lastConfirmed)
|
||||||
|
polyline.popNode();
|
||||||
|
polyline.addNode(clPoint);
|
||||||
|
lastConfirmed = false;
|
||||||
|
|
||||||
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw();
|
|
||||||
m_iXnew = clPoint.x();
|
m_iXnew = clPoint.x();
|
||||||
m_iYnew = clPoint.y();
|
m_iYnew = clPoint.y();
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,6 @@ protected:
|
||||||
int m_iXold, m_iYold;
|
int m_iXold, m_iYold;
|
||||||
int m_iXnew, m_iYnew;
|
int m_iXnew, m_iYnew;
|
||||||
SbBool m_bInner;
|
SbBool m_bInner;
|
||||||
SbBool mustRedraw;
|
|
||||||
std::vector<SbVec2s> _clPoly;
|
std::vector<SbVec2s> _clPoly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,6 +144,7 @@ protected:
|
||||||
virtual int popupMenu();
|
virtual int popupMenu();
|
||||||
|
|
||||||
Gui::Polyline polyline;
|
Gui::Polyline polyline;
|
||||||
|
bool lastConfirmed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -58,9 +58,11 @@
|
||||||
#include <Gui/Document.h>
|
#include <Gui/Document.h>
|
||||||
#include <Gui/FileDialog.h>
|
#include <Gui/FileDialog.h>
|
||||||
#include <Gui/Selection.h>
|
#include <Gui/Selection.h>
|
||||||
|
#include <Gui/MouseSelection.h>
|
||||||
#include <Gui/ViewProvider.h>
|
#include <Gui/ViewProvider.h>
|
||||||
#include <Gui/View3DInventor.h>
|
#include <Gui/View3DInventor.h>
|
||||||
#include <Gui/View3DInventorViewer.h>
|
#include <Gui/View3DInventorViewer.h>
|
||||||
|
#include <Gui/NavigationStyle.h>
|
||||||
#include <Gui/WaitCursor.h>
|
#include <Gui/WaitCursor.h>
|
||||||
#include <CXX/Objects.hxx>
|
#include <CXX/Objects.hxx>
|
||||||
|
|
||||||
|
@ -835,7 +837,11 @@ void CmdMeshPolyCut::activated(int iMsg)
|
||||||
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||||
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
|
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
|
||||||
viewer->setEditing(true);
|
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);
|
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::clipMeshCallback);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -425,7 +425,7 @@ void ViewProviderPoints::clipPointsCallback(void * ud, SoEventCallback * n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view->getSoRenderManager()->render();
|
view->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewProviderPoints::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
void ViewProviderPoints::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user