I’m been poking around the code, and things have been more or less making sense to me until I ran into this draw edit thing…
void ViewProviderSketch::drawEdit(const std::vector<Base::Vector2D> &EditCurve)
{
assert(edit);edit->EditCurveSet->numVertices.setNum(1);
edit->EditCurvesCoordinate->point.setNum(EditCurve.size());
SbVec3f *verts = edit->EditCurvesCoordinate->point.startEditing();
int32_t *index = edit->EditCurveSet->numVertices.startEditing();int i=0; // setting up the line set
for (std::vector<Base::Vector2D>::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++)
verts[i].setValue(it->fX,it->fY,zEdit);index[0] = EditCurve.size();
edit->EditCurvesCoordinate->point.finishEditing();
edit->EditCurveSet->numVertices.finishEditing();
}I’m note really sure what’s going on here. So I’m going to attempt to figure this one out here…
Ok…It seems like the first thing I should look at is edit and see what’s up with that….
Sooo.. edit is a pointer to a Structure EditData declared in class ViewProviderSketch
struct EditData {
EditData():
sketchHandler(0),
DragPoint(-1),
DragCurve(-1),
DragConstraint(-1),
PreselectPoint(-1),
PreselectCurve(-1),
PreselectCross(-1),
PreselectConstraint(-1),
blockedPreselection(false),
FullyConstrained(false),
//ActSketch(0),
EditRoot(0),
PointsMaterials(0),
CurvesMaterials(0),
PointsCoordinate(0),
CurvesCoordinate(0),
CurveSet(0),
PointSet(0)
{}// pointer to the active handler for new sketch objects
DrawSketchHandler *sketchHandler;// dragged point
int DragPoint;
// dragged curve
int DragCurve;
// dragged constraint
int DragConstraint;SbColor PreselectOldColor;
int PreselectPoint;
int PreselectCurve;
int PreselectCross;
int PreselectConstraint;
bool blockedPreselection;
bool FullyConstrained;// pointer to the Solver
Sketcher::Sketch ActSketch;
// container to track our own selected parts
std::set<int> SelPointSet;
std::set<int> SelCurvSet; // also holds cross axes at -1 and -2
std::set<int> SelConstraintSet;// helper data structure for the constraint rendering
std::vector<ConstraintType> vConstrType;// nodes for the visuals
SoSeparator *EditRoot;
SoMaterial *PointsMaterials;
SoMaterial *CurvesMaterials;
SoMaterial *RootCrossMaterials;
SoMaterial *EditCurvesMaterials;
SoCoordinate3 *PointsCoordinate;
SoCoordinate3 *CurvesCoordinate;
SoCoordinate3 *RootCrossCoordinate;
SoCoordinate3 *EditCurvesCoordinate;
SoLineSet *CurveSet;
SoLineSet *EditCurveSet;
SoLineSet *RootCrossSet;
SoMarkerSet *PointSet;SoText2 *textX;
SoTranslation *textPos;SoGroup *constrGroup;
};EditData *edit;
The structure look like this:
/// Data structure while edit the sketch
struct EditData {
EditData():
sketchHandler(0),
DragPoint(-1),
DragCurve(-1),
DragConstraint(-1),
PreselectPoint(-1),
PreselectCurve(-1),
PreselectCross(-1),
PreselectConstraint(-1),
blockedPreselection(false),
FullyConstrained(false),
//ActSketch(0),
EditRoot(0),
PointsMaterials(0),
CurvesMaterials(0),
PointsCoordinate(0),
CurvesCoordinate(0),
CurveSet(0),
PointSet(0)
{}// pointer to the active handler for new sketch objects
DrawSketchHandler *sketchHandler;// dragged point
int DragPoint;
// dragged curve
int DragCurve;
// dragged constraint
int DragConstraint;SbColor PreselectOldColor;
int PreselectPoint;
int PreselectCurve;
int PreselectCross;
int PreselectConstraint;
bool blockedPreselection;
bool FullyConstrained;// pointer to the Solver
Sketcher::Sketch ActSketch;
// container to track our own selected parts
std::set<int> SelPointSet;
std::set<int> SelCurvSet; // also holds cross axes at -1 and -2
std::set<int> SelConstraintSet;// helper data structure for the constraint rendering
std::vector<ConstraintType> vConstrType;// nodes for the visuals
SoSeparator *EditRoot;
SoMaterial *PointsMaterials;
SoMaterial *CurvesMaterials;
SoMaterial *RootCrossMaterials;
SoMaterial *EditCurvesMaterials;
SoCoordinate3 *PointsCoordinate;
SoCoordinate3 *CurvesCoordinate;
SoCoordinate3 *RootCrossCoordinate;
SoCoordinate3 *EditCurvesCoordinate;
SoLineSet *CurveSet;
SoLineSet *EditCurveSet;
SoLineSet *RootCrossSet;
SoMarkerSet *PointSet;SoText2 *textX;
SoTranslation *textPos;SoGroup *constrGroup;
};
Sooo.. the pointer edit is set to null in the ViewProviderSketch constructor.
edit has the address of a new object of type EditData that is created and assigned in bool ViewProviderSketch::setEdit(int ModNum).
It seems that this object is destroyed in void ViewProviderSketch::unsetEdit(int ModNum)
void ViewProviderSketch::unsetEdit(int ModNum)
{
ShowGrid.setValue(false);
TightGrid.setValue(true);edit->EditRoot->removeAllChildren();
pcRoot->removeChild(edit->EditRoot);if (edit->sketchHandler)
purgeHandler();delete edit;
edit = 0;this->show();
// and update the sketch
getSketchObject()->getDocument()->recompute();// clear the selection and set the new/edited sketch(convenience)
Gui::Selection().clearSelection();
std::string ObjName = getSketchObject()->getNameInDocument();
std::string DocName = getSketchObject()->getDocument()->getName();
Gui::Selection().addSelection(DocName.c_str(),ObjName.c_str());// when pressing ESC make sure to close the dialog
Gui::Control().closeDialog();
}
Ok… I set a break point on setEdit and it seemed to break when a sketch is created
0 SketcherGui::ViewProviderSketch::setEdit ViewProviderSketch.cpp 2683 0x7fffd672852d
1 Gui::ViewProvider::startEditing ViewProvider.cpp 94 0x7ffff7799ca5
2 Gui::View3DInventorViewer::setEditingViewProvider View3DInventorViewer.cpp 363 0x7ffff7776c5d
3 Gui::Document::setEdit Document.cpp 188 0x7ffff75388cf
4 Gui::DocumentPy::setEdit DocumentPyImp.cpp 108 0x7ffff75564cf
5 Gui::DocumentPy::staticCallback_setEdit DocumentPy.cpp 399 0x7ffff75534cf
6 PyEval_EvalFrameEx /usr/lib/libpython2.6.so.1.0 0 0x7ffff651a030
7 PyEval_EvalCodeEx /usr/lib/libpython2.6.so.1.0 0 0x7ffff651bd60
8 PyEval_EvalCode /usr/lib/libpython2.6.so.1.0 0 0x7ffff651be32
9 PyRun_StringFlags /usr/lib/libpython2.6.so.1.0 0 0x7ffff6539d1c
10 Base::InterpreterSingleton::runString Interpreter.cpp 117 0x7ffff69ed333
11 Gui::Command::doCommand Command.cpp 413 0x7ffff75794bb
12 CmdSketcherNewSketch::activated Command.cpp 156 0x7fffd66e2990
13 Gui::Command::invoke Command.cpp 282 0x7ffff7578d6f
14 Gui::Action::onActivated Action.cpp 82 0x7ffff756e4fb
15 Gui::Action::qt_metacall moc_Action.cpp 73 0x7ffff7574d04
16 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) /usr/lib/libQtCore.so.4 0 0x7ffff15f2e3f
17 QAction::triggered(bool) /usr/lib/libQtGui.so.4 0 0x7ffff2696032
18 QAction::activate(QAction::ActionEvent) /usr/lib/libQtGui.so.4 0 0x7ffff26980ab
19 ?? /usr/lib/libQtGui.so.4 0 0x7ffff2ad739d
20 ?? /usr/lib/libQtGui.so.4 0 0x7ffff2adcdda
21 QWidget::event(QEvent*) /usr/lib/libQtGui.so.4 0 0x7ffff26f2582
22 QMenu::event(QEvent*) /usr/lib/libQtGui.so.4 0 0x7ffff2adef9b
23 QApplicationPrivate::notify_helper(QObject*, QEvent*) /usr/lib/libQtGui.so.4 0 0x7ffff269c22c
24 QApplication::notify(QObject*, QEvent*) /usr/lib/libQtGui.so.4 0 0x7ffff26a2ecb
25 Gui::GUIApplication::notify Application.cpp 1465 0x7ffff751a1c1
26 QCoreApplication::notifyInternal(QObject*, QEvent*) /usr/lib/libQtCore.so.4 0 0x7ffff15e006c
27 QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) /usr/lib/libQtGui.so.4 0 0x7ffff26a20ae
28 ?? /usr/lib/libQtGui.so.4 0 0x7ffff27223dd
29 QApplication::x11ProcessEvent(_XEvent*) /usr/lib/libQtGui.so.4 0 0x7ffff27208ac
30 ?? /usr/lib/libQtGui.so.4 0 0x7ffff274c882
31 g_main_context_dispatch /lib/libglib-2.0.so.0 0 0x7fffeb89e8c2
32 ?? /lib/libglib-2.0.so.0 0 0x7fffeb8a2748
33 g_main_context_iteration /lib/libglib-2.0.so.0 0 0x7fffeb8a28fc
34 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) /usr/lib/libQtCore.so.4 0 0x7ffff1609513
35 ?? /usr/lib/libQtGui.so.4 0 0x7ffff274c46e
36 QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) /usr/lib/libQtCore.so.4 0 0x7ffff15de992
37 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) /usr/lib/libQtCore.so.4 0 0x7ffff15ded6c
38 QCoreApplication::exec() /usr/lib/libQtCore.so.4 0 0x7ffff15e2aab
39 Gui::Application::runApplication Application.cpp 1689 0x7ffff7516557
40 main MainGui.cpp 361 0x4096e7void ViewProviderSketch::drawEdit(const std::vector<Base::Vector2D> &EditCurve)
{
assert(edit);edit->EditCurveSet->numVertices.setNum(1);
edit->EditCurvesCoordinate->point.setNum(EditCurve.size());
SbVec3f *verts = edit->EditCurvesCoordinate->point.startEditing();
int32_t *index = edit->EditCurveSet->numVertices.startEditing();int i=0; // setting up the line set
for (std::vector<Base::Vector2D>::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++)
verts[i].setValue(it->fX,it->fY,zEdit);index[0] = EditCurve.size();
edit->EditCurvesCoordinate->point.finishEditing();
edit->EditCurveSet->numVertices.finishEditing();
}
Ok EditCurveSet is of type SoLineSet
http://doc.coin3d.org/Coin/classSoLineSet.html#_details
SoCoordinate3 *EditCurvesCoordinate;
http://doc.coin3d.org/Coin/classSoCoordinate3.html#_details
Ok… My brain is starting to ache.. I guess I need to look at this coin/inventor stuff.
I found a link to a pdf tutorial that looks fairly interesting; PG-GettingStarted.pdf
http://www.ims.tuwien.ac.at/teaching/vr/tutorial/content1.html
This looks… like the place to get started:
http://www.cse.unr.edu/~b_yi/coin3d/chapter01/index.html