From: rnv Date: Fri, 21 Nov 2008 17:02:17 +0000 (+0000) Subject: Implementation Notebook in the GEOM. X-Git-Tag: TG_DumpPython_Extension_3~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8f8acbd807492a05fea70caa60816f381e199b3e;p=modules%2Fgeom.git Implementation Notebook in the GEOM. --- diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 1996716ac..b12b0ab17 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -104,8 +104,8 @@ def ParseParameters(*parameters): if isinstance(parameter,str): if notebook.isVariable(parameter): Result.append(notebook.get(parameter)) - pass - pass + else: + raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!" else: Result.append(parameter) pass diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h index dac7699af..c21a373a0 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h @@ -77,6 +77,7 @@ private slots: void SetEditCurrentArgument(); void ReverseAngle(); void ValueChangedInSpinBox( double ); + void TextValueChangedInSpinBox( const QString& ); void ConstructorsClicked( int ); void SetDoubleSpinBoxStep( double ); }; diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index c3d4b216e..498c1d16b 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -184,6 +184,13 @@ void TransformationGUI_MultiTranslationDlg::Init() connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged(const QString& )), + this, SLOT(TextValueChangedInSpinBox(const QString& ))); + connect(GroupDimensions->SpinBox_DX1, SIGNAL(textChanged(const QString& )), + this, SLOT(TextValueChangedInSpinBox(const QString& ))); + connect(GroupDimensions->SpinBox_DX2, SIGNAL(textChanged(const QString& )), + this, SLOT(TextValueChangedInSpinBox(const QString& ))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU())); @@ -505,6 +512,40 @@ void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*) ActivateThisDialog(); } +//================================================================================= +// function : TextValueChangedInSpinBox +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::TextValueChangedInSpinBox( const QString& s) +{ + QObject* send = (QObject*)sender(); + bool isDigit = true; + + switch (getConstructorId()) { + case 0: + GroupPoints->SpinBox_DX->text().toDouble(&isDigit); + if(!isDigit){ + GroupPoints->CheckButton1->setChecked(false); + } + GroupPoints->CheckButton1->setEnabled(isDigit); + break; + case 1: + if (send == GroupDimensions->SpinBox_DX1) { + GroupDimensions->SpinBox_DX1->text().toDouble(&isDigit); + if(!isDigit) + GroupDimensions->CheckButton1->setChecked(false); + GroupDimensions->CheckButton1->setEnabled(isDigit); + } + else if(send == GroupDimensions->SpinBox_DX2){ + GroupDimensions->SpinBox_DX2->text().toDouble(&isDigit); + if(!isDigit) + GroupDimensions->CheckButton2->setChecked(false); + GroupDimensions->CheckButton2->setEnabled(isDigit); + } + break; + } +} + //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -512,7 +553,6 @@ void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*) void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue) { QObject* send = (QObject*)sender(); - switch (getConstructorId()) { case 0: if (send == GroupPoints->SpinBox_DX) @@ -579,14 +619,24 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperatio // function : isValid // purpose : //================================================================================= -bool TransformationGUI_MultiTranslationDlg::isValid (QString& /*msg*/) +bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg) { int aConstructorId = getConstructorId(); - - if (aConstructorId == 0) - return !(myBase->_is_nil() || myVectorU->_is_nil()); - else if (aConstructorId == 1) - return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()); + + if (aConstructorId == 0) { + bool ok = true; + ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; + return !(myBase->_is_nil() || myVectorU->_is_nil()) && ok; + } + else if (aConstructorId == 1) { + bool ok = true; + ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && ok; + ok = GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && ok; + return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()) && ok; + } return 0; } @@ -600,11 +650,17 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + QStringList aParameters; + switch (getConstructorId()) { case 0: if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) { anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU); + if(!IsPreview()) { + aParameters<SpinBox_DX->text(); + aParameters<SpinBox_DY->text(); + } res = true; } break; @@ -614,13 +670,22 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> MultiTranslate2D(myBase, myVectorU, myStepU, myNbTimesU, myVectorV, myStepV, myNbTimesV); + if(!IsPreview()) { + aParameters<SpinBox_DX1->text(); + aParameters<SpinBox_DY1->text(); + aParameters<SpinBox_DX2->text(); + aParameters<SpinBox_DY2->text(); + } res = true; } break; } - if (!anObj->_is_nil()) + if (!anObj->_is_nil()) { + if(!IsPreview()) + anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); objects.push_back(anObj._retn()); + } return res; } diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h index 145fb48ec..ab91a4671 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h @@ -78,6 +78,7 @@ private slots: void ReverseStepU(); void ReverseStepV(); void ValueChangedInSpinBox( double ); + void TextValueChangedInSpinBox( const QString& ); void ConstructorsClicked( int ); void SetDoubleSpinBoxStep( double ); }; diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx index a0f4d448d..dd9636d6a 100644 --- a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx @@ -278,7 +278,7 @@ bool TransformationGUI_OffsetDlg::isValid( QString& msg ) return false; } } - return true; + return GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ); } //================================================================================= @@ -295,8 +295,12 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects ) for ( int i = 0; i < myObjects.length(); i++ ) { anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShapeCopy( myObjects[i], GetOffset() ); - if ( !anObj->_is_nil() ) + if ( !anObj->_is_nil() ) { + if(!IsPreview()) { + anObj->SetParameters(GroupPoints->SpinBox_DX->text().toLatin1().constData()); + } objects.push_back( anObj._retn() ); + } } } else { diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index eb4d0703c..de530cc54 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -151,6 +151,9 @@ void TransformationGUI_RotationDlg::Init() connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged( const QString& )), + this, SLOT(TextValueChangedInSpinBox( const QString&))); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); @@ -464,6 +467,16 @@ void TransformationGUI_RotationDlg::enterEvent (QEvent*) ActivateThisDialog(); } +void TransformationGUI_RotationDlg::TextValueChangedInSpinBox( const QString& s) +{ + bool isDigit = true; + s.toDouble(&isDigit); + if(!isDigit) { + GroupPoints->CheckButton2->setChecked(false); + } + GroupPoints->CheckButton2->setEnabled(isDigit); +} + //================================================================================= // function : ValueChangedInSpinBox() // purpose : @@ -486,13 +499,13 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool TransformationGUI_RotationDlg::isValid (QString& /*msg*/) +bool TransformationGUI_RotationDlg::isValid (QString& msg) { if (myObjects.length() < 1) return false; switch (getConstructorId()) { case 0: - return !(myAxis->_is_nil()); + return !(myAxis->_is_nil()) && GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ); break; case 1: return !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil()); @@ -522,8 +535,12 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) myCurrObject = myObjects[i]; anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> RotateCopy(myObjects[i], myAxis, GetAngle() * PI180); - if (!anObj->_is_nil()) + if (!anObj->_is_nil()) { + if(!IsPreview()) { + anObj->SetParameters(GroupPoints->SpinBox_DX->text().toLatin1().constData()); + } objects.push_back(anObj._retn()); + } } } else { diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h index b741346f0..5cc6ff2d7 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -74,6 +74,7 @@ private slots: void SelectionIntoArgument(); void SetEditCurrentArgument(); void ValueChangedInSpinBox(); + void TextValueChangedInSpinBox( const QString& ); void CreateCopyModeChanged( bool ); void ConstructorsClicked( int ); void onReverse(); diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index f9c28818b..e77150d3a 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -92,13 +92,13 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg (GeometryGUI* theGeometry LineEdit2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); TextLabel3 = new QLabel(tr("GEOM_SCALE_FACTOR"), GroupBox1); - SpinBox_FX = new QtxDoubleSpinBox(GroupBox1); + SpinBox_FX = new SalomeApp_DoubleSpinBox(GroupBox1); TextLabel4 = new QLabel(tr("GEOM_SCALE_FACTOR_Y"), GroupBox1); - SpinBox_FY = new QtxDoubleSpinBox(GroupBox1); + SpinBox_FY = new SalomeApp_DoubleSpinBox(GroupBox1); TextLabel5 = new QLabel(tr("GEOM_SCALE_FACTOR_Z"), GroupBox1); - SpinBox_FZ = new QtxDoubleSpinBox(GroupBox1); + SpinBox_FZ = new SalomeApp_DoubleSpinBox(GroupBox1); CheckBoxCopy = new QCheckBox(tr("GEOM_CREATE_COPY"), GroupBox1); CheckBoxCopy->setChecked(true); @@ -458,15 +458,19 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool TransformationGUI_ScaleDlg::isValid (QString& /*msg*/) +bool TransformationGUI_ScaleDlg::isValid (QString& msg) { if (myObjects.length() > 0 && fabs(SpinBox_FX->value()) > 0.00001) { // && !myPoint->_is_nil() - if (getConstructorId() == 0) - return true; + if (getConstructorId() == 0) { + return SpinBox_FX->isValid( msg, !IsPreview() ); + } if (fabs(SpinBox_FY->value()) > 0.00001 && - fabs(SpinBox_FZ->value()) > 0.00001) + fabs(SpinBox_FZ->value()) > 0.00001 && + SpinBox_FX->isValid( msg, !IsPreview()) && + SpinBox_FY->isValid( msg, !IsPreview()) && + SpinBox_FZ->isValid( msg, !IsPreview())) return true; } return false; @@ -492,8 +496,11 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) { anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value()); - if (!anObj->_is_nil()) + if (!anObj->_is_nil()) { + if(!IsPreview()) + anObj->SetParameters(SpinBox_FX->text().toLatin1().constData()); objects.push_back(anObj._retn()); + } } } else @@ -518,6 +525,13 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(), SpinBox_FY->value(), SpinBox_FZ->value()); if (!anObj->_is_nil()) + if(!IsPreview()) { + QStringList aParameters; + aParameters<text(); + aParameters<text(); + aParameters<text(); + anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + } objects.push_back(anObj._retn()); } } diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h index a2533298e..c4830e524 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.h +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -35,7 +35,7 @@ class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QtxDoubleSpinBox; +class SalomeApp_DoubleSpinBox; //================================================================================= // class : TransformationGUI_ScaleDlg @@ -79,9 +79,9 @@ private: QLabel* TextLabel3; QLabel* TextLabel4; QLabel* TextLabel5; - QtxDoubleSpinBox* SpinBox_FX; - QtxDoubleSpinBox* SpinBox_FY; - QtxDoubleSpinBox* SpinBox_FZ; + SalomeApp_DoubleSpinBox* SpinBox_FX; + SalomeApp_DoubleSpinBox* SpinBox_FY; + SalomeApp_DoubleSpinBox* SpinBox_FZ; QCheckBox* CheckBoxCopy; private slots: diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index f47bb590d..6a55d49a6 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -516,19 +516,25 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation() // function : isValid // purpose : //================================================================================= -bool TransformationGUI_TranslationDlg::isValid (QString& /*msg*/) +bool TransformationGUI_TranslationDlg::isValid (QString& msg) { int aConstructorId = getConstructorId(); if (myObjects.length() < 1) return false; switch (aConstructorId) { - case 0: - return true; + case 0: + { + bool ok = true; + ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) && ok; + ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) && ok; + return ok; + } case 1: return !(myPoint1->_is_nil() || myPoint2->_is_nil()); case 2: - return !(myVector->_is_nil()); + return !(myVector->_is_nil()) && GroupPoints->SpinBox3->isValid( msg, !IsPreview() ); default: break; } @@ -553,13 +559,21 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) double dy = GroupPoints->SpinBox2->value(); double dz = GroupPoints->SpinBox3->value(); + QStringList aParameters; + aParameters<SpinBox1->text(); + aParameters<SpinBox2->text(); + aParameters<SpinBox3->text(); + if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> TranslateDXDYDZCopy(myObjects[i], dx, dy, dz); - if (!anObj->_is_nil()) + if (!anObj->_is_nil()) { + if(!IsPreview()) + anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); objects.push_back(anObj._retn()); + } } } else { @@ -599,6 +613,7 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) } case 2: { + QStringList aParameters; bool byDistance = GroupPoints->CheckBox1->isChecked(); if (byDistance) { double aDistance = GroupPoints->SpinBox3->value(); @@ -606,8 +621,12 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) myCurrObject = myObjects[i]; anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> TranslateVectorDistance(myObjects[i], myVector, aDistance, toCreateCopy); - if (!anObj->_is_nil()) + if (!anObj->_is_nil()) { + if(toCreateCopy) + if(!IsPreview()) + anObj->SetParameters(GroupPoints->SpinBox3->text().toLatin1().constData()); objects.push_back(anObj._retn()); + } } } else {