150
150
pcColorBar->setRange( fMin, fMax, 3 );
153
void ViewProviderMeshCurvature::slotCreatedObject(App::DocumentObject& Obj)
157
void ViewProviderMeshCurvature::slotDeletedObject(App::DocumentObject& Obj)
161
void ViewProviderMeshCurvature::slotChangedObject(App::DocumentObject& Obj, App::Property& Prop)
153
void ViewProviderMeshCurvature::slotCreatedObject(const App::DocumentObject& Obj)
157
void ViewProviderMeshCurvature::slotDeletedObject(const App::DocumentObject& Obj)
161
void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
163
163
// we get this for any object for that a property has changed. Thus, we must regard that object
164
164
// which is linked by our link property
235
235
const Mesh::MeshObject& kernel = object->Mesh.getValue();
236
236
pcColorMat->diffuseColor.setNum((int)kernel.countPoints());
237
237
pcColorMat->transparency.setNum((int)kernel.countPoints());
239
// get the view provider of the associated mesh feature
240
App::Document* rDoc = pcObject->getDocument();
241
Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc);
242
Gui::ViewProviderGeometryObject* view = static_cast<Gui::ViewProviderGeometryObject*>(pDoc->getViewProvider(object));
243
this->pcLinkRoot->addChild(view->getHighlightNode());
239
// get the view provider of the associated mesh feature
240
App::Document* rDoc = pcObject->getDocument();
241
Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc);
242
Gui::ViewProviderGeometryObject* view = static_cast<Gui::ViewProviderGeometryObject*>(pDoc->getViewProvider(object));
243
this->pcLinkRoot->addChild(view->getHighlightNode());
246
246
else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) {
247
247
const Mesh::PropertyCurvatureList* curv = static_cast<const Mesh::PropertyCurvatureList*>(prop);
372
372
void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback * n)
374
374
if (n->getEvent()->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
375
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(n->getEvent());
376
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
378
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
379
n->getAction()->setHandled();
380
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
382
view->setEditing(false);
383
view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
384
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), curvatureInfoCallback);
386
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
387
const SoPickedPoint * point = n->getPickedPoint();
389
Base::Console().Message("No facet picked.\n");
395
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
396
// really from the mesh we render and not from any other geometry
397
Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
398
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId()))
400
ViewProviderMeshCurvature* that = static_cast<ViewProviderMeshCurvature*>(vp);
401
const SoDetail* detail = point->getDetail(point->getPath()->getTail());
402
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
403
// safe downward cast, know the type
404
SoFaceDetail * facedetail = (SoFaceDetail *)detail;
375
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(n->getEvent());
376
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
378
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
379
n->getAction()->setHandled();
380
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
382
view->setEditing(false);
383
view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
384
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), curvatureInfoCallback);
386
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
387
const SoPickedPoint * point = n->getPickedPoint();
389
Base::Console().Message("No facet picked.\n");
395
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
396
// really from the mesh we render and not from any other geometry
397
Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
398
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId()))
400
ViewProviderMeshCurvature* that = static_cast<ViewProviderMeshCurvature*>(vp);
401
const SoDetail* detail = point->getDetail(point->getPath()->getTail());
402
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
403
// safe downward cast, know the type
404
SoFaceDetail * facedetail = (SoFaceDetail *)detail;
405
405
// get the curvature info of the three points of the picked facet
406
406
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
407
407
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
408
408
int index3 = facedetail->getPoint(2)->getCoordinateIndex();
409
409
that->curvatureInfo(index1, index2, index3);