]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx
Salome HOME
updated copyright message
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI_CylinderDlg.cxx
index 73e7c03fa73ee7a3ac4f23257b43557e78b69e1a..4e0a129125ffa16fa526852506e4b0be85a77e02 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -166,7 +166,7 @@ void PrimitiveGUI_CylinderDlg::Init()
 
   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
   
-  connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle()));
+  connect(GroupPoints->checkBox,     SIGNAL(toggled(bool)), this, SLOT(ActivateAngle()));
   connect(GroupDimensions->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle()));
   
   initName(tr("GEOM_CYLINDER"));
@@ -317,7 +317,7 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument()
     GroupPoints->LineEdit2->setEnabled(false);
 
     globalSelection(GEOM_POINT); // to break previous local selection
-    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
+    localSelection(TopAbs_VERTEX);
   }
   else if (send == GroupPoints->PushButton2) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
@@ -326,7 +326,7 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument()
     GroupPoints->LineEdit1->setEnabled(false);
 
     globalSelection(GEOM_LINE);  // to break previous local selection
-    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
+    localSelection(TopAbs_EDGE);
   }
   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
           this, SLOT(SelectionIntoArgument()));
@@ -385,7 +385,7 @@ void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox()
 //=================================================================================
 GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation()
 {
-  return getGeomEngine()->GetI3DPrimOperations(getStudyId());
+  return getGeomEngine()->GetI3DPrimOperations();
 }
 
 //=================================================================================
@@ -399,9 +399,10 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
   {
     ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
          GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
-         GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
+         ( !GroupPoints->checkBox->isChecked() || GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) ) &&
          myPoint && myDir;
-        if(GroupPoints->SpinBox_DZ->value()<=0. || GroupPoints->SpinBox_DZ->value()>=360.) {
+    if ( GroupPoints->checkBox->isChecked() && 
+        ( GroupPoints->SpinBox_DZ->value() <= 0. || GroupPoints->SpinBox_DZ->value() >= 360. ) ) {
       msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
       ok = false;
     }
@@ -410,10 +411,11 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
   {
     ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
          GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
-         GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
-        if(GroupDimensions->SpinBox_DZ->value()<=0. || GroupDimensions->SpinBox_DZ->value()>=360.) {
-           msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
-           ok = false;
+         ( !GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) );
+    if ( GroupDimensions->checkBox->isChecked() &&
+        ( GroupDimensions->SpinBox_DZ->value() <= 0. || GroupDimensions->SpinBox_DZ->value() >= 360. ) ) {
+      msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
+      ok = false;
     }
   }
   ok = qAbs( getHeight() ) > Precision::Confusion() && ok;
@@ -428,7 +430,6 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
 bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
 {
   bool res = false;
-  bool BAngle = false;
   
   GEOM::GEOM_Object_var anObj;
 
@@ -436,55 +437,53 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
 
   switch (getConstructorId()) {
   case 0:
-    BAngle = GroupPoints->checkBox->isChecked();
     if ( myPoint && myDir ) {
-      if(!BAngle){
-       anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
+      if ( GroupPoints->checkBox->isChecked() ) {
+       anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.);
        if (!anObj->_is_nil() && !IsPreview())
        {
          QStringList aParameters;
          aParameters << GroupPoints->SpinBox_DX->text();
          aParameters << GroupPoints->SpinBox_DY->text();
-         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+         aParameters << GroupPoints->SpinBox_DZ->text();
+         anObj->SetParameters(aParameters.join(":").toUtf8().constData());
        }
        res = true;
       }
-      else if(BAngle){
-       anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.);
+      else {
+       anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
        if (!anObj->_is_nil() && !IsPreview())
        {
          QStringList aParameters;
          aParameters << GroupPoints->SpinBox_DX->text();
          aParameters << GroupPoints->SpinBox_DY->text();
-         aParameters << GroupPoints->SpinBox_DZ->text();
-         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+         anObj->SetParameters(aParameters.join(":").toUtf8().constData());
        }
        res = true;
       }
     }
     break;
   case 1:
-    BAngle = GroupDimensions->checkBox->isChecked();
-    if(!BAngle){
-      anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
+    if ( GroupDimensions->checkBox->isChecked() ) {
+      anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.);
       if (!anObj->_is_nil() && !IsPreview())
       {
        QStringList aParameters;
        aParameters << GroupDimensions->SpinBox_DX->text();
        aParameters << GroupDimensions->SpinBox_DY->text();
-       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+       aParameters << GroupDimensions->SpinBox_DZ->text();
+       anObj->SetParameters(aParameters.join(":").toUtf8().constData());
       }
       res = true;
     }
-    else if(BAngle){
-      anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.);
+    else {
+      anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
       if (!anObj->_is_nil() && !IsPreview())
       {
        QStringList aParameters;
        aParameters << GroupDimensions->SpinBox_DX->text();
        aParameters << GroupDimensions->SpinBox_DY->text();
-       aParameters << GroupDimensions->SpinBox_DZ->text();
-       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+       anObj->SetParameters(aParameters.join(":").toUtf8().constData());
       }
       res = true;
     }
@@ -551,6 +550,17 @@ void PrimitiveGUI_CylinderDlg::addSubshapesToStudy()
   }
 }
 
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> PrimitiveGUI_CylinderDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  res << myPoint << myDir;
+  return res;
+}
+
 //=================================================================================
 // function :  ActivateAngle()
 // purpose  : enable the