#include <CurveCreator_Curve.hxx>
#include <CurveCreator_Section.hxx>
+#include <CurveCreator_Listener.hxx>
#include <stdio.h>
CurveCreator_Curve::CurveCreator_Curve
(const CurveCreator::Dimension theDimension)
: myIsLocked (false),
- myDimension (theDimension)
+ myDimension (theDimension),
+ myListener(NULL)
{
}
for (; i < aNbSections; i++) {
mySections[i]->myType = theType;
}
+ if( myListener )
+ myListener->curveChanged();
} else {
- mySections.at(theISection)->myType = theType;
+ if( mySections.at(theISection)->myType != theType ){
+ mySections.at(theISection)->myType = theType;
+ if( myListener )
+ myListener->sectionTypeChanged(theISection);
+ }
}
}
aSection->myPoints.insert(aSection->myPoints.end(),
thePoints.begin(), thePoints.end());
+ if( myListener )
+ myListener->pointInserted( theISection, -1 );
}
//=======================================================================
aSection->myIsClosed = theIsClosed;
aSection->myPoints = thePoints;
mySections.push_back(aSection);
+ if( myListener )
+ myListener->sectionAdded( -1 );
}
//=======================================================================
delete *anIterRm;
mySections.erase(anIterRm);
}
+ myListener->sectionRemoved(theISection);
}
//=======================================================================
aSection->myPoints.insert(aSection->myPoints.begin() + toICoord(theIPnt),
thePoints.begin(), thePoints.end());
+ if( myListener )
+ myListener->pointInserted( theISection, theIPnt );
}
}
aSection->myPoints.end() : anIterBegin + toICoord(theNbPoints));
aSection->myPoints.erase(anIterBegin, anIterEnd);
+ myListener->pointRemoved(theISection, theIPnt, theNbPoints );
}
//=======================================================================
}
mySections.clear();
+ if( myListener )
+ myListener->curveChanged();
}
//=======================================================================
for (i = 0; i < myDimension; i++) {
aSection->myPoints.at(toICoord(theIPnt) + i) = theCoords[i];
}
+
+ if( myListener )
+ myListener->pointChanged( theISection, theIPnt );
}
}
for (i = 0; i < aSize; i++) {
mySections[i]->myIsClosed = theIsClosed;
+ if( myListener ){
+ myListener->sectionClosed( theISection, theIsClosed );
+ }
}
} else {
mySections.at(theISection)->myIsClosed = theIsClosed;
+ if( myListener ){
+ myListener->sectionClosed( theISection, theIsClosed );
+ }
}
}
CurveCreator_Section *aSection2 = mySections.at(theISectionFrom);
aSection1->myPoints.insert(aSection1->myPoints.end(),
- aSection2->myPoints.begin(), aSection2->myPoints.end());
+ aSection2->myPoints.begin(), aSection2->myPoints.end());
removeSection(theISectionFrom);
+ if( myListener )
+ myListener->curveChanged();
}
}
// Just erace section pointers as they were deleted before.
mySections.erase(mySections.begin() + 1, mySections.end());
+ if( myListener )
+ myListener->curveChanged();
}
}
}
return "";
}
+
+//=======================================================================
+// function: setListener
+// purpose: set curve changes listener
+//=======================================================================
+void CurveCreator_Curve::setListener( CurveCreator_Listener* theListener )
+{
+ myListener = theListener;
+}
+
+//=======================================================================
+// function: setListener
+// purpose: set curve changes listener
+//=======================================================================
+void CurveCreator_Curve::removeListener()
+{
+ myListener = NULL;
+}
#include <QString>
class CurveCreator_Section;
-
+class CurveCreator_Listener;
/**
* The CurveCreator_Curve object is represented as one or more sets of
* Return unic section name
*/
std::string getUnicSectionName();
+
+ /**
+ * Set curve creator listener object
+ */
+ void setListener( CurveCreator_Listener* myWatcher );
+
+ /**
+ * Remove curve creator listener object
+ */
+ void removeListener();
+
protected:
/** Set type of the specified section (or all sections
bool myIsLocked;
Sections mySections; //!< curve data
CurveCreator::Dimension myDimension; //!< curve dimension
+ CurveCreator_Listener* myListener; //!< listener
friend class CurveCreator_CurveEditor;
friend class CurveCreator_Operation;
: myNbUndos (0),
myNbRedos (0),
myPCurve (thePCurve),
- myUndoDepth (-1)
+ myUndoDepth (-1),
+ myOpLevel(0)
{
if (myPCurve != NULL) {
if (myPCurve->isLocked()) {
const int theISection)
{
if (myPCurve != NULL) {
+ startOperation();
// Set the difference.
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetType,
// Update the curve.
myPCurve->setType(theType, theISection);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::AddPoints,
thePoints, theISection);
// Update the curve.
myPCurve->addPoints(thePoints, theISection);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::AddSection,
- thePoints, theType, theIsClosed);
+ theName, thePoints, theType, theIsClosed);
}
// Update the curve.
myPCurve->addSection(theName, theType, theIsClosed, thePoints);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::RemoveSection,
theISection);
// Update the curve.
myPCurve->removeSection(theISection);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::InsertPoints,
thePoints, theISection, theIPnt);
// Update the curve.
myPCurve->insertPoints(thePoints, theISection, theIPnt);
+ finishOperation();
}
}
const int theOrigIPnt,
const int theNewIPnt )
{
+ startOperation();
myPCurve->movePoint(theISection, theOrigIPnt, theNewIPnt);
+ finishOperation();
}
//=======================================================================
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::RemovePoints,
theISection, theIPnt, theNbPoints);
// Update the curve.
myPCurve->removePoints(theISection, theIPnt, theNbPoints);
+ finishOperation();
}
}
void CurveCreator_CurveEditor::clear()
{
if (myPCurve != NULL) {
+ startOperation();
// Set the difference.
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::Clear);
// Update the curve.
myPCurve->clear();
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetCoordinates,
theCoords, theISection, theIPnt);
// Update the curve.
myPCurve->setCoordinates(theCoords, theISection, theIPnt);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetClosed,
theIsClosed, theISection);
// Update the curve.
myPCurve->setClosed(theIsClosed, theISection);
+ finishOperation();
}
}
void CurveCreator_CurveEditor::setName(const std::string& theName,
const int theISection)
{
- myPCurve->setName( theName, theISection );
+ if (myPCurve != NULL) {
+ // Set the difference.
+ startOperation();
+ if (addEmptyDiff()) {
+ myListDiffs.back().init(myPCurve, CurveCreator_Operation::RenameSection,
+ theName, theISection);
+ }
+ myPCurve->setName( theName, theISection );
+ finishOperation();
+ }
}
//=======================================================================
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::MoveSection,
theISection, theNewIndex);
// Update the curve.
myPCurve->moveSection(theISection, theNewIndex);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::Join,
theISectionTo, theISectionFrom);
// Update the curve.
myPCurve->join(theISectionTo, theISectionFrom);
+ finishOperation();
}
}
{
if (myPCurve != NULL) {
// Set the difference.
+ startOperation();
if (addEmptyDiff()) {
myListDiffs.back().init(myPCurve, CurveCreator_Operation::Join);
}
// Update the curve.
myPCurve->join();
+ finishOperation();
}
}
return isEnabled;
}
+
+void CurveCreator_CurveEditor::startOperation()
+{
+ myOpLevel++;
+}
+
+void CurveCreator_CurveEditor::finishOperation()
+{
+ myOpLevel--;
+}
//! Join all sections to the single curve
void join();
+ void startOperation();
+ void finishOperation();
private:
/** This method updates all undo/redo information required to be updated
ListDiff myListDiffs;
CurveCreator_Curve* myPCurve;
int myUndoDepth;
-
+ int myOpLevel;
};
#endif
return isOK;
}
+//=======================================================================
+// function: init
+// purpose:
+//=======================================================================
+bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
+ const CurveCreator_Operation::Type theType,
+ const std::string& theName,
+ const CurveCreator::Coordinates &theCoords,
+ const int theIntParam1,
+ const int theIntParam2)
+{
+ bool isOK = false;
+
+ if (theCurve != NULL) {
+ clear();
+
+ // Set redo.
+ myPRedo = new CurveCreator_Operation;
+
+ if (myPRedo->init(theType, theName, theCoords, theIntParam1, theIntParam2)) {
+ // Construct undo for different commands.
+ switch (theType) {
+ case CurveCreator_Operation::AddSection:
+ setNbUndos(1);
+ isOK = myPUndo[0].init(CurveCreator_Operation::RemoveSection, -1);
+ break;
+ }
+ }
+ }
+ if( !isOK )
+ clear();
+ return isOK;
+}
+
//=======================================================================
// function: init
// purpose:
if (myPRedo->init(theType, theCoords, theIntParam1, theIntParam2)) {
// Construct undo for different commands.
switch (theType) {
- case CurveCreator_Operation::AddSection:
- setNbUndos(1);
- isOK = myPUndo[0].init(CurveCreator_Operation::RemoveSection, -1);
- break;
case CurveCreator_Operation::InsertPoints:
{
const CurveCreator::Dimension aDim = theCurve->getDimension();
return isOK;
}
+bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
+ const CurveCreator_Operation::Type theType,
+ const std::string &theName,
+ const int theIntParam1 )
+{
+ bool isOK = false;
+ myPRedo = new CurveCreator_Operation;
+
+ if (myPRedo->init(theType, theName, theIntParam1 )) {
+ // Construct undo for different commands.
+ switch (theType) {
+ case CurveCreator_Operation::RenameSection:
+ setNbUndos(1);
+ isOK = myPUndo[0].init(CurveCreator_Operation::RenameSection,
+ theCurve->getSectionName(theIntParam1), theIntParam1);
+ break;
+ }
+ }
+ if( !isOK ){
+ clear();
+ }
+ return isOK;
+}
+
//=======================================================================
// function: applyUndo
// purpose:
* CurveCreator::Coordinates parameter and two integer parameters.
* It is applicable to the following operations:
* <UL>
- * <LI>AddSection</LI>
* <LI>InsertPoints</LI>
* <LI>SetCoordinates</LI>
* </UL>
const int theIntParam1,
const int theIntParam2);
+ /**
+ * This method initializes the difference with an operation with one
+ * Name, one CurveCreator::Coordinates parameter and two integer parameters.
+ * It is applicable to the following operations:
+ * <UL>
+ * <LI>AddSection</LI>
+ * </UL>
+ */
+ bool init(const CurveCreator_Curve *theCurve,
+ const CurveCreator_Operation::Type theType,
+ const std::string& theName,
+ const CurveCreator::Coordinates &theCoords,
+ const int theIntParam1,
+ const int theIntParam2);
+
+ /**
+ * This method initializes the difference with an operation with one
+ * string and one integer parameters.
+ * It is applicable to the following operations:
+ * <UL>
+ * <LI>RenameSection</LI>
+ * </UL>
+ */
+ bool init(const CurveCreator_Curve *theCurve,
+ const CurveCreator_Operation::Type theType,
+ const std::string &theName,
+ const int theIntParam1 );
+
/**
* This method applies undo operation to theCurve.
*/
--- /dev/null
+#ifndef CURVE_CREATOR_LISTENER_HXX
+#define CURVE_CREATOR_LISTENER_HXX
+
+class CurveCreator_Listener
+{
+public:
+ CurveCreator_Listener(void){};
+ virtual ~CurveCreator_Listener(void){};
+
+ virtual void pointChanged( int theSection, int thePoint ){}
+ virtual void pointRemoved( int theSection, int theFirstPoint, int thePointCnt ){}
+ virtual void pointInserted( int theSection, int theIndx ){}
+
+ virtual void sectionClosed( int theSection, bool isClosed ){}
+ virtual void sectionAdded( int theSection ){}
+ virtual void sectionRemoved( int theSection ){}
+ virtual void sectionTypeChanged( int theSection ){}
+
+ virtual void curveChanged(){}
+};
+
+#endif
\ No newline at end of file
#include <QLocale>
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
- QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false)
+ QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim)
{
QGridLayout* aCoordLay = new QGridLayout();
aCoords.push_back(anX);
double anY = myY->value();
aCoords.push_back(anY);
- if( myZ->isVisible() ){
+ if( myDim == CurveCreator::Dim3d ){
double aZ = myZ->value();
aCoords.push_back(aZ);
}
return isOK;
}
+//=======================================================================
+// function: Constructor
+// purpose:
+//=======================================================================
+bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
+ const std::string& theName,
+ const CurveCreator::Coordinates &theCoords,
+ const int theIntParam1,
+ const int theIntParam2)
+{
+ bool isOK = false;
+ if (theType == CurveCreator_Operation::AddSection ) {
+ const int aNbCoords = theCoords.size();
+ const size_t aSize =
+ 3*sizeof(theIntParam1) + aNbCoords*sizeof(CurveCreator::TypeCoord) + theName.length() + 1;
+ int *pIntData = (int *)allocate(aSize);
+
+ *pIntData++ = theIntParam1;
+ *pIntData++ = theIntParam2;
+ char* aStrPtr = (char*)pIntData;
+ if( !theName.empty() ){
+ strcpy( aStrPtr, theName.c_str() );
+ aStrPtr += theName.length();
+ }
+ else{
+ *aStrPtr = 0;
+ }
+ aStrPtr++;
+ pIntData = (int*)aStrPtr;
+ *pIntData++ = aNbCoords;
+
+ CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)aStrPtr;
+ int i = 0;
+
+ for (; i < aNbCoords; i++) {
+ *pRealData++ = theCoords[i];
+ }
+
+ myType = theType;
+ isOK = true;
+ }
+
+ return isOK;
+}
+
+bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
+ const std::string &theName,
+ const int theIntParam1 )
+{
+ if (theType == CurveCreator_Operation::RenameSection ) {
+ size_t aSize = sizeof(theIntParam1) + theName.length() + 1;
+ int *pIntData = (int *)allocate(aSize);
+ *pIntData = theIntParam1;
+ pIntData++;
+ if( !theName.empty() ){
+ strcpy( (char*)pIntData, theName.c_str() );
+ }
+ else{
+ *((char*)pIntData) = 0;
+ }
+ myType = theType;
+ return true;
+ }
+ return false;
+}
+
//=======================================================================
// function: apply
// purpose:
case CurveCreator_Operation::AddSection:
{
const CurveCreator::Type aType = (CurveCreator::Type) pInt[0];
+
+ std::string aName = std::string((char*)&pInt[2]);
+
CurveCreator::Coordinates aCoords;
- getCoords(&pInt[2], aCoords);
- theCurve->addSection(std::string(""), aType, (pInt[1] != 0), aCoords);
+ char* aPtr = ((char*)&pInt[2]);
+ aPtr += (aName.length()) + 1;
+ getCoords((int*)aPtr, aCoords);
+ theCurve->addSection(aName, aType, (pInt[1] != 0), aCoords);
}
break;
case CurveCreator_Operation::RemoveSection:
theCurve->removeSection(pInt[0]);
break;
+ case CurveCreator_Operation::RenameSection:
+ {
+ std::string aName = std::string((char*)&pInt[1]);
+ theCurve->setName(aName, pInt[0]);
+ }
+ break;
default:
break;
}
#include <CurveCreator.hxx>
+#include <string>
class CurveCreator_Curve;
Join, //!< Method CurveCreator_Curve::join
AddSection, //!< Method CurveCreator_Curve::addSection
RemoveSection, //!< Method CurveCreator_Curve::removeSection
- RenameCurve //!< Method CurveCreator_Curve::renameCurve
+ RenameSection //!< Method CurveCreator_Curve::renameSection
};
/**
bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
const int theIntParam1, const int theIntParam2);
+ /**
+ * This method initializes the object with an operation with one
+ * string, one CurveCreator::Coordinates parameter and two integer parameters.
+ * It is applicable to the following operations:
+ * <UL>
+ * <LI>AddSection</LI>
+ * <LI>InsertPoints</LI>
+ * <LI>SetCoordinates</LI>
+ * </UL>
+ * @return true in case of success; false otherwise.
+ */
+ bool init(const CurveCreator_Operation::Type theType,
+ const std::string& theName,
+ const CurveCreator::Coordinates &theCoords,
+ const int theIntParam1,
+ const int theIntParam2);
+
+
+ /**
+ * This method initializes the object with an operation with one
+ * string parameter and one integer.
+ * It is applicable to the following operations:
+ * <UL>
+ * <LI>RenameSection</LI>
+ * </UL>
+ * @return true in case of success; false otherwise.
+ */
+ bool init(const CurveCreator_Operation::Type theType,
+ const std::string &theName,
+ const int theIntParam1 );
+
/**
* This method applies the current operation to theCurve.
*/
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"),
QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
+ connect(anAct, SIGNAL(triggered()), this, SLOT(onUndo()) );
aTB->addAction(anAct);
anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"),
QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
+ connect(anAct, SIGNAL(triggered()), this, SLOT(onRedo()) );
aTB->addAction(anAct);
aTB->addSeparator();
myEdit = new CurveCreator_CurveEditor(myCurve);
}
onSelectionChanged();
+ updateUndoRedo();
}
void CurveCreator_Widget::onSelectionChanged()
}
}
}
+ emit selectionChanged();
}
void CurveCreator_Widget::onNewPoint()
myNewPointEditor->clear();
myPointNum++;
onSelectionChanged();
+ updateUndoRedo();
}
void CurveCreator_Widget::onNewSection()
myNewSectionEditor->setSectionName(aNewName);
mySection++;
onSelectionChanged();
+ updateUndoRedo();
}
QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
QString aName = myNewSectionEditor->getName();
bool isClosed = myNewSectionEditor->isClosed();
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
+ myEdit->startOperation();
myEdit->setClosed( isClosed, mySection );
myEdit->setName( aName.toStdString(), mySection );
myEdit->setType( aSectType, mySection );
+ myEdit->finishOperation();
mySectionView->sectionChanged(mySection);
+ updateUndoRedo();
}
}
aCoords = myNewPointEditor->getCoordinates();
myEdit->setCoordinates(aCoords, theSection, thePoint);
mySectionView->pointDataChanged(theSection, thePoint );
+ updateUndoRedo();
}
}
}
int aMainSect = aSections[0];
int aMainSectSize = myCurve->getNbPoints(aMainSect);
+ myEdit->startOperation();
for( int i = 1 ; i < aSections.size() ; i++ ){
int aSectNum = aSections[i] - (i-1);
myEdit->join( aMainSect, aSectNum );
mySectionView->sectionsRemoved( aSectNum );
}
+ myEdit->finishOperation();
int aNewSectSize = myCurve->getNbPoints(aMainSect);
if( aNewSectSize != aMainSectSize )
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );
+ updateUndoRedo();
}
void CurveCreator_Widget::onRemove()
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
int aCurrSect=-1;
int aRemoveCnt = 0;
+ myEdit->startOperation();
for( int i = 0 ; i < aSelPoints.size() ; i++ ){
if( aCurrSect != aSelPoints[i].first ){
aRemoveCnt = 0;
myEdit->removeSection( aSectNum );
mySectionView->sectionsRemoved( aSectNum );
}
+ myEdit->finishOperation();
mySectionView->clearSelection();
+ updateUndoRedo();
}
void CurveCreator_Widget::onMoveUp()
mySectionView->pointsSwapped( aSection, aPoint, -1 );
}
}
+ updateUndoRedo();
}
void CurveCreator_Widget::onMoveDown()
mySectionView->pointsSwapped( aSection, aPoint, 1 );
}
}
+ updateUndoRedo();
}
void CurveCreator_Widget::onClearAll()
myEdit->clear();
mySectionView->reset();
onSelectionChanged();
+ updateUndoRedo();
}
void CurveCreator_Widget::onJoinAll()
myEdit->join();
mySectionView->reset();
onSelectionChanged();
+ updateUndoRedo();
}
void CurveCreator_Widget::onInsertSectionBefore()
if( !myEdit )
return;
QList<int> aSelSections = mySectionView->getSelectedSections();
+ myEdit->startOperation();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myEdit->setType(CurveCreator::BSpline, aSelSections[i]);
mySectionView->sectionChanged(aSelSections[i]);
}
+ myEdit->finishOperation();
+ updateUndoRedo();
}
void CurveCreator_Widget::onSetPolyline()
{
if( !myEdit )
return;
+ myEdit->startOperation();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myEdit->setType(CurveCreator::Polyline, aSelSections[i]);
mySectionView->sectionChanged(aSelSections[i]);
}
+ myEdit->finishOperation();
+ updateUndoRedo();
}
void CurveCreator_Widget::onCloseSections()
{
if( !myEdit )
return;
+ myEdit->startOperation();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myEdit->setClosed(true, aSelSections[i]);
mySectionView->sectionChanged(aSelSections[i]);
}
+ myEdit->finishOperation();
+ updateUndoRedo();
}
void CurveCreator_Widget::onUncloseSections()
{
if( !myEdit )
return;
+ myEdit->startOperation();
QList<int> aSelSections = mySectionView->getSelectedSections();
for( int i = 0 ; i < aSelSections.size() ; i++ ){
myEdit->setClosed(false, aSelSections[i]);
mySectionView->sectionChanged(aSelSections[i]);
}
+ myEdit->finishOperation();
+ updateUndoRedo();
+}
+
+void CurveCreator_Widget::onUndo()
+{
+ if( !myEdit )
+ return;
+ myEdit->undo();
+ mySectionView->reset();
+ updateUndoRedo();
+}
+
+void CurveCreator_Widget::onRedo()
+{
+ if( !myEdit )
+ return;
+ myEdit->redo();
+ mySectionView->reset();
+ updateUndoRedo();
+}
+
+void CurveCreator_Widget::updateUndoRedo()
+{
+ QAction* anAct = myActionMap[UNDO_ID];
+ if( anAct != 0 ){
+ if( myEdit->getNbUndo() != 0 ){
+ anAct->setEnabled(true);
+ }
+ else{
+ anAct->setDisabled(true);
+ }
+ }
+ anAct = myActionMap[REDO_ID];
+ if( anAct != 0 ){
+ if( myEdit->getNbRedo() != 0 ){
+ anAct->setEnabled(true);
+ }
+ else{
+ anAct->setDisabled(true);
+ }
+ }
}
void CurveCreator_Widget::onContextMenu( QPoint thePoint )
{
QList<ActionId> aContextActions;
aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<
- INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID << SEPARATOR_ID <<
CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<
- SET_SECTIONS_SPLINE_ID << SEPARATOR_ID <<
- INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
+ SET_SECTIONS_SPLINE_ID;
QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);
bool isVis = false;
QList<ActionId> aResAct;
}
aMenu->exec(aGlPoint);
}
+
+QList<int> CurveCreator_Widget::getSelectedSections()
+{
+ return mySectionView->getSelectedSections();
+}
+
+QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints()
+{
+ return mySectionView->getSelectedPoints();
+}
void setCurve( CurveCreator_Curve* theCurve );
+ QList<int> getSelectedSections();
+ QList< QPair< int, int > > getSelectedPoints();
+
signals:
-
+ void selectionChanged();
+
public slots:
protected slots:
void onUncloseSections();
void onInsertPointBefore();
void onInsertPointAfter();
+ void onUndo();
+ void onRedo();
void onUndoSettings();
void onContextMenu(QPoint thePoint);
protected:
QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
const QString& theToolTip, const QKeySequence& theShortcut );
QAction* getAction(ActionId theId);
+ void updateUndoRedo();
private:
QMap<ActionId, QAction*> myActionMap;
CurveCreator_Curve* myCurve;
CurveCreator_Diff.hxx \
CurveCreator_Section.hxx \
CurveCreator_Curve.hxx \
- CurveCreator_CurveEditor.hxx
+ CurveCreator_CurveEditor.hxx \
+ CurveCreator_Listener.hxx
# Compilation options for GUI mode
if GEOM_ENABLE_GUI