Workin on my mouseMoves…

For some reason I had a Bob Seger sound bouncing around in my head when I wrote that title.
Anyway…   Things are not going  flawlessly at the first attempt.. Go figure
I need to look at the unaltered code to see if I messed something in the copy and paste.
http://free-cad.git.sourceforge.net/git/gitweb.cgi?p=free-cad/free-cad;a=blob;f=src/Mod/Sketcher/Gui/CommandCreateGeo.cpp;h=89685e99abed69ba4611dd763f40c4695f2c26bc;hb=HEAD

It seems like I got keyArcPressed() working ok as intended,

Just to get going on this, I copied sections of  from DrawSketchHandlerArc::mouseMove into the conditional testing keyArcPressed().   This shouldn’t work but at least it a place to get started.
Within DrawSketchHandlerLineSet

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){
  if (keyArcPressed()){//Draw an Arc
                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{//Draw a line
EditCurve[1] = onSketchPos;
sketchgui->drawEdit(EditCurve);
if (seekAutoConstraint(sugConstr2, onSketchPos, onSketchPos – EditCurve[0])) {
renderSuggestConstraintsCursor(sugConstr2);
return;
}

}

}
applyCursor();
}

———————

It seems this will cause a segmentation fault:

The inferior stopped because it received a signal from the Operating System.

Signal name : SIGSEGV
Signal meaning : Segmentation fault

———————-

0    QHashData::nextNode(QHashData::Node*)    /usr/lib/libQtCore.so.4    0    0x7ffff1507673
1    QApplication::allWidgets()    /usr/lib/libQtGui.so.4    0    0x7ffff269bfcc
2    QApplication::setOverrideCursor(QCursor const&)    /usr/lib/libQtGui.so.4    0    0x7ffff2713d17
3    Gui::WaitCursorP::setBusy    WaitCursor.cpp    80    0x7ffff756d1ec
4    Gui::WaitCursor::setWaitCursor    WaitCursor.cpp    161    0x7ffff756d580
5    WaitCursor    WaitCursor.cpp    146    0x7ffff756d4dc
6    Gui::Command::updateActive    Command.cpp    455    0x7ffff757968b
7    DrawSketchHandlerLineSet::releaseButton    CommandCreateGeo.cpp    628    0x7fffd5f1d036
8    SketcherGui::ViewProviderSketch::mouseButtonPressed    ViewProviderSketch.cpp    589    0x7fffd5f47a94
9    Gui::ViewProvider::eventCallback    ViewProvider.cpp    195    0x7ffff779a1f6
10    SoEventCallback::handleEvent(SoHandleEventAction*)    /usr/lib/libCoin.so.60    0    0x7ffff51c3e0b
11    SoNode::handleEventS(SoAction*, SoNode*)    /usr/lib/libCoin.so.60    0    0x7ffff51dcda7
12    SoAction::traverse(SoNode*)    /usr/lib/libCoin.so.60    0    0x7ffff4fa44f7
13    SoChildList::traverse(SoAction*, int, int)    /usr/lib/libCoin.so.60    0    0x7ffff50f8ded
14    SoGroup::doAction(SoAction*)    /usr/lib/libCoin.so.60    0    0x7ffff51cffbb
15    SoSeparator::doAction(SoAction*)    /usr/lib/libCoin.so.60    0    0x7ffff51f393f
16    Gui::SoFCUnifiedSelection::handleEvent    SoFCUnifiedSelection.cpp    322    0x7ffff76f1ef9
17    SoNode::handleEventS(SoAction*, SoNode*)    /usr/lib/libCoin.so.60    0    0x7ffff51dcda7
18    SoAction::traverse(SoNode*)    /usr/lib/libCoin.so.60    0    0x7ffff4fa44f7
19    SoChildList::traverse(SoAction*, int, int)    /usr/lib/libCoin.so.60    0    0x7ffff50f8ded
20    SoGroup::doAction(SoAction*)    /usr/lib/libCoin.so.60    0    0x7ffff51cffbb
…    <More>

Running out of time here before I need to go to work, but I need to thing about what I need to do for my next steps..

The next goal is figure out what kind of program logic I need to  to get some kind of arc going in polyline.

Done is define as not getting seg faults getting an arc to draw in polyline….(Not shooting for tangency at this point)

  • Dissect the logic of DrawSketchHandlerArc::mouseMove to understand what’s going on.
  • Dissect the logic of DrawSketchHandlerArc::mouseDown to understand what’s going on.
  • Dissect  the logic(with keyArcPressed= false)  of DrawSketchHandlerLineSet::mouseMove to understand what’s going on
  • Dissect the logic(with keyArcPressed= false) of DrawSketchHandlerLineSet::mouseDown to understand what’s going on.
  • Figure out the next programming step…

 

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *