~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Mesh/Gui/ViewProviderCurvature.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2010-01-11 08:48:33 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100111084833-4g9vgdqbkw8u34zb
Tags: 0.9.2646.5-1
* New upstream version (closes: #561696).
* Added swig to Build-Depends (closes: #563523, #563772).
* Removed python-opencv from Build-Depends and Recommends (closes: #560768).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de>              *
 
2
 *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
3
 *                                                                         *
4
4
 *   This file is part of the FreeCAD CAx development system.              *
5
5
 *                                                                         *
150
150
    pcColorBar->setRange( fMin, fMax, 3 );
151
151
}
152
152
 
153
 
void ViewProviderMeshCurvature::slotCreatedObject(App::DocumentObject& Obj)
154
 
{
155
 
}
156
 
 
157
 
void ViewProviderMeshCurvature::slotDeletedObject(App::DocumentObject& Obj)
158
 
{
159
 
}
160
 
 
161
 
void ViewProviderMeshCurvature::slotChangedObject(App::DocumentObject& Obj, App::Property& Prop)
 
153
void ViewProviderMeshCurvature::slotCreatedObject(const App::DocumentObject& Obj)
 
154
{
 
155
}
 
156
 
 
157
void ViewProviderMeshCurvature::slotDeletedObject(const App::DocumentObject& Obj)
 
158
{
 
159
}
 
160
 
 
161
void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
162
162
{
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
174
174
    }
175
175
}
176
176
 
177
 
void ViewProviderMeshCurvature::slotCreatedDocument(App::Document& Doc)
 
177
void ViewProviderMeshCurvature::slotCreatedDocument(const App::Document& Doc)
178
178
{
179
179
}
180
180
 
181
 
void ViewProviderMeshCurvature::slotDeletedDocument(App::Document& Doc)
 
181
void ViewProviderMeshCurvature::slotDeletedDocument(const App::Document& Doc)
182
182
{
183
183
}
184
184
 
222
222
        pcColorBar->Detach(this);
223
223
        pcColorBar->unref();
224
224
        pcColorBar = pcBar;
225
 
    }
 
225
    }
226
226
}
227
227
 
228
228
void ViewProviderMeshCurvature::updateData(const App::Property* prop)
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());
238
 
 
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());
244
 
        }
 
238
 
 
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());
 
244
        }
245
245
    }
246
246
    else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) {
247
247
        const Mesh::PropertyCurvatureList* curv = static_cast<const Mesh::PropertyCurvatureList*>(prop);
250
250
        init(curv); // init color bar
251
251
#endif
252
252
        setActiveMode();
253
 
    }
 
253
    }
254
254
}
255
255
 
256
256
SoSeparator* ViewProviderMeshCurvature::getFrontRoot(void) const
372
372
void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback * n)
373
373
{
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());
377
 
 
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) {
381
 
            n->setHandled();
382
 
            view->setEditing(false);
383
 
            view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
384
 
            view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), curvatureInfoCallback);
385
 
        }
386
 
        else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
387
 
            const SoPickedPoint * point = n->getPickedPoint();
388
 
            if (point == NULL) {
389
 
                Base::Console().Message("No facet picked.\n");
390
 
                return;
391
 
            }
392
 
 
393
 
            n->setHandled();
394
 
 
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()))
399
 
                return;
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());
 
377
 
 
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) {
 
381
            n->setHandled();
 
382
            view->setEditing(false);
 
383
            view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
 
384
            view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), curvatureInfoCallback);
 
385
        }
 
386
        else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
 
387
            const SoPickedPoint * point = n->getPickedPoint();
 
388
            if (point == NULL) {
 
389
                Base::Console().Message("No facet picked.\n");
 
390
                return;
 
391
            }
 
392
 
 
393
            n->setHandled();
 
394
 
 
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()))
 
399
                return;
 
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);
410
 
            }
411
 
        }
 
410
            }
 
411
        }
412
412
    }
413
413
}
414
414