I’ve been poking around DrawSketchHandlerArc (Check around line 700 here) just trying to see how this thing ticks.
These notes probably won’t make sense to anyone but me, and probably if I go back to read them later, they won’t make sense to me either.
DrawSketchHandlerArc has a enumeration mode which consists of the following values:
enum SelectMode {
STATUS_SEEK_First, /**< enum value —-. */
STATUS_SEEK_Second, /**< enum value —-. */
STATUS_SEEK_Third, /**< enum value —-. */
STATUS_End
};
If you take a look at DrawSketchHandlerLineSet it has a similar enumeration that looks like:
enum SelectMode {
STATUS_SEEK_First, /**< enum value —-. */
STATUS_SEEK_Second, /**< enum value —-. */
STATUS_Do,
STATUS_Close
};
My oh my… there are some darn interesting things going here:
I drew a couple of lines in polylines got out of that mode and went into draw arc…
in DrawSketchHandlerArc
virtual void mouseMove(Base::Vector2D onSketchPos)
{
setPositionText(onSketchPos);
if (Mode==STATUS_SEEK_First) {
if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2D(0.f,0.f))) {
renderSuggestConstraintsCursor(sugConstr1);
return;
}
}
else if (Mode==STATUS_SEEK_Second) {
float dx_ = onSketchPos.fX – EditCurve[0].fX;
float dy_ = onSketchPos.fY – EditCurve[0].fY;
for (int i=0; i < 16; i++) {
float angle = i*M_PI/16.0;
float dx = dx_ * cos(angle) + dy_ * sin(angle);
float dy = -dx_ * sin(angle) + dy_ * cos(angle);
EditCurve[1+i] = Base::Vector2D(EditCurve[0].fX + dx, EditCurve[0].fY + dy);
EditCurve[17+i] = Base::Vector2D(EditCurve[0].fX – dx, EditCurve[0].fY – dy);
}
EditCurve[33] = EditCurve[1];
sketchgui->drawEdit(EditCurve);
if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2D(0.f,0.f))) {
renderSuggestConstraintsCursor(sugConstr2);
return;
}
}
else if (Mode==STATUS_SEEK_Third) {
float angle1 = atan2(onSketchPos.fY – CenterPoint.fY,
onSketchPos.fX – CenterPoint.fX) – startAngle;
float angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ;
arcAngle = abs(angle1-arcAngle) < abs(angle2-arcAngle) ? angle1 : angle2;
for (int i=1; i <= 29; i++) {
float angle = i*arcAngle/29.0;
float dx = rx * cos(angle) – ry * sin(angle);
float dy = rx * sin(angle) + ry * cos(angle);
EditCurve[i] = Base::Vector2D(CenterPoint.fX + dx, CenterPoint.fY + dy);
}
sketchgui->drawEdit(EditCurve);
if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2D(0.f,0.f))) {
renderSuggestConstraintsCursor(sugConstr3);
return;
}
}
applyCursor();
}
There are a bunch of interesting functions at play: (I was going to screen shoot this and post pretty pictures, put for some strange reason, screen shots are not picking up the red arc or constraint (which is a bit of a bummer). The strange thing is that this is occurring if I just printscreen the form or the whole screen…
If the cursor is set over an element, it’s highlighted… (I think this is probably happening further up stream.)
Just to test that out //’d out everything I bolded above. I’m thinking the when I’m in arc mode, I should only see elements with focus light up… And the result is…
Ok.. This is interesting, //setPositionText(onSketchPos); stop the display of the coordinates… no surprise there.
//renderSuggestConstraintsCursor(sugConstr1); Blocked displaying the constraint symbols (either constraint or tangency but the cursors was replaced with the Arc… Ok… what I just noticed is that when I did a screen shot, the regular mouse cursor copied not the little arc…
It does appear that the objects with focus is indeed happening further upstream.. One more test to be sure is to put an immediate return on the mousemove after uncommenting everything. Yep… object focus happening further up stream, but that’s no surprise.
Ok… Stepping between the mouse move and the button events is making sense to me up this point. The next point of study is this
void ViewProviderSketch::drawEdit(const std::vector<Base::Vector2D> &EditCurve) and in particular I need to research SbVec3f
Off to the job….