Implementation Notebook in the GEOM.

This commit is contained in:
rnv 2008-11-21 17:02:17 +00:00
parent 38e241bb31
commit 8f8acbd807
10 changed files with 156 additions and 34 deletions

View File

@ -104,8 +104,8 @@ def ParseParameters(*parameters):
if isinstance(parameter,str): if isinstance(parameter,str):
if notebook.isVariable(parameter): if notebook.isVariable(parameter):
Result.append(notebook.get(parameter)) Result.append(notebook.get(parameter))
pass else:
pass raise RuntimeError, "Variable with name '" + parameter + "' doesn't exist!!!"
else: else:
Result.append(parameter) Result.append(parameter)
pass pass

View File

@ -77,6 +77,7 @@ private slots:
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ReverseAngle(); void ReverseAngle();
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );
void TextValueChangedInSpinBox( const QString& );
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void SetDoubleSpinBoxStep( double ); void SetDoubleSpinBoxStep( double );
}; };

View File

@ -184,6 +184,13 @@ void TransformationGUI_MultiTranslationDlg::Init()
connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DY2, 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(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU())); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
@ -505,6 +512,40 @@ void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
ActivateThisDialog(); 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() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -512,7 +553,6 @@ void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue) void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
{ {
QObject* send = (QObject*)sender(); QObject* send = (QObject*)sender();
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (send == GroupPoints->SpinBox_DX) if (send == GroupPoints->SpinBox_DX)
@ -579,14 +619,24 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperatio
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiTranslationDlg::isValid (QString& /*msg*/) bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg)
{ {
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
if (aConstructorId == 0) if (aConstructorId == 0) {
return !(myBase->_is_nil() || myVectorU->_is_nil()); bool ok = true;
else if (aConstructorId == 1) ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()); 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; return 0;
} }
@ -600,11 +650,17 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
QStringList aParameters;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) { if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU); MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
if(!IsPreview()) {
aParameters<<GroupPoints->SpinBox_DX->text();
aParameters<<GroupPoints->SpinBox_DY->text();
}
res = true; res = true;
} }
break; break;
@ -614,13 +670,22 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MultiTranslate2D(myBase, myVectorU, myStepU, myNbTimesU, MultiTranslate2D(myBase, myVectorU, myStepU, myNbTimesU,
myVectorV, myStepV, myNbTimesV); myVectorV, myStepV, myNbTimesV);
if(!IsPreview()) {
aParameters<<GroupDimensions->SpinBox_DX1->text();
aParameters<<GroupDimensions->SpinBox_DY1->text();
aParameters<<GroupDimensions->SpinBox_DX2->text();
aParameters<<GroupDimensions->SpinBox_DY2->text();
}
res = true; res = true;
} }
break; break;
} }
if (!anObj->_is_nil()) if (!anObj->_is_nil()) {
if(!IsPreview())
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
objects.push_back(anObj._retn()); objects.push_back(anObj._retn());
}
return res; return res;
} }

View File

@ -78,6 +78,7 @@ private slots:
void ReverseStepU(); void ReverseStepU();
void ReverseStepV(); void ReverseStepV();
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );
void TextValueChangedInSpinBox( const QString& );
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void SetDoubleSpinBoxStep( double ); void SetDoubleSpinBoxStep( double );
}; };

View File

@ -278,7 +278,7 @@ bool TransformationGUI_OffsetDlg::isValid( QString& msg )
return false; 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++ ) { for ( int i = 0; i < myObjects.length(); i++ ) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShapeCopy( myObjects[i], GetOffset() ); 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() ); objects.push_back( anObj._retn() );
}
} }
} }
else { else {

View File

@ -151,6 +151,9 @@ void TransformationGUI_RotationDlg::Init()
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); 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->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
@ -464,6 +467,16 @@ void TransformationGUI_RotationDlg::enterEvent (QEvent*)
ActivateThisDialog(); 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() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -486,13 +499,13 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_RotationDlg::isValid (QString& /*msg*/) bool TransformationGUI_RotationDlg::isValid (QString& msg)
{ {
if (myObjects.length() < 1) return false; if (myObjects.length() < 1) return false;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
return !(myAxis->_is_nil()); return !(myAxis->_is_nil()) && GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() );
break; break;
case 1: case 1:
return !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil()); return !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil());
@ -522,8 +535,12 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
RotateCopy(myObjects[i], myAxis, GetAngle() * PI180); 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()); objects.push_back(anObj._retn());
}
} }
} }
else { else {

View File

@ -74,6 +74,7 @@ private slots:
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox(); void ValueChangedInSpinBox();
void TextValueChangedInSpinBox( const QString& );
void CreateCopyModeChanged( bool ); void CreateCopyModeChanged( bool );
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void onReverse(); void onReverse();

View File

@ -28,7 +28,7 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <QtxDoubleSpinBox.h> #include <SalomeApp_DoubleSpinBox.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
@ -92,13 +92,13 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg (GeometryGUI* theGeometry
LineEdit2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); LineEdit2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
TextLabel3 = new QLabel(tr("GEOM_SCALE_FACTOR"), GroupBox1); 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); 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); 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 = new QCheckBox(tr("GEOM_CREATE_COPY"), GroupBox1);
CheckBoxCopy->setChecked(true); CheckBoxCopy->setChecked(true);
@ -458,15 +458,19 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation()
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_ScaleDlg::isValid (QString& /*msg*/) bool TransformationGUI_ScaleDlg::isValid (QString& msg)
{ {
if (myObjects.length() > 0 && fabs(SpinBox_FX->value()) > 0.00001) if (myObjects.length() > 0 && fabs(SpinBox_FX->value()) > 0.00001)
{ {
// && !myPoint->_is_nil() // && !myPoint->_is_nil()
if (getConstructorId() == 0) if (getConstructorId() == 0) {
return true; return SpinBox_FX->isValid( msg, !IsPreview() );
}
if (fabs(SpinBox_FY->value()) > 0.00001 && 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 true;
} }
return false; return false;
@ -492,8 +496,11 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
{ {
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value()); 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()); objects.push_back(anObj._retn());
}
} }
} }
else else
@ -518,6 +525,13 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(), ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value()); SpinBox_FY->value(), SpinBox_FZ->value());
if (!anObj->_is_nil()) if (!anObj->_is_nil())
if(!IsPreview()) {
QStringList aParameters;
aParameters<<SpinBox_FX->text();
aParameters<<SpinBox_FY->text();
aParameters<<SpinBox_FZ->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
}
objects.push_back(anObj._retn()); objects.push_back(anObj._retn());
} }
} }

View File

@ -35,7 +35,7 @@ class QGroupBox;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QPushButton; class QPushButton;
class QtxDoubleSpinBox; class SalomeApp_DoubleSpinBox;
//================================================================================= //=================================================================================
// class : TransformationGUI_ScaleDlg // class : TransformationGUI_ScaleDlg
@ -79,9 +79,9 @@ private:
QLabel* TextLabel3; QLabel* TextLabel3;
QLabel* TextLabel4; QLabel* TextLabel4;
QLabel* TextLabel5; QLabel* TextLabel5;
QtxDoubleSpinBox* SpinBox_FX; SalomeApp_DoubleSpinBox* SpinBox_FX;
QtxDoubleSpinBox* SpinBox_FY; SalomeApp_DoubleSpinBox* SpinBox_FY;
QtxDoubleSpinBox* SpinBox_FZ; SalomeApp_DoubleSpinBox* SpinBox_FZ;
QCheckBox* CheckBoxCopy; QCheckBox* CheckBoxCopy;
private slots: private slots:

View File

@ -516,19 +516,25 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation()
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_TranslationDlg::isValid (QString& /*msg*/) bool TransformationGUI_TranslationDlg::isValid (QString& msg)
{ {
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
if (myObjects.length() < 1) return false; if (myObjects.length() < 1) return false;
switch (aConstructorId) { switch (aConstructorId) {
case 0: case 0:
return true; {
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: case 1:
return !(myPoint1->_is_nil() || myPoint2->_is_nil()); return !(myPoint1->_is_nil() || myPoint2->_is_nil());
case 2: case 2:
return !(myVector->_is_nil()); return !(myVector->_is_nil()) && GroupPoints->SpinBox3->isValid( msg, !IsPreview() );
default: default:
break; break;
} }
@ -553,13 +559,21 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects)
double dy = GroupPoints->SpinBox2->value(); double dy = GroupPoints->SpinBox2->value();
double dz = GroupPoints->SpinBox3->value(); double dz = GroupPoints->SpinBox3->value();
QStringList aParameters;
aParameters<<GroupPoints->SpinBox1->text();
aParameters<<GroupPoints->SpinBox2->text();
aParameters<<GroupPoints->SpinBox3->text();
if (toCreateCopy) { if (toCreateCopy) {
for (int i = 0; i < myObjects.length(); i++) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateDXDYDZCopy(myObjects[i], dx, dy, dz); 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()); objects.push_back(anObj._retn());
}
} }
} }
else { else {
@ -599,6 +613,7 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects)
} }
case 2: case 2:
{ {
QStringList aParameters;
bool byDistance = GroupPoints->CheckBox1->isChecked(); bool byDistance = GroupPoints->CheckBox1->isChecked();
if (byDistance) { if (byDistance) {
double aDistance = GroupPoints->SpinBox3->value(); double aDistance = GroupPoints->SpinBox3->value();
@ -606,8 +621,12 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects)
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateVectorDistance(myObjects[i], myVector, aDistance, toCreateCopy); 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()); objects.push_back(anObj._retn());
}
} }
} }
else { else {