Small bug fix in undo / redo mechanism of 3d sketcher

This commit is contained in:
rnc 2012-11-19 17:58:33 +00:00
parent 648960ae0b
commit d1371cd825
2 changed files with 26 additions and 4 deletions

View File

@ -530,6 +530,7 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
myRedoList.clear(); myRedoList.clear();
myLengthIORedoList.Clear(); myLengthIORedoList.Clear();
myAngleIORedoList.Clear(); myAngleIORedoList.Clear();
myTextIORedoList.Clear();
if (myCoordType == 0 && myMode == 1) // RELATIVE CARTESIAN COORDINATES if (myCoordType == 0 && myMode == 1) // RELATIVE CARTESIAN COORDINATES
{ {
@ -622,6 +623,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo()
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myTextPrs, true);
removeLastIOFromPrs(); removeLastIOFromPrs();
@ -630,6 +632,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo()
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs);
if (isAngleVisible) if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myTextPrs);
// Remove last point from list // Remove last point from list
myPointsList.removeLast(); myPointsList.removeLast();
@ -657,6 +660,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo()
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myTextPrs, true);
restoreLastIOToPrs(); restoreLastIOToPrs();
@ -665,6 +669,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo()
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs);
if (isAngleVisible) if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myTextPrs);
// Remove last point from redo list // Remove last point from redo list
myRedoList.removeLast(); myRedoList.removeLast();
@ -699,6 +704,12 @@ void EntityGUI_3DSketcherDlg::removeLastIOFromPrs ()
myAngleIORedoList.Prepend(anIOList.First()); // Store last prepended Angle IO in redo list myAngleIORedoList.Prepend(anIOList.First()); // Store last prepended Angle IO in redo list
myAnglePrs->RemoveFirst(); // Remove it from myAnglePrs myAnglePrs->RemoveFirst(); // Remove it from myAnglePrs
} }
for (int t = 0; t<Last.T; t++)
{
myTextPrs->GetObjects(anIOList);
myTextIORedoList.Prepend(anIOList.First()); // Store last prepended Text IO in redo list
myTextPrs->RemoveFirst(); // Remove it from myTextPrs
}
} }
//================================================================================= //=================================================================================
@ -719,6 +730,11 @@ void EntityGUI_3DSketcherDlg::restoreLastIOToPrs ()
myAnglePrs->PrependObject(myAngleIORedoList.First()); // Restore last removed IO myAnglePrs->PrependObject(myAngleIORedoList.First()); // Restore last removed IO
myAngleIORedoList.RemoveFirst(); // Remove it from redo list myAngleIORedoList.RemoveFirst(); // Remove it from redo list
} }
for (int t = 0; t<LastDeleted.T; t++)
{
myTextPrs->PrependObject(myTextIORedoList.First()); // Restore last removed IO
myTextIORedoList.RemoveFirst(); // Remove it from redo list
}
} }
//================================================================================= //=================================================================================
@ -1209,6 +1225,7 @@ EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const
// Update point presentation type // Update point presentation type
xyz.A = myPrsType.A; // Number of angle diomensions xyz.A = myPrsType.A; // Number of angle diomensions
xyz.L = myPrsType.L; // Number of length dimensions xyz.L = myPrsType.L; // Number of length dimensions
xyz.T = myPrsType.T; // Number of text objects
return xyz; return xyz;
} }
@ -1463,7 +1480,7 @@ void EntityGUI_3DSketcherDlg::displayDimensions (bool store)
displayAngle(anAngle1, P0, P1, P2, store); displayAngle(anAngle1, P0, P1, P2, store);
else else
{ {
std::string anAngleText = doubleToString(anAngle1) + "deg"; std::string anAngleText = doubleToString(anAngle1) + " deg.";
displayText(anAngleText, Current_Pnt, store); displayText(anAngleText, Current_Pnt, store);
} }
@ -1607,6 +1624,9 @@ void EntityGUI_3DSketcherDlg::displayText ( std::string theText,
// Display modified presentation // Display modified presentation
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myTextPrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myTextPrs);
// Update dimension presentation text count for later undo / redo
myPrsType.T += 1;
} }
else else
{ {

View File

@ -58,18 +58,19 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
struct XYZ struct XYZ
{ {
XYZ() { x = y = z = 0.0; command = params = ""; L=A=0; } XYZ() { x = y = z = 0.0; command = params = ""; L=A=T=0; }
double x, y, z; // for preview only double x, y, z; // for preview only
int L, A; // for preview only int L, A, T; // for preview only
QString command; QString command;
QString params; QString params;
}; };
struct prsType struct prsType
{ {
prsType(){L=A=0;} prsType(){L=A=T=0;}
int L; int L;
int A; int A;
int T;
}; };
typedef QList<XYZ> XYZList; typedef QList<XYZ> XYZList;
@ -154,6 +155,7 @@ private:
XYZList myRedoList; XYZList myRedoList;
AIS_ListOfInteractive myLengthIORedoList; AIS_ListOfInteractive myLengthIORedoList;
AIS_ListOfInteractive myAngleIORedoList; AIS_ListOfInteractive myAngleIORedoList;
AIS_ListOfInteractive myTextIORedoList;
prsType myPrsType; prsType myPrsType;
EntityGUI_3Spin* Group3Spin; EntityGUI_3Spin* Group3Spin;