]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Added 2 new operations:
authorrnc <rnc@opencascade.com>
Thu, 1 Mar 2012 14:35:25 +0000 (14:35 +0000)
committerrnc <rnc@opencascade.com>
Thu, 1 Mar 2012 14:35:25 +0000 (14:35 +0000)
- Extruded cut, allows to add material an existing shape by extrusion of a profile
- Extruded boss, allows to remove material from an existing shape by extrusion od a profile

Modified the sketcher dialog in order to use MakeSketcherOnPLane API instead of MakeSketcher. It is now possible to make a skecth directly on the face of a shape without creating a local coordinate system.

Code refactoring in the sketcher dialog

30 files changed:
idl/GEOM_Gen.idl
resources/Makefile.am
resources/draft.png [new file with mode: 0644]
resources/extruded_boss.png [new file with mode: 0644]
resources/extruded_cut.png [new file with mode: 0644]
src/DlgRef/DlgRef.cxx
src/DlgRef/DlgRef.h
src/DlgRef/DlgRef.pro
src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui [new file with mode: 0644]
src/DlgRef/Makefile.am
src/EntityGUI/EntityGUI_SketcherDlg.cxx
src/EntityGUI/EntityGUI_SketcherDlg.h
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI_Operations.h
src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx
src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx
src/GEOMImpl/GEOMImpl_IPrism.hxx
src/GEOMImpl/GEOMImpl_PrismDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_I3DPrimOperations_i.cc
src/GEOM_I/GEOM_I3DPrimOperations_i.hh
src/GEOM_SWIG/geompyDC.py
src/OperationGUI/Makefile.am
src/OperationGUI/OperationGUI.cxx
src/OperationGUI/OperationGUI.h
src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx [new file with mode: 0644]
src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h [new file with mode: 0644]

index 919daa260564660e33dbb911572afab10427a992..1792e88e226065157b0d19fd24d4362c65d1c08b 100644 (file)
@@ -1311,6 +1311,23 @@ module GEOM
                                             in double theDX, in double theDY, in double theDZ,
                                             in double theScaleFactor);
 
+
+    /*!
+     *  \brief Add / Remove material to / from  a solid by extrusion of the base shape on the given distance.
+     *  \param theInitShape Initial shape on which to perform the feature.It has to be a solid or 
+     *   a compound made of a single solid
+     *  \param theBase Edge or wire defining the base shape to be extruded. 
+     *  \param theHeight Prism dimension along the normal of the face.
+     *  \param theAngle Draft angel in degrees
+     *  \param theFuse If true material is added else material is removed
+     *  \return New GEOM_Object, containing the modified shape
+     */
+    GEOM_Object MakeDraftPrism (in GEOM_Object theInitShape,
+                                in GEOM_Object theBase,
+                                in double theHeight, 
+                                in double theAngle,
+                                in boolean theFuse);
+
     /*!
      *  \brief Create a shape by extrusion of the base shape along
      *  the path shape. The path shape can be a wire or an edge.
index 8938d374e49ae047863050b96495034884174b03..9719dd063fcbbeba0168b59e8243b98fea80ba66 100644 (file)
@@ -78,8 +78,11 @@ disk_r.png                   \
 display.png                    \
 displayonly.png                        \
 displayall.png                 \
+draft.png                      \
 erase.png                      \
 eraseall.png                   \
+extruded_boss.png              \
+extruded_cut.png               \
 face_hw.png                    \
 face_vechw.png                 \
 feature_detect.png             \
diff --git a/resources/draft.png b/resources/draft.png
new file mode 100644 (file)
index 0000000..d99c8a6
Binary files /dev/null and b/resources/draft.png differ
diff --git a/resources/extruded_boss.png b/resources/extruded_boss.png
new file mode 100644 (file)
index 0000000..fca4e90
Binary files /dev/null and b/resources/extruded_boss.png differ
diff --git a/resources/extruded_cut.png b/resources/extruded_cut.png
new file mode 100644 (file)
index 0000000..21ae1cf
Binary files /dev/null and b/resources/extruded_cut.png differ
index 5af5142e2f736ac6fe261ffbd9139ee827d40994..8c21e214d056798c728000ab97acc52876fa2594 100644 (file)
@@ -428,6 +428,20 @@ DlgRef_2Sel2Spin::~DlgRef_2Sel2Spin()
 {
 }
 
+//////////////////////////////////////////
+// DlgRef_2Sel2Spin1Push
+//////////////////////////////////////////
+
+DlgRef_2Sel2Spin1Push::DlgRef_2Sel2Spin1Push( QWidget* parent, Qt::WindowFlags f )
+: QWidget( parent, f )
+{
+  setupUi( this );
+}
+
+DlgRef_2Sel2Spin1Push::~DlgRef_2Sel2Spin1Push()
+{
+}
+
 //////////////////////////////////////////
 // DlgRef_2Sel3Spin2Rb
 //////////////////////////////////////////
index 0436df09aae06afe5ca1b99af823dc3431f6caba..0673ad7dc84c8a5343636f23de14535fcf5d9cbc 100644 (file)
@@ -499,6 +499,22 @@ public:
   ~DlgRef_2Sel2Spin();
 };
 
+//////////////////////////////////////////
+// DlgRef_2Sel2Spin1Push
+//////////////////////////////////////////
+
+#include "ui_DlgRef_2Sel2Spin1Push_QTD.h"
+
+class DLGREF_EXPORT DlgRef_2Sel2Spin1Push : public QWidget, 
+                                       public Ui::DlgRef_2Sel2Spin1Push_QTD
+{
+  Q_OBJECT
+
+public:
+  DlgRef_2Sel2Spin1Push( QWidget* = 0, Qt::WindowFlags = 0 );
+  ~DlgRef_2Sel2Spin1Push();
+};
+
 //////////////////////////////////////////
 // DlgRef_2Sel3Spin2Rb
 //////////////////////////////////////////
index aa4ead95336272d4f7a4f73d66534d885e5933e4..cea85d4a78a93aa35577bc05e8f995a3e17ba3ec 100644 (file)
@@ -94,6 +94,7 @@ HEADERS += DlgRef_1Sel3Spin1Check.h
 HEADERS += DlgRef_1Sel4Spin2Check.h
 HEADERS += DlgRef_2Sel1Spin2Check.h
 HEADERS += DlgRef_2Sel2Spin1Check.h
+HEADERS += DlgRef_2Sel2Spin1Push.h
 HEADERS += DlgRef_2Sel2Spin3Check.h
 HEADERS += DlgRef_2Sel4Spin1Check.h
 HEADERS += DlgRef_3Sel4Spin2Check.h
diff --git a/src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui b/src/DlgRef/DlgRef_2Sel2Spin1Push_QTD.ui
new file mode 100644 (file)
index 0000000..4c3dbe5
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DlgRef_2Sel2Spin1Push_QTD</class>
+ <widget class="QWidget" name="DlgRef_2Sel2Spin1Push_QTD">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>281</width>
+    <height>150</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string/>
+  </property>
+  <layout class="QGridLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QGroupBox" name="GroupBox1">
+     <property name="title">
+      <string/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="TextLabel1">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>TL1</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QPushButton" name="PushButton1">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <widget class="QLineEdit" name="LineEdit1"/>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="TextLabel2">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>TL2</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QPushButton" name="PushButton2">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2">
+       <widget class="QLineEdit" name="LineEdit2"/>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="TextLabel3">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>TL3</string>
+        </property>
+        <property name="wordWrap">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1" colspan="2">
+       <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX"/>
+      </item>
+      <item row="3" column="2">
+       <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY"/>
+      </item>
+      <item row="3" column="1">
+       <widget class="QPushButton" name="PushButton3">
+        <property name="text">
+         <string/>
+        </property>
+        <property name="checkable">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
+ <customwidgets>
+  <customwidget>
+   <class>SalomeApp_DoubleSpinBox</class>
+   <extends>QDoubleSpinBox</extends>
+   <header location="global">SalomeApp_DoubleSpinBox.h</header>
+  </customwidget>
+ </customwidgets>
+ <tabstops>
+  <tabstop>PushButton1</tabstop>
+  <tabstop>LineEdit1</tabstop>
+  <tabstop>PushButton2</tabstop>
+  <tabstop>LineEdit2</tabstop>
+  <tabstop>SpinBox_DX</tabstop>
+  <tabstop>SpinBox_DY</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
index cea029eacac91cca6f581203d8ab9c42e0887709..8566c14e1d6584ba94db75afac54c7384e1cbf1d 100644 (file)
@@ -65,6 +65,7 @@ UIC_FILES =                                   \
        ui_DlgRef_2Sel2Spin1Check_QTD.h         \
        ui_DlgRef_2Sel2Spin3Check_QTD.h         \
        ui_DlgRef_2Sel2Spin_QTD.h               \
+       ui_DlgRef_2Sel2Spin1Push_QTD.h          \
        ui_DlgRef_2Sel3Spin2Rb_QTD.h            \
        ui_DlgRef_2Sel3Spin_QTD.h               \
        ui_DlgRef_2Sel4Spin1Check_QTD.h         \
index db3663ce1982ad16844529aceb4b5568f60399fc..a9b37aa9392f7ddc12825b3bc5b16e6280e80364 100644 (file)
@@ -100,6 +100,7 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
   QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO"    ) ) );
   QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
   QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC"     ) ) );
+  QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
 
   setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
 
@@ -116,19 +117,29 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
   /***************************************************************/
 
   GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
-  QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
+  QGridLayout* planeLayout = new QGridLayout(GroupBox1);
   planeLayout->setSpacing(6);
   planeLayout->setMargin(11);
 
   ComboBox1 = new QComboBox(GroupBox1);
-  ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
-  planeLayout->addWidget(ComboBox1);
+  //ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
+  planeLayout->addWidget(ComboBox1,0,0,1,2);
 
   planeButton = new QPushButton (GroupBox1);
-  planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
+  //planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
   planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
-  planeLayout->addWidget(planeButton);
-
+  planeLayout->addWidget(planeButton,0,2);
+  
+  selButton = new QPushButton (GroupBox1);
+  selButton->setIcon(image5);
+  planeLayout->addWidget(selButton,1,0);
+  
+  WPlaneLineEdit = new QLineEdit (GroupBox1);
+  WPlaneLineEdit->setReadOnly(true);
+  planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
+  
+  planeLayout->setColumnStretch(1,1);
+  
   topLayout->addWidget(GroupBox1);
   topLayout->addWidget( MainWidget );
   topLayout->setStretch( 1, 1);
@@ -311,8 +322,9 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
   connect( Group2Sel->checkBox,      SIGNAL( stateChanged( int ) ),    this, SLOT( CheckBoxClicked( int ) ) );
   connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ),    this, SLOT( CheckBoxClicked( int ) ) );
 
-  connect( ComboBox1,                SIGNAL( activated( int ) ),       this, SLOT( SelectionIntoArgument() ) );
+  connect( ComboBox1,                SIGNAL( activated( int ) ),       this, SLOT( ActivateLocalCS() ) );
   connect( planeButton,              SIGNAL( clicked() ),              this, SLOT( ActivateLocalCS() ) );
+  connect( selButton,                SIGNAL( clicked() ),              this, SLOT( SetEditCurrentArgument() ) );
 
   connect( myGeometryGUI,            SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
 
@@ -394,12 +406,14 @@ void EntityGUI_SketcherDlg::Init()
 {
   /* init variables */
   autoApply = false;
-  myEditCurrentArgument = Group1Sel->LineEdit1;
+  
+  myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
+  
   myCommand.append( "Sketcher" );
   myUndoCommand.append( "Sketcher" );
 
   mySketchState = FIRST_POINT;
-  globalSelection( GEOM_POINT );
+  globalSelection( GEOM_FACE );
 
   myCheckFlag = 0;
 
@@ -409,6 +423,13 @@ void EntityGUI_SketcherDlg::Init()
   myLastY2 = 0.0;
 
   myHelpFileName = "create_sketcher_page.html";
+  
+  GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
+  myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
+                                     0,0,1,
+                                     1,0,0 ); 
+  myWPlane = myGlobalCS;
+  myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
 
   /* Get setting of step value from file configuration */
   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
@@ -435,10 +456,15 @@ void EntityGUI_SketcherDlg::Init()
 
   MainWidget->RadioButton1->setChecked( true );
 
-  TypeClicked( 0 );
-
   FindLocalCS();
+  TypeClicked( 0 );
+  // If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
+  // that should be filled with the possibly selected face
+  SelectionIntoArgument();     
+  
   resize(100,100);
+  
+  setPrefix(tr("GEOM_SKETCH"));
 
   ActivateLocalCS();
   GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
@@ -451,6 +477,7 @@ void EntityGUI_SketcherDlg::Init()
 //=================================================================================
 void EntityGUI_SketcherDlg::InitClick()
 {
+  MESSAGE("EntityGUI_SketcherDlg::InitClick()")
   disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
   myCheckFlag = 0;
 
@@ -1007,6 +1034,8 @@ bool EntityGUI_SketcherDlg::ClickOnApply()
   if ( sender() && sender()->inherits( "QPushButton" ) )
     ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
 
+//   addSubshapesToStudy();
+
   QString aParameters;
   myCommand.append( GetNewCommand( aParameters ) );
   mySketchState = NEXT_POINT;
@@ -1168,210 +1197,163 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
 {
   MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
   myEditCurrentArgument->setText( "" );
-  double tmpX = myX;
-  double tmpY = myY;
-  myX = myLastX1;
-  myY = myLastY1;
-  //  printf ("\nmyX = %f         myY = %f", myX, myY);
-  //  printf ("\nmyLastX1 = %f    myLastY1 = %f", myLastX1, myLastY1);
-  //  printf ("\nmyLastX2 = %f    myLastY2 = %f", myLastX2, myLastY2);
-
-  if ( sender() == ComboBox1 )
-      ActivateLocalCS();
 
   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
   SALOME_ListIO aSelList;
   aSelMgr->selectedObjects(aSelList);
-
-  int nbSel = aSelList.Extent();
-  MESSAGE("NbSel = "<<nbSel)
-  if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
-    GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-    if ( !CORBA::is_nil(aSelectedObject) ) {
-      TopoDS_Shape aShape;
-      if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
-        gp_Trsf aTrans;
-        gp_Ax3 aWPlane = GetActiveLocalCS();
-
-        aTrans.SetTransformation(aWPlane);
-        BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
-        aShape = aTransformation.Shape();
-
-        gp_Pnt aPnt;
-        if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
-          myX = aPnt.X();
-          myY = aPnt.Y();
-          Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
-          if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
-            disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            Group2Spin->SpinBox_DX->setValue(myX);
-            Group2Spin->SpinBox_DY->setValue(myY);
-            connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-          } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
-            if ( myLastX1 && myLastY1 ) {
-              Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
-              Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
-            } else {
-              if ( mySketchState != FIRST_POINT ) {
-                Group2Spin->SpinBox_DX->setValue(myX - tmpX);
-                Group2Spin->SpinBox_DY->setValue(myY - tmpY);
-              } else {
-                Group2Spin->SpinBox_DX->setValue(myX);
-                Group2Spin->SpinBox_DY->setValue(myY);
-              }
-            }
-          }
-        }
-      }
-    }
+  
+  this->activateWindow();
+  
+  if (aSelList.Extent() == 0)
+  {
+    selButton->setDown(false);
+    WPlaneLineEdit->setEnabled(false);
+    WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
+    return;
   }
-
-  if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) {
-    GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-    if ( !CORBA::is_nil(aSelectedObject) ) {
-      TopoDS_Shape aShape;
-      if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
-        gp_Trsf aTrans;
-        gp_Ax3 aWPlane = GetActiveLocalCS();
-
-        aTrans.SetTransformation(aWPlane);
-        BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
-        aShape = aTransformation.Shape();
-
-        gp_Pnt aPnt;
-        if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
-          myX = aPnt.X();
-          myY = aPnt.Y();
-          Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
-          if( Group3Spin->isVisible() && mySketchType == PT_ABS ) {
+  else if (aSelList.Extent() != 1)                                
+    return;
+  
+  double tmpX = myX;
+  double tmpY = myY;
+  myX = myLastX1;
+  myY = myLastY1;
+  
+  TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+  if (myEditCurrentArgument == WPlaneLineEdit)
+    aNeedType = TopAbs_FACE;
+  
+  GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+  TopoDS_Shape aShape;
+  
+  if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) 
+                     && !aShape.IsNull())
+  { 
+    QString aName = GEOMBase::GetName( aSelectedObject.get() ); 
+    myEditCurrentArgument->setText(aName);
+    if (myEditCurrentArgument==WPlaneLineEdit)  
+    { 
+      AddLocalCS(aSelectedObject.get());
+      selButton->setDown(false);
+      WPlaneLineEdit->setEnabled(false);
+      TypeClicked( 0 );
+    }           
+    else
+    {
+      gp_Trsf aTrans;
+      gp_Ax3 aWPlane = GetActiveLocalCS();
+
+      aTrans.SetTransformation(aWPlane);
+      BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
+      aShape = aTransformation.Shape();
+
+      gp_Pnt aPnt;
+      if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) 
+      {
+        myX = aPnt.X();
+        myY = aPnt.Y();       
+        double Xcoord = myX;
+        double Ycoord = myY;
+        
+        switch (mySketchType)
+        {
+          case PT_ABS:
+          disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+          disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+          
+          Group2Spin->SpinBox_DX->setValue(Xcoord);
+          Group2Spin->SpinBox_DY->setValue(Ycoord);
+      
+          connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+          connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+            break;
+            
+          case PT_RELATIVE:
+            if (myLastX1 && myLastY1)
+            {
+              Xcoord = myX - myLastX1;
+              Ycoord = myY - myLastY1;
+            }
+            else if (mySketchState != FIRST_POINT)
+            {
+              Xcoord = myX - tmpX;
+              Ycoord = myY - tmpY;
+            }          
+            Group2Spin->SpinBox_DX->setValue(Xcoord);
+            Group2Spin->SpinBox_DY->setValue(Ycoord);      
+            break; 
+            
+          case PT_ABS_RADIUS:
             disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
             disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            Group3Spin->SpinBox_DX->setValue(myX);
-            Group3Spin->SpinBox_DY->setValue(myY);
+            
+            Group3Spin->SpinBox_DX->setValue(Xcoord);
+            Group3Spin->SpinBox_DY->setValue(Ycoord);
+      
             connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
             connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-          } else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) {
-            if ( myLastX1 && myLastY1 ) {
-              Group3Spin->SpinBox_DX->setValue(myX - myLastX1);
-              Group3Spin->SpinBox_DY->setValue(myY - myLastY1);
-            } else {
-              if ( mySketchState != FIRST_POINT ) {
-                Group3Spin->SpinBox_DX->setValue(myX - tmpX);
-                Group3Spin->SpinBox_DY->setValue(myY - tmpY);
-              } else {
-                Group3Spin->SpinBox_DX->setValue(myX);
-                Group3Spin->SpinBox_DY->setValue(myY);
-              }
+            break;
+            
+          case PT_REL_RADIUS:
+            if (myLastX1 && myLastY1)
+            {
+              Xcoord = myX - myLastX1;
+              Ycoord = myY - myLastY1;
             }
-          }
-        }
-      }
-    }
-  }
-
-  if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) {
-    GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-    if ( !CORBA::is_nil(aSelectedObject) ) {
-      TopoDS_Shape aShape;
-      if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
-        gp_Trsf aTrans;
-        gp_Ax3 aWPlane = GetActiveLocalCS();
-
-        aTrans.SetTransformation(aWPlane);
-        BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
-        aShape = aTransformation.Shape();
-
-        gp_Pnt aPnt;
-        if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
-          myXc = aPnt.X();
-          myYc = aPnt.Y();
-          Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
-          if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
+            else if (mySketchState != FIRST_POINT)
+            {
+              Xcoord = myX - tmpX;
+              Ycoord = myY - tmpY;
+            }             
+            Group3Spin->SpinBox_DX->setValue(Xcoord);
+            Group3Spin->SpinBox_DY->setValue(Ycoord);
+            break; 
+            
+          case PT_ABS_CENTER:
             disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
             disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            Group4Spin->SpinBox_DX->setValue(myXc);
-            Group4Spin->SpinBox_DY->setValue(myYc);
+            
+            Group4Spin->SpinBox_DX->setValue(Xcoord);
+            Group4Spin->SpinBox_DY->setValue(Ycoord);
+      
             connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-          } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
-            if ( myLastX1 && myLastY1 ) {
-              Group4Spin->SpinBox_DX->setValue(myXc - myLastX1);
-              Group4Spin->SpinBox_DY->setValue(myYc - myLastY1);
-            } else {
-              if ( mySketchState != FIRST_POINT ) {
-                Group4Spin->SpinBox_DX->setValue(myXc - tmpX);
-                Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
-              } else {
-                Group4Spin->SpinBox_DX->setValue(myXc);
-                Group4Spin->SpinBox_DY->setValue(myYc);
-              }
+            connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );        
+            break;
+            
+          case PT_REL_CENTER:
+            if (myLastX1 && myLastY1)
+            {
+              Xcoord = myXc - myLastX1;
+              Ycoord = myYc - myLastY1;
             }
-          }
-        }
-      }
-    }
-  }
-
-  if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) {
-    if (!Group2Sel->LineEdit1->text().isEmpty()){    //Check wether or not Linedit2 has been modified
-      myX=tmpX;                                      // If yes keep the old values of X and Y  
-      myY=tmpY;
-    }
-    GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-    if ( !CORBA::is_nil(aSelectedObject) ) {
-      TopoDS_Shape aShape;
-      if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
-        gp_Trsf aTrans;
-        gp_Ax3 aWPlane = GetActiveLocalCS();
-
-        aTrans.SetTransformation(aWPlane);
-        BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
-        aShape = aTransformation.Shape();
-
-        gp_Pnt aPnt;
-        if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
-          myX = aPnt.X();
-          myY = aPnt.Y();
-          Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
-          if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
-            disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            Group4Spin->SpinBox_DZ->setValue(myX);
-            Group4Spin->SpinBox_DS->setValue(myY);
-            connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-            connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-          } else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
-            if ( myLastX1 && myLastY1 ) {
-              Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
-              Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
-            } else {
-              if ( mySketchState != FIRST_POINT ) {
-                Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
-                Group4Spin->SpinBox_DS->setValue(myY - tmpY);
-              } else {
-                Group4Spin->SpinBox_DZ->setValue(myX);
-                Group4Spin->SpinBox_DS->setValue(myY);
-              }
+            else if (mySketchState != FIRST_POINT)
+            {
+              Xcoord = myXc - tmpX;
+              Ycoord = myYc - tmpY;
+            } 
+            else
+            {
+              Xcoord = myXc;
+              Ycoord = myYc;
             }
-          }
+            
+            Group4Spin->SpinBox_DX->setValue(Xcoord);
+            Group4Spin->SpinBox_DY->setValue(Ycoord);            
+            break; 
+            
         }
       }
     }
   }
-  if (nbSel == 0){                 // If no object selected
-    myX=tmpX;                      // Don't change the point coordinates
-    myY=tmpY;                      // and don't redisplay the preview
-  }
-  else if(!autoApply){
+
+  if(!autoApply){
     GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
   }
-  if ( autoApply ){    
+  else {    
     ClickOnApply();
     autoApply = false;
   }
-  this->activateWindow();
   
 }
 
@@ -1382,6 +1364,7 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
 //=================================================================================
 void EntityGUI_SketcherDlg::SetEditCurrentArgument()
 {
+  TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
   if ( sender() == Group1Sel->PushButton1 ) {
     myEditCurrentArgument = Group1Sel->LineEdit1;
     myEditCurrentArgument->setFocus();
@@ -1406,7 +1389,14 @@ void EntityGUI_SketcherDlg::SetEditCurrentArgument()
     Group2Sel->LineEdit2->setEnabled(true);
    // myEditCurrentArgument->setFocus();
   }
-  SelectionIntoArgument();
+  else if ( sender() == selButton ) {
+    myNeedType = TopAbs_FACE;
+    myEditCurrentArgument = WPlaneLineEdit;
+    WPlaneLineEdit->setEnabled(true);
+    selButton->setDown(true);
+  }
+  globalSelection(); // close local selection to clear it
+  localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
 }
 
 
@@ -1470,9 +1460,9 @@ void EntityGUI_SketcherDlg::ActivateThisDialog()
           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   //myGeometryGUI->SetState( 0 );
-  globalSelection( GEOM_POINT );
+//   globalSelection( GEOM_POINT );
   
-  myEditCurrentArgument = Group1Sel->LineEdit1;
+  myEditCurrentArgument = WPlaneLineEdit;
   myEditCurrentArgument->setFocus();
   
    if ( sender() == Group1Sel->LineEdit1 ) {
@@ -2235,24 +2225,14 @@ bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
     }
   }
 
-  gp_Ax3 myWPlane = GetActiveLocalCS();
-  GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
-  WPlane->length( 9 );
-  WPlane[0] = myWPlane.Location().X();
-  WPlane[1] = myWPlane.Location().Y();
-  WPlane[2] = myWPlane.Location().Z();
-
-  WPlane[3] = myWPlane.Direction().X();
-  WPlane[4] = myWPlane.Direction().Y();
-  WPlane[5] = myWPlane.Direction().Z();
-
-  WPlane[6] = myWPlane.XDirection().X();
-  WPlane[7] = myWPlane.XDirection().Y();
-  WPlane[8] = myWPlane.XDirection().Z();
-
   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
-  GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane );
-
+  GEOM::GEOM_Object_var anObj = NULL;
+  
+  int index = ComboBox1->currentIndex();
+  if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
+  {
+    anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
+  }
   if ( !anObj->_is_nil() )
   {
     if( !IsPreview() ) {
@@ -2325,7 +2305,7 @@ void EntityGUI_SketcherDlg::displayPntPreview(const double x,
                                              )
 {
   // Get globalCS and working plane
-  gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX);
+  gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
   gp_Ax3 aWPlane  = GetActiveLocalCS();
   
   // Build point in localCS
@@ -2392,6 +2372,16 @@ bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
   return true;
 }
 
+//=================================================================================
+// function : acceptMouseEvent()
+// purpose  :
+//=================================================================================
+bool EntityGUI_SketcherDlg::acceptMouseEvent() const 
+{
+  return ( (getPnt1ConstructorId() == 1 || getPnt1ConstructorId() == 0)  //accept mouse event only on absolute and relative selection mode        
+           && !WPlaneLineEdit->isEnabled());                                  // called by EntityGUI::OnMousePress()
+}  
+
 //=================================================================================
 // function : keyPressEvent()
 // purpose  :
@@ -2457,14 +2447,43 @@ void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
   //Group4Spin->SpinBox_DS->setSingleStep(step);
 }
 
+//=================================================================================
+// function : AddLocalCS()
+// purpose  : Add All Coordinates systems in study
+//=================================================================================
+void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
+{
+  MESSAGE("EntityGUI_SketcherDlg::AddLocalCS")
+  QString aName = GEOMBase::GetName( aSelectedObject );
+  
+  int index = ComboBox1->findText(aName, Qt::MatchExactly);
+  
+  if (index==-1)  // If the working plane hasn't been added yet
+  {   
+    myWPlaneList.push_back(aSelectedObject);
+    myWPlane = aSelectedObject;
+    addSubshapesToStudy();
+    myLCSList.push_back(WPlaneToLCS(aSelectedObject));
+    ComboBox1->addItem(aName); 
+    index = ComboBox1->count();
+    ComboBox1->setCurrentIndex(index-1);    
+  }
+  else
+  {
+    ComboBox1->setCurrentIndex(index);
+  }
+  ActivateLocalCS();   
+}
+
 //=================================================================================
 // function : FindLocalCS()
 // purpose  : Find All Coordinates systems in study
 //=================================================================================
 void EntityGUI_SketcherDlg::FindLocalCS()
 {
+  MESSAGE("EntityGUI_SketcherDlg::FindLocalCS")
   ComboBox1->clear();
-  myLCSList.clear();
+  myWPlaneList.clear();
   SalomeApp_Application* app =
     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   if ( !app )
@@ -2478,11 +2497,7 @@ void EntityGUI_SketcherDlg::FindLocalCS()
 
   //add Global CS
   ComboBox1->addItem(tr("GEOM_GCS"));
-  gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
-  gp_Dir aDirZ = gp_Dir(0, 0, 1);
-  gp_Dir aDirX = gp_Dir(1, 0, 0);
-  gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
-  myLCSList.push_back(globalCS);
+  myWPlaneList.push_back(myGlobalCS);
 
   // get GEOM component
   CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
@@ -2497,31 +2512,55 @@ void EntityGUI_SketcherDlg::FindLocalCS()
 
   // browse through all GEOM data tree
   _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
-  for ( it->InitEx( true ); it->More(); it->Next() ) {
+  for ( it->InitEx( true ); it->More(); it->Next() ) 
+  {
     _PTR(SObject) child( it->Value() );
     CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
     if( CORBA::is_nil( geomObj ) ) 
       continue;
-    if (geomObj->GetType() == GEOM_MARKER) {
+    if (geomObj->GetType() == GEOM_MARKER) 
+    {
+      myWPlaneList.push_back(geomObj);
+      myLCSList.push_back(WPlaneToLCS(geomObj));
       ComboBox1->addItem(geomObj->GetName());
-      TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
-      
-      gp_Ax3 aLCS;
-      aLCS.Transform(aShape.Location().Transformation());
-      if (aShape.ShapeType() == TopAbs_FACE) {
-        Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
-        if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
-          Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
-          gp_Pln aPln = aGPlane->Pln();
-          aLCS = aPln.Position();
-        }
-      }
-      myLCSList.push_back(aLCS);
+      MESSAGE("ComboBox1->addItem() in  EntityGUI_SketcherDlg::FindLocalCS()")
+    }
+  }
+}
+
+//=================================================================================
+// function : WPlaneToLCS ( aWPlane )
+// purpose  : 
+//=================================================================================
+gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
+{
+  TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
+  
+  gp_Ax3 aLCS;
+  if (CORBA::is_nil( geomObj ) || aShape.IsNull())
+  {
+    MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
+  }
+  aLCS.Transform(aShape.Location().Transformation());
+  if (aShape.ShapeType() == TopAbs_FACE) 
+  {
+    GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
+    myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
+    double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
+    aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
+    if ( aMeasureOp->IsDone() )
+    {  
+      gp_Pnt aPnt ( Ox, Oy, Oz );
+      gp_Dir aDirN ( Zx, Zy, Zz );
+      gp_Dir aDirX ( Xx, Xy, Xz );
+      aLCS = gp_Ax3( aPnt, aDirN, aDirX );
     }
   }
+  return aLCS;
 }
 
+
 //=================================================================================
 // function : getPnt1ConstructorId()
 // purpose  :
@@ -2550,11 +2589,13 @@ int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
 //=================================================================================
 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
 {
+  MESSAGE("EntityGUI_SketcherDlg::GetActiveLocalCS()")
   int ind = ComboBox1->currentIndex();
   if (ind == -1)
     return myGeometryGUI->GetWorkingPlane();
-
+  
   gp_Ax3 aLCS = myLCSList.at(ind);
+  myWPlane = myWPlaneList.at(ind);
 
   return aLCS;
 }
@@ -2565,6 +2606,17 @@ gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
 //=================================================================================
 void EntityGUI_SketcherDlg::ActivateLocalCS()
 {
-    myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
-    myGeometryGUI->ActiveWorkingPlane();
+  MESSAGE("EntityGUI_SketcherDlg::ActivateLocalCS")
+  myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
+  myGeometryGUI->ActiveWorkingPlane();
 }
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose  : virtual method to add new SubObjects if local selection
+//=================================================================================
+void EntityGUI_SketcherDlg::addSubshapesToStudy()
+{
+  MESSAGE("EntityGUI_SketcherDlg::addSubshapesToStudy()")
+  GEOMBase::PublishSubObject(myWPlane);
+}
\ No newline at end of file
index fd36ce6a9dc38f954250fc80ea7417ed1bb0db06..252127e1ff901aebd523a7aa32b184d2b4ef2d32 100644 (file)
@@ -73,9 +73,8 @@ public:
 
   bool eventFilter (QObject* object, QEvent* event);
   
-  bool                               acceptMouseEvent() const { return ( getPnt1ConstructorId() == 1 
-                                                                      || getPnt1ConstructorId() == 0 );  }   //accept mouse event only on absolute and relative selection mode
-  void                               OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& );                // called by EntityGUI::OnMousePress()
+  bool                               acceptMouseEvent() const;  // called by EntityGUI::OnMousePress()
+  void                               OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& );             
 
 protected:
   void                               initSpinBox( SalomeApp_DoubleSpinBox*, 
@@ -86,7 +85,8 @@ protected:
   virtual GEOM::GEOM_IOperations_ptr createOperation();
   virtual bool                       isValid( QString& );
   virtual bool                       execute( ObjectList& );
-
+  virtual void                       addSubshapesToStudy();
+  
   void                               closeEvent( QCloseEvent* );
   void                               keyPressEvent( QKeyEvent* );
 
@@ -170,6 +170,9 @@ private:
   QGroupBox*                         GroupBox1;
   QComboBox*                         ComboBox1;
   QPushButton*                       planeButton;
+  QPushButton*                       selButton;
+  
+  QLineEdit*                         WPlaneLineEdit;
 
   GeometryGUI*                       myGeometryGUI;
 
@@ -178,6 +181,9 @@ private:
   double                             myLineWidth;
 
   QList<gp_Ax3>                      myLCSList;
+  GEOM::GEOM_Object_var              myGlobalCS;
+  GEOM::GEOM_Object_var              myWPlane;
+  QList< GEOM::GEOM_Object_var >     myWPlaneList;
 
   int                                myCheckFlag;
   
@@ -215,8 +221,10 @@ private slots:
   void                               CheckBoxClicked( int );
   void                               ValueChangedInSpinBox( double );
   void                               SetDoubleSpinBoxStep( double );
+  void                               AddLocalCS( GEOM::GEOM_Object_var );
   void                               FindLocalCS();
   gp_Ax3                             GetActiveLocalCS();
+  gp_Ax3                             WPlaneToLCS( GEOM::GEOM_Object_var );
   void                               ActivateLocalCS();
 };
 
index 95cf241bfe750fa495bdcaa48d51eed7ada8597c..489c064d875a36b28c294570964aabd215462fa5 100644 (file)
             <source>ICO_DELETE</source>
             <translation>delete.png</translation>
         </message>
-       <message>
+        <message>
             <source>ICO_DISK</source>
             <translation>disk.png</translation>
         </message>
             <source>ICO_DISPLAY_ONLY</source>
             <translation>displayonly.png</translation>
         </message>
+        <message>
+            <source>ICO_DRAFT</source>
+            <translation>draft.png</translation>
+        </message>
+        <message>
+            <source>ICO_DISPLAY_ONLY</source>
+            <translation>displayonly.png</translation>
+        </message>
         <message>
             <source>ICO_EDGE</source>
             <translation>build_edge.png</translation>
         <message>
             <source>ICO_EXPLODE_BLOCKS</source>
             <translation>subshape.png</translation>
+        </message>
+         <message>
+            <source>ICO_EXTRUDED_BOSS</source>
+            <translation>extruded_boss.png</translation>
+        </message>
+        <message>
+            <source>ICO_EXTRUDED_CUT</source>
+            <translation>extruded_cut.png</translation>
         </message>
         <message>
             <source>ICO_EXTRUSION</source>
index a993e8be3f785c972e237f03e4074e884a111790..25b1a30d4c6383ff8eaa3485321952739b51a689 100644 (file)
@@ -585,6 +585,19 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_EXTRUSION</source>
         <translation>Extrusion</translation>
     </message>
+    <message>
+        <source>GEOM_EXTRUDED_CUT</source>
+        <translation>Extruded cut</translation>
+    </message>
+    <message>
+        <source>GEOM_EXTRUDED_BOSS</source>
+        <translation>Extruded boss</translation>
+    </message>
+    <message>
+        <source>GEOM_EXTRUSION</source>
+        <translation>Extrusion</translation>
+    </message>
+
     <message>
         <source>GEOM_EXTRUSION_BSV</source>
         <translation>Base Shapes + Vector</translation>
@@ -806,6 +819,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_HOLES</source>
         <translation>Holes</translation>
     </message>
+    <message>
+        <source>GEOM_INIT_SHAPE</source>
+        <translation>Initial shape</translation>
+    </message>
     <message>
         <source>GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE</source>
         <translation>Identical names : select by mouse !</translation>
@@ -1566,6 +1583,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_SHELL_TITLE</source>
         <translation>Shell Construction</translation>
     </message>
+    <message>
+        <source>GEOM_SKETCH</source>
+        <translation>Sketch</translation>
+    </message>
     <message>
         <source>GEOM_SKETCHER_ABS</source>
         <translation>Absolute</translation>
@@ -1726,6 +1747,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_SKETCHER_VXVY</source>
         <translation>VX-VY</translation>
     </message>
+    <message>
+        <source>GEOM_SKETCHER_WPLANE</source>
+        <translation>Select a planar face or a plane</translation>
+    </message>
     <message>
         <source>GEOM_SKETCHER_VY2</source>
         <translation>VY :</translation>
@@ -2370,6 +2395,14 @@ Please, select face, shell or solid and try again</translation>
         <source>MEN_EXTRUSION</source>
         <translation>Extrusion</translation>
     </message>
+    <message>
+        <source>MEN_EXTRUDED_CUT</source>
+        <translation>Extruded cut</translation>
+    </message>
+    <message>
+        <source>MEN_EXTRUDED_BOSS</source>
+        <translation>Extruded boss</translation>
+    </message>
     <message>
         <source>MEN_FACE</source>
         <translation>Face</translation>
index e037eb54ec1d35a359e947784afd4d2ec44b52f9..11bfcf6f1d835276bfefbc517797708fed6f0522 100644 (file)
@@ -1717,6 +1717,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>GEOM_SKETCHER_VXVY</source>
         <translation>VX-VY</translation>
     </message>
+    <message>
+        <source>GEOM_SKETCHER_WPLANE</source>
+        <translation>Sélectionnez une face plane ou un plan</translation>
+    </message>
     <message>
         <source>GEOM_SKETCHER_VY2</source>
         <translation>VY :</translation>
index 674eb2869a32886c6f0a327e5cdbf75808c7a180..eb4aa6d772f0bf039af3e7b294126c7707d9b4f5 100644 (file)
@@ -512,6 +512,8 @@ void GeometryGUI::OnGUIEvent( int id )
   case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
   case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
   case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
+  case GEOMOp::OpExtrudedBoss:       // MENU OPERATION - EXTRUDED BOSS
+  case GEOMOp::OpExtrudedCut:        // MENU OPERATION - EXTRUDED CUT
     libName = "OperationGUI";
     break;
   case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
@@ -785,6 +787,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   //createGeomAction( GEOMOp::OpClipping,        "CLIPPING" );
   createGeomAction( GEOMOp::OpShapesOnShape,  "GET_SHAPES_ON_SHAPE" );
   createGeomAction( GEOMOp::OpSharedShapes,   "GET_SHARED_SHAPES" );
+  createGeomAction( GEOMOp::OpExtrudedCut,    "EXTRUDED_CUT" );
+  createGeomAction( GEOMOp::OpExtrudedBoss,   "EXTRUDED_BOSS" );
   createGeomAction( GEOMOp::OpFillet1d,       "FILLET_1D" );
   createGeomAction( GEOMOp::OpFillet2d,       "FILLET_2D" );
 
@@ -1001,6 +1005,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
   createMenu( GEOMOp::OpChamfer,       operId, -1 );
+  createMenu( GEOMOp::OpExtrudedBoss,  operId, -1 );
+  createMenu( GEOMOp::OpExtrudedCut,   operId, -1 );
   //createMenu( GEOMOp::OpClipping,      operId, -1 );
 
   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
@@ -1076,40 +1082,50 @@ void GeometryGUI::initialize( CAM_Application* app )
 */
 
   // ---- create toolbars --------------------------
-
+  
   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
-  createTool( GEOMOp::OpPoint,   basicTbId );
-  createTool( GEOMOp::OpLine,    basicTbId );
-  createTool( GEOMOp::OpCircle,  basicTbId );
-  createTool( GEOMOp::OpEllipse, basicTbId );
-  createTool( GEOMOp::OpArc,     basicTbId );
-  createTool( GEOMOp::OpCurve,   basicTbId );
-  createTool( GEOMOp::OpVector,  basicTbId );
-  createTool( GEOMOp::OpPlane,   basicTbId );
-  createTool( GEOMOp::OpLCS,     basicTbId );
+  createTool( GEOMOp::OpPoint,      basicTbId );
+  createTool( GEOMOp::OpLine,       basicTbId );
+  createTool( GEOMOp::OpCircle,     basicTbId );
+  createTool( GEOMOp::OpEllipse,    basicTbId );
+  createTool( GEOMOp::OpArc,        basicTbId );
+  createTool( GEOMOp::OpCurve,      basicTbId );
+  createTool( GEOMOp::OpVector,     basicTbId );
+  createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
+  createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
+  createTool( GEOMOp::OpPlane,      basicTbId );
+  createTool( GEOMOp::OpLCS,        basicTbId );
   createTool( GEOMOp::OpOriginAndVectors, basicTbId );
-
+  
+//   int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
+//   createTool( GEOMOp::Op2dSketcher,  sketchTbId );
+//   createTool( GEOMOp::Op3dSketcher,  sketchTbId );
+  
   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
-  createTool( GEOMOp::OpBox,       primTbId );
-  createTool( GEOMOp::OpCylinder,  primTbId );
-  createTool( GEOMOp::OpSphere,    primTbId );
-  createTool( GEOMOp::OpTorus,     primTbId );
-  createTool( GEOMOp::OpCone,      primTbId );
-  createTool( GEOMOp::OpRectangle, primTbId );
-  createTool( GEOMOp::OpDisk,      primTbId );
-
+  createTool( GEOMOp::OpBox,        primTbId );
+  createTool( GEOMOp::OpCylinder,   primTbId );
+  createTool( GEOMOp::OpSphere,     primTbId );
+  createTool( GEOMOp::OpTorus,      primTbId );
+  createTool( GEOMOp::OpCone,       primTbId );
+  createTool( GEOMOp::OpRectangle,  primTbId );
+  createTool( GEOMOp::OpDisk,       primTbId );
+  createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
+  
+//   int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
+//   createTool( GEOMOp::OpPipeTShape, advancedTbId );
+  
   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
-  createTool( GEOMOp::OpFuse,    boolTbId );
-  createTool( GEOMOp::OpCommon,  boolTbId );
-  createTool( GEOMOp::OpCut,     boolTbId );
-  createTool( GEOMOp::OpSection, boolTbId );
-
-  int genTbId = createTool( tr( "TOOL_GENERATION" ) );
+  createTool( GEOMOp::OpFuse,       boolTbId );
+  createTool( GEOMOp::OpCommon,     boolTbId );
+  createTool( GEOMOp::OpCut,        boolTbId );
+  createTool( GEOMOp::OpSection,    boolTbId );
+  
+   int genTbId = createTool( tr( "TOOL_GENERATION" ) );
   createTool( GEOMOp::OpPrism,      genTbId );
   createTool( GEOMOp::OpRevolution, genTbId );
   createTool( GEOMOp::OpFilling,    genTbId );
   createTool( GEOMOp::OpPipe,       genTbId );
-
+  
   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
   createTool( GEOMOp::OpTranslate,      transTbId );
   createTool( GEOMOp::OpRotate,         transTbId );
@@ -1121,29 +1137,22 @@ void GeometryGUI::initialize( CAM_Application* app )
   createTool( separator(),              transTbId );
   createTool( GEOMOp::OpMultiTranslate, transTbId );
   createTool( GEOMOp::OpMultiRotate,    transTbId );
-
+  
   int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
-  createTool( GEOMOp::Op2dSketcher,      operTbId );
-  createTool( GEOMOp::Op3dSketcher,      operTbId );
-  createTool( separator(),               operTbId );
   createTool( GEOMOp::OpExplode,         operTbId );
-  createTool( separator(),               operTbId );
-#ifdef WITH_OPENCV
-  createTool( GEOMOp::OpFeatureDetect,   operTbId );
-#endif
-  createTool( GEOMOp::OpPictureImport,   operTbId );
-  createTool( separator(),               operTbId );
-
   createTool( GEOMOp::OpPartition,       operTbId );
   createTool( GEOMOp::OpArchimede,       operTbId );
   createTool( GEOMOp::OpShapesOnShape,   operTbId );
   createTool( GEOMOp::OpSharedShapes,    operTbId );
-  createTool( separator(),               operTbId );
-  createTool( GEOMOp::OpFillet1d,        operTbId );
-  createTool( GEOMOp::OpFillet2d,        operTbId );
-  createTool( GEOMOp::OpFillet3d,        operTbId );
-  createTool( GEOMOp::OpChamfer,         operTbId );
-
+  
+  int featTbId = createTool( tr( "TOOL_FEATURES" ) );
+  createTool( GEOMOp::OpFillet1d,        featTbId );
+  createTool( GEOMOp::OpFillet2d,        featTbId );
+  createTool( GEOMOp::OpFillet3d,        featTbId );
+  createTool( GEOMOp::OpChamfer,         featTbId );
+  createTool( GEOMOp::OpExtrudedBoss,    featTbId );
+  createTool( GEOMOp::OpExtrudedCut,     featTbId );
+  
   int buildTbId = createTool( tr( "TOOL_BUILD" ) );
   createTool( GEOMOp::OpEdge,     buildTbId );
   createTool( GEOMOp::OpWire,     buildTbId );
@@ -1171,9 +1180,13 @@ void GeometryGUI::initialize( CAM_Application* app )
   createTool( GEOMOp::OpCheckShape,       measureTbId );
   createTool( GEOMOp::OpCheckCompound,    measureTbId );
   createTool( GEOMOp::OpCheckSelfInters,  measureTbId );
+  
+  int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
+  createTool( GEOMOp::OpPictureImport,    picturesTbId );
+  #ifdef WITH_OPENCV
+    createTool( GEOMOp::OpFeatureDetect,  picturesTbId );
+  #endif
 
-  int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
-  createTool( GEOMOp::OpPipeTShape, advancedTbId );
   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
 
   // ---- create popup menus --------------------------
index 227c23283b72480cee4b006fa017bd257728d283..a4ad5eadfd034fafb60061e032aac68e006f55da 100644 (file)
@@ -136,6 +136,8 @@ namespace GEOMOp {
     OpFillet1d            = 3706,   // MENU OPERATION - FILLET 1D
     OpClipping            = 3707,   // MENU OPERATION - CLIPPING RANGE
     OpSharedShapes        = 3708,   // MENU OPERATION - GET SHARED SHAPES
+    OpExtrudedBoss        = 3709,   // MENU OPERATION - ETRUDED BOSS
+    OpExtrudedCut         = 3710,   // MENU OPERATION - ETRUDED CUT
     // RepairGUI -----------------//--------------------------------
     OpSewing              = 4000,   // MENU REPAIR - SEWING
     OpSuppressFaces       = 4001,   // MENU REPAIR - SUPPRESS FACES
index 4a69c1be98da776f5ea9c003a977ed29a2145c0a..76962b98879182ce76db5fd8324549fcb3ed839b 100644 (file)
@@ -1293,6 +1293,88 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
   return aPrism;
 }
 
+//=============================================================================
+/*!
+ *  MakeDraftPrism
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
+       (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
+{
+  SetErrorCode(KO);
+
+  if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
+
+  Handle(GEOM_Object) aPrism = NULL;
+  
+  if ( theFuse )
+  {
+    //Add a new Extruded Boss object  
+    aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
+  }
+  else
+  { 
+    //Add a new Extruded Cut object  
+    aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
+  }
+  
+  //Add a new Prism function for the creation of a Draft Prism feature
+  Handle(GEOM_Function) aFunction = 
+    aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
+  if (aFunction.IsNull()) return NULL;
+  
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
+  
+  GEOMImpl_IPrism aCI (aFunction);
+
+  Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
+  Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
+  if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
+  
+  // Set parameters 
+  aCI.SetBase(aRefBase);
+  aCI.SetInitShape(aRefInit);
+  aCI.SetH(theHeight);
+  aCI.SetDraftAngle(theAngle);
+  if ( theFuse )
+    aCI.SetFuseFlag(1);
+  else
+    aCI.SetFuseFlag(0);
+  
+  //Compute the Draft Prism Feature value
+  try {
+#if OCC_VERSION_LARGE > 0x06010000
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Extrusion can not be created, check input data");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+  
+  //Make a Python command
+  if(theFuse)
+  {
+    GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
+      << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
+  }
+  else
+  {   
+    GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
+      << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
+  }
+
+  SetErrorCode(OK);
+  return aPrism;
+}
+
 //=============================================================================
 /*!
  *  MakePipe
index b0818cbe1cbd3b7578b130fe49934698ee82b8f0..dd066a215e19c6dbbea07c8d0df6f65b9afff575 100644 (file)
@@ -89,7 +89,10 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
 
   Standard_EXPORT Handle(GEOM_Object) MakePrismDXDYDZ2Ways (Handle(GEOM_Object) theBase,
                                                             double theDX, double theDY, double theDZ);
-
+  
+  Standard_EXPORT Handle(GEOM_Object) MakeDraftPrism  (Handle(GEOM_Object) theInitShape, Handle(GEOM_Object) theBase,
+                                                       double theHeight, double theAngle, bool theFuse);
+  
   Standard_EXPORT Handle(GEOM_Object) MakePipe (Handle(GEOM_Object) theBase,
                                                 Handle(GEOM_Object) thePath);
 
index 63319a1ec1795519882faae0cc6272700dfb26c3..fafa695141f3835c5e5fc764f6a52e612ecc0f79 100644 (file)
 //NOTE: This is an intreface to a function for the Prism creation.
 
 #include "GEOM_Function.hxx"
+// #include <GEOMImpl_Mode.hxx>  TEST
 
-#define PRISM_ARG_H     1
-#define PRISM_ARG_VEC   2
-#define PRISM_ARG_BASE  3
-#define PRISM_ARG_PNT_F 4
-#define PRISM_ARG_PNT_L 5
-#define PRISM_ARG_DX    6
-#define PRISM_ARG_DY    7
-#define PRISM_ARG_DZ    8
-#define PRISM_ARG_SCALE 9
+#define PRISM_ARG_H        1
+#define PRISM_ARG_VEC      2
+#define PRISM_ARG_BASE     3
+#define PRISM_ARG_PNT_F    4
+#define PRISM_ARG_PNT_L    5
+#define PRISM_ARG_DX       6
+#define PRISM_ARG_DY       7
+#define PRISM_ARG_DZ       8
+#define PRISM_ARG_SCALE    9
+#define PRISM_ARG_DRAFT    10
+#define PRISM_ARG_FUSE     11
+#define PRISM_ARG_INIT     12
+#define PRISM_ARG_MODE     13
 
 class GEOMImpl_IPrism
 {
@@ -40,15 +45,17 @@ class GEOMImpl_IPrism
 
   GEOMImpl_IPrism(Handle(GEOM_Function) theFunction): _func(theFunction) {}
 
-  void SetBase  (Handle(GEOM_Function) theRefBase  ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); }
-  void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(PRISM_ARG_VEC , theRefVector); }
-  void SetFirstPoint(Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_F, thePoint); }
-  void SetLastPoint (Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_L, thePoint); }
+  void SetBase  (Handle(GEOM_Function) theRefBase      ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); }
+  void SetVector(Handle(GEOM_Function) theRefVector    ) { _func->SetReference(PRISM_ARG_VEC , theRefVector); }
+  void SetFirstPoint(Handle(GEOM_Function) thePoint    ) { _func->SetReference(PRISM_ARG_PNT_F, thePoint); }
+  void SetLastPoint (Handle(GEOM_Function) thePoint    ) { _func->SetReference(PRISM_ARG_PNT_L, thePoint); }
+  void SetInitShape (Handle(GEOM_Function) theInitShape) { _func->SetReference(PRISM_ARG_INIT,  theInitShape); }
 
   Handle(GEOM_Function) GetBase  () { return _func->GetReference(PRISM_ARG_BASE); }
   Handle(GEOM_Function) GetVector() { return _func->GetReference(PRISM_ARG_VEC ); }
   Handle(GEOM_Function) GetFirstPoint() { return _func->GetReference(PRISM_ARG_PNT_F ); }
   Handle(GEOM_Function) GetLastPoint () { return _func->GetReference(PRISM_ARG_PNT_L ); }
+  Handle(GEOM_Function) GetInitShape () { return _func->GetReference(PRISM_ARG_INIT  ); }
 
   void SetDX(double theDX) { _func->SetReal(PRISM_ARG_DX, theDX); }
   void SetDY(double theDY) { _func->SetReal(PRISM_ARG_DY, theDY); }
@@ -58,13 +65,19 @@ class GEOMImpl_IPrism
   double GetDY() { return _func->GetReal(PRISM_ARG_DY); }
   double GetDZ() { return _func->GetReal(PRISM_ARG_DZ); }
 
-  void SetH(double theH) { _func->SetReal(PRISM_ARG_H, theH); }
-
-  double GetH() { return _func->GetReal(PRISM_ARG_H); }
-
-  void SetScale(double theH) { _func->SetReal(PRISM_ARG_SCALE, theH); }
+  void SetH         (double theH    ) { _func->SetReal(PRISM_ARG_H, theH); }
+  void SetScale     (double theH    ) { _func->SetReal(PRISM_ARG_SCALE, theH); }
+  void SetDraftAngle(double theAngle) { _func->SetReal(PRISM_ARG_DRAFT, theAngle); }
 
+  double GetH()          { return _func->GetReal(PRISM_ARG_H); }
   double GetScale() { return _func->GetReal(PRISM_ARG_SCALE); }
+  double GetDraftAngle() { return _func->GetReal(PRISM_ARG_DRAFT); }
+  
+  void SetFuseFlag(int theFlag) { _func->SetInteger(PRISM_ARG_FUSE, theFlag); }
+//   void SetMode(GEOMImpl_Mode theMode) { _func->SetInteger(PRISM_ARG_MODE, theMode); }  //TEST
+
+  int  GetFuseFlag()      { return _func->GetInteger(PRISM_ARG_FUSE); }
+//   GEOMImpl_Mode GetMode() { return _func->GetInteger(PRISM_ARG_MODE); }   //TEST
 
  private:
 
index a477dc2eb8f5886758e48e3fda95e0c1c3f04aea..6387f7df903ee2d36dd3b687bad5bfa66320b38e 100644 (file)
 #include <GEOM_Function.hxx>
 
 #include <BRepPrimAPI_MakePrism.hxx>
+#include <BRepFeat_MakeDPrism.hxx>
 
 #include <BRep_Builder.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepBuilderAPI_MakeVertex.hxx>
 #include <BRepBuilderAPI_Sewing.hxx>
 #include <BRepBuilderAPI_Transform.hxx>
 #include <BRepCheck_Shell.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
 #include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
 
 #include <TopAbs.hxx>
 #include <TopExp.hxx>
@@ -65,6 +68,8 @@
 
 #include <Standard_ConstructionError.hxx>
 
+#include "utilities.h"
+
 //=======================================================================
 //function : GetID
 //purpose  :
@@ -180,11 +185,143 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
       }
     }
   }
+  
+  else if (aType == DRAFT_PRISM_FEATURE) {
+    Handle(GEOM_Function) aRefInit = aCI.GetInitShape();
+    Handle(GEOM_Function) aRefBase = aCI.GetBase();   
+    TopoDS_Shape anInitShape = aRefInit->GetValue();        // Initial shape
+    TopoDS_Shape aSketch     = aRefBase->GetValue();  
+    Standard_Real aHeight    = aCI.GetH();                  // Height of the extrusion
+    Standard_Real anAngle    = aCI.GetDraftAngle();         // Draft angle
+    Standard_Boolean isProtrusion = (aCI.GetFuseFlag()==1); 
+    // Flag to know wether the feature is a protrusion (fuse) or a depression (cut)
+    
+    if (anInitShape.ShapeType() == TopAbs_COMPOUND)
+    {
+      TopExp_Explorer anExp(anInitShape, TopAbs_SOLID);
+      int solidCount = 0;
+      for(;anExp.More();anExp.Next())
+      {
+        solidCount++;
+      }
+      if (solidCount == 0)
+      {
+        Standard_ConstructionError::Raise("The input shape is a compound without any solid");
+      }
+      else if (solidCount > 1)
+      {
+        Standard_ConstructionError::Raise("The input shape is a compound with more than one solid");
+      }
+    }
+     
+    TopoDS_Wire aWire = TopoDS_Wire();
+    
+    if (aSketch.ShapeType() == TopAbs_EDGE)
+    {
+      aWire = BRepBuilderAPI_MakeWire(TopoDS::Edge(aSketch));
+    }
+    else if (aSketch.ShapeType() == TopAbs_WIRE)
+    {
+      aWire = TopoDS::Wire(aSketch);
+    }
+    else
+    {
+      Standard_ConstructionError::Raise("The input sketch is neither a wire nor an edge");
+    }
+    
+    if (!aWire.Closed())
+      Standard_ConstructionError::Raise("The wire has to be closed");
+       
+    // history of the Base wire (RefBase)
+    Handle(GEOM_Object) aSuppObj;
+    TDF_LabelSequence aLabelSeq;
+    aRefBase->GetDependency(aLabelSeq);
+    
+    // If the base wire has only one dependency we use it
+    // to determine the right normal of the face which
+    // must be oriented towards outside of the solid (like the support face)
+    if (aLabelSeq.Length()==1)  
+    {
+      TDF_Label anArgumentRefLabel = aLabelSeq.Value(1);
+      aSuppObj = GEOM_Object::GetReferencedObject(anArgumentRefLabel);   
+    }
+    
+    // Construction of the face if the wire hasn't any support face
+    TopoDS_Face aFaceBase = BRepBuilderAPI_MakeFace(aWire);
+    if(!aSuppObj.IsNull())      // If the wire has a support
+    {
+      TopoDS_Shape aSupport = aSuppObj->GetValue();
+      if (aSupport.ShapeType() == TopAbs_FACE)
+      {
+        Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aSupport));
+        TopoDS_Face aTempFace = BRepBuilderAPI_MakeFace(aSurf, aWire);
+        
+        if(aTempFace.Orientation() != TopoDS::Face(aSupport).Orientation())
+        {
+          aFaceBase=TopoDS::Face(aTempFace.Reversed());
+        }
+        else
+          aFaceBase=aTempFace;
+      }
+    }
+    
+    // Invert height and angle if the operation is an extruded cut
+    bool invert = !isProtrusion; 
+    
+    // If the face has a reverse orientation invert for extruded boss operations
+    if(aFaceBase.Orientation() == TopAbs_REVERSED)
+      invert = isProtrusion;
+
+    if(invert)
+    {
+      anAngle = -anAngle;  // Invert angle and height
+      aHeight = -aHeight;
+    }
+    
+    BRepFeat_MakeDPrism thePrism(anInitShape, aFaceBase, TopoDS_Face(),
+                                 anAngle*PI180, isProtrusion, Standard_True); 
+    
+    thePrism.Perform(aHeight);
+    
+    aShape = thePrism.Shape();
+  }
 
   if (aShape.IsNull()) return 0;
-
-  TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
-  aFunction->SetValue(aRes);
+  
+  
+  if (aType == DRAFT_PRISM_FEATURE)
+  {
+    TopoDS_Shape aRes = aShape;
+    
+    // If the result is a compound with only one solid,
+    // return the solid
+    if (aShape.ShapeType() == TopAbs_COMPOUND)  
+    {
+      TopExp_Explorer anExp(aShape, TopAbs_SOLID);
+      
+      int solidNb = 0;
+      TopoDS_Solid aSolid;
+      
+      for(;anExp.More();anExp.Next())
+      {
+        aSolid = TopoDS::Solid(anExp.Current());
+        solidNb++;
+      }
+      if (solidNb == 1)
+      {
+        aRes = aSolid;
+      } 
+    } 
+    
+    aFunction->SetValue(aRes);
+  }
+  else
+  {
+    TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+    aFunction->SetValue(aRes);
+  }
+  
 
   log.SetTouched(Label());
 
index 9359db7a35dc738ee2659d86418fcd9c85a8483a..6b61e88990b82f78bed5d17229326383ac6b8661 100755 (executable)
 
 #define GEOM_PROJECTION 45
 
+#define GEOM_EXTRUDED_CUT 46
+
+#define GEOM_EXTRUDED_BOSS 47
+
 //GEOM_Function types
 
 #define COPY_WITH_REF    1
 #define PRISM_BASE_TWO_PNT_2WAYS 4
 #define PRISM_BASE_DXDYDZ        5
 #define PRISM_BASE_DXDYDZ_2WAYS  6
+#define DRAFT_PRISM_FEATURE      7
 
 #define REVOLUTION_BASE_AXIS_ANGLE       1
 #define REVOLUTION_BASE_AXIS_ANGLE_2WAYS 2
index d8fd0a7fa004365f2609efa7892f2d24a47bb67d..2175cc50d80f37526b48fa3c3f18355d9e4eceaf 100644 (file)
@@ -705,6 +705,37 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZWithScaling
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  MakeDraftPrism
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDraftPrism
+                      (GEOM::GEOM_Object_ptr theInitShape, GEOM::GEOM_Object_ptr theBase, 
+                       CORBA::Double  theHeight,
+                       CORBA::Double  theAngle,
+                       CORBA::Boolean theFuse)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+  
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(GEOM_Object) aInit   = GetObjectImpl(theInitShape);
+  Handle(GEOM_Object) aBase   = GetObjectImpl(theBase);
+
+  if (aBase.IsNull() || aInit.IsNull()) return aGEOMObject._retn();
+
+  //Create the Prism
+  Handle(GEOM_Object) anObject = GetOperations()->MakeDraftPrism(aInit, aBase, theHeight, theAngle, theFuse);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  MakePipe
index 0890e3de688cba1749340590d4bdf6c9c203f4a2..3b64361d8f23f66c27ac25bb0c7a46b5996fe9ab 100644 (file)
@@ -138,7 +138,13 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i :
                                                     CORBA::Double         theDY,
                                                     CORBA::Double         theDZ,
                                                     CORBA::Double         theScaleFactor);
-
+  
+  GEOM::GEOM_Object_ptr MakeDraftPrism (GEOM::GEOM_Object_ptr theInitShape,
+                                        GEOM::GEOM_Object_ptr theBase,
+                                        CORBA::Double         theHeight,
+                                        CORBA::Double         theAngle,
+                                        CORBA::Boolean        theFuse);
+                            
   GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase,
                                  GEOM::GEOM_Object_ptr thePath);
 
index 31cc2471086e5063e64028bff03ac52adbb16e91..dbf18eb980151e6511aed883712aecb4508b6217 100644 (file)
@@ -63,7 +63,7 @@
 ##     @defgroup l3_basic_op      Basic Operations
 ##     @defgroup l3_boolean       Boolean Operations
 ##     @defgroup l3_transform     Transformation Operations
-##     @defgroup l3_local         Local Operations (Fillet and Chamfer)
+##     @defgroup l3_local         Local Operations (Fillet, Chamfer and other Features)
 ##     @defgroup l3_blocks_op     Blocks Operations
 ##     @defgroup l3_healing       Repairing Operations
 ##     @defgroup l3_restore_ss    Restore presentation parameters and a tree of sub-shapes
@@ -6222,6 +6222,64 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             else:
                 anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape)
             return anObj
+            
+        ## Remove material from a solid by extrusion of the base shape on the given distance.
+        #  @param theInit Shape to remove material from. It must be a solid or 
+        #  a compound made of a single solid.
+        #  @param theBase Closed edge or wire defining the base shape to be extruded.
+        #  @param theH Prism dimension along the normal to theBase
+        #  @param theAngle Draft angle in degrees.
+        #  @return New GEOM.GEOM_Object, containing the initial shape with removed material 
+        #
+        #  @ref tui_creation_prism "Example"
+        def MakeExtrudedCut(self, theInit, theBase, theH, theAngle):
+            """
+            Add material to a solid by extrusion of the base shape on the given distance.
+
+            Parameters:
+                theInit Shape to remove material from. It must be a solid or a compound made of a single solid.
+                theBase Closed edge or wire defining the base shape to be extruded.
+                theH Prism dimension along the normal  to theBase
+                theAngle Draft angle in degrees.
+
+            Returns:
+                New GEOM.GEOM_Object,  containing the initial shape with removed material.
+            """
+            # Example: see GEOM_TestAll.py
+            #theH,Parameters = ParseParameters(theH)
+            anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, False)
+            RaiseIfFailed("MakeExtrudedBoss", self.PrimOp)
+            #anObj.SetParameters(Parameters)
+            return anObj   
+            
+        ## Add material to a solid by extrusion of the base shape on the given distance.
+        #  @param theInit Shape to add material to. It must be a solid or 
+        #  a compound made of a single solid.
+        #  @param theBase Closed edge or wire defining the base shape to be extruded.
+        #  @param theH Prism dimension along the normal to theBase
+        #  @param theAngle Draft angle in degrees.
+        #  @return New GEOM.GEOM_Object, containing the initial shape with added material 
+        #
+        #  @ref tui_creation_prism "Example"
+        def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle):
+            """
+            Add material to a solid by extrusion of the base shape on the given distance.
+
+            Parameters:
+                theInit Shape to add material to. It must be a solid or a compound made of a single solid.
+                theBase Closed edge or wire defining the base shape to be extruded.
+                theH Prism dimension along the normal  to theBase
+                theAngle Draft angle in degrees.
+
+            Returns:
+                New GEOM.GEOM_Object,  containing the initial shape with added material.
+            """
+            # Example: see GEOM_TestAll.py
+            #theH,Parameters = ParseParameters(theH)
+            anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, True)
+            RaiseIfFailed("MakeExtrudedBoss", self.PrimOp)
+            #anObj.SetParameters(Parameters)
+            return anObj   
 
         # end of l3_local
         ## @}
index e5f3a27d8a3c6e64f53c1287f13a95120f944aca..a833735b03cd31aeb9d0a39480fef69518c9c5ec 100644 (file)
@@ -32,6 +32,7 @@ salomeinclude_HEADERS =                               \
        OperationGUI_ChamferDlg.h               \
        OperationGUI_GetShapesOnShapeDlg.h      \
        OperationGUI_GetSharedShapesDlg.h       \
+       OperationGUI_ExtrudedFeatureDlg.h       \
        OperationGUI_ClippingDlg.h
 
 # Libraries targets
@@ -46,6 +47,7 @@ dist_libOperationGUI_la_SOURCES =             \
        OperationGUI_FilletDlg.cxx              \
        OperationGUI_Fillet1d2dDlg.cxx          \
        OperationGUI_ChamferDlg.cxx             \
+       OperationGUI_ExtrudedFeatureDlg.cxx     \
        OperationGUI_ClippingDlg.cxx
 
 MOC_FILES =                                    \
@@ -56,6 +58,7 @@ MOC_FILES =                                   \
        OperationGUI_FilletDlg_moc.cxx          \
        OperationGUI_Fillet1d2dDlg_moc.cxx      \
        OperationGUI_ChamferDlg_moc.cxx         \
+       OperationGUI_ExtrudedFeatureDlg_moc.cxx \
        OperationGUI_ClippingDlg_moc.cxx
 
 nodist_libOperationGUI_la_SOURCES =            \
@@ -81,6 +84,7 @@ libOperationGUI_la_CPPFLAGS =         \
        -I$(srcdir)/../GEOMClient       \
        -I$(srcdir)/../GEOMImpl         \
        -I$(srcdir)/../GEOMAlgo         \
+       -I$(srcdir)/../GEOM             \
        -I$(top_builddir)/src/DlgRef    \
        -I$(top_builddir)/idl
 
index d70e3b26d963a712109d022cb264dfe12cd87db2..7c8ed82de9d1dca3943a22c4fdfd33a81e537a50 100644 (file)
@@ -43,6 +43,7 @@
 #include "OperationGUI_ClippingDlg.h"    // Clipping dialog box
 #include "OperationGUI_GetShapesOnShapeDlg.h"
 #include "OperationGUI_GetSharedShapesDlg.h"
+#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT
 
 //=======================================================================
 // function : OperationGUI()
@@ -81,6 +82,8 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpClipping:      (new OperationGUI_ClippingDlg        (getGeometryGUI(), parent))->show(); break;
   case GEOMOp::OpShapesOnShape: (new OperationGUI_GetShapesOnShapeDlg(getGeometryGUI(), parent))->show(); break;
   case GEOMOp::OpSharedShapes:  (new OperationGUI_GetSharedShapesDlg (getGeometryGUI(), parent))->show(); break;
+  case GEOMOp::OpExtrudedBoss:  (new OperationGUI_ExtrudedFeatureDlg (BOSS, getGeometryGUI(), parent))->show(); break;
+  case GEOMOp::OpExtrudedCut:   (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break;
   case GEOMOp::OpFillet1d:      (new OperationGUI_Fillet1d2dDlg      (getGeometryGUI(), parent, true))->show(); break;
   case GEOMOp::OpFillet2d:      (new OperationGUI_Fillet1d2dDlg      (getGeometryGUI(), parent, false))->show(); break;
   default:
index 311485da404e7bebc962430495962cd15886f3b8..a35882e24ca2c4f215a0457d00bbabbb95da487d 100644 (file)
@@ -36,6 +36,8 @@
 class OperationGUI : public GEOMGUI
 {
 public :
+  enum ExtrudedFeatOperation { CUT = 1, BOSS = 2 };
+  
   OperationGUI( GeometryGUI* );
   ~OperationGUI();
 
diff --git a/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx b/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.cxx
new file mode 100644 (file)
index 0000000..b9f0bb8
--- /dev/null
@@ -0,0 +1,382 @@
+// Copyright (C) 2007-2011  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
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : OperationGUI_ExtrudedFeatureDlg.cxx
+//  Author : Renaud NEDELEC, Open CASCADE S.A.S.
+
+#include "OperationGUI.h"
+#include "OperationGUI_ExtrudedFeatureDlg.h"
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <DlgRef.h>
+#include <GEOM_Object.hxx>
+
+// OCCT Includes
+// #include <TopoDS_Shape.hxx>
+// #include <TopoDS_Edge.hxx>
+// #include <TopoDS.hxx>
+// #include <TopExp.hxx>
+// #include <TColStd_IndexedMapOfInteger.hxx>
+// #include <TopTools_IndexedMapOfShape.hxx>
+// #include <Precision.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include <GEOMImpl_Types.hxx>
+
+//=================================================================================
+// class    : OperationGUI_ExtrudedFeatureDlg()
+// purpose  : Constructs a OperationGUI_ExtrudedCutDlg which is a child of 'parent',
+//            with the name 'name' and widget flags set to 'f'.
+//            The dialog will by default be modeless, unless you set 'modal' to
+//            TRUE to construct a modal dialog.
+//=================================================================================
+
+OperationGUI_ExtrudedFeatureDlg::OperationGUI_ExtrudedFeatureDlg(const int theOperation,
+                                                                 GeometryGUI* theGeometryGUI,
+                                                                 QWidget* parent,bool modal, 
+                                                                 Qt::WindowFlags fl)
+  : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+    myOperation(theOperation)
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap image0;
+  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+  QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICO_DRAFT")));
+  QString aTitle;
+  switch (myOperation) 
+  {
+    case OperationGUI::BOSS:
+      image0 = QPixmap(aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_BOSS")));
+      aTitle = tr("GEOM_EXTRUDED_BOSS");
+      break;
+    case OperationGUI::CUT:
+      image0 = QPixmap( aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_CUT")));
+      aTitle = tr("GEOM_EXTRUDED_CUT");
+      break;
+  }
+    
+  setWindowTitle(aTitle);
+  mainFrame()->GroupConstructors->setTitle(aTitle);
+  mainFrame()->RadioButton1->setIcon(image0);
+  mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+  mainFrame()->RadioButton3->close();
+  
+  mainFrame()->RadioButton1->setChecked(true);
+  
+  myGroup = new DlgRef_2Sel2Spin1Push(centralWidget());
+  myGroup->PushButton1->setIcon(image1);
+  myGroup->PushButton2->setIcon(image1);
+  myGroup->PushButton3->setIcon(image2);
+  myGroup->LineEdit1->setReadOnly(true);
+  myGroup->LineEdit2->setReadOnly(true);
+  myGroup->TextLabel1->setText(tr("GEOM_INIT_SHAPE"));
+  myGroup->TextLabel2->setText(tr("GEOM_SKETCH"));
+  myGroup->TextLabel3->setText(tr("GEOM_HEIGHT"));
+  
+  QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+  layout->setMargin(0); 
+  layout->setSpacing(6);
+  layout->addWidget(myGroup);
+
+  Init();
+   
+}
+
+//=================================================================================
+// function : ~OperationGUI_ExtrudedFeatureDlg()
+// purpose  : Destroys the object and frees any allocated resources
+//=================================================================================
+OperationGUI_ExtrudedFeatureDlg::~OperationGUI_ExtrudedFeatureDlg()
+{
+}
+
+//=================================================================================
+// function : Init()
+// purpose  :
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::Init()
+{
+  // init variables
+  myEditCurrentArgument = myGroup->LineEdit1;
+  
+  // Get setting of step value from file configuration
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
+  
+  initSpinBox(myGroup->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox(myGroup->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+
+  myGroup->LineEdit1->setText("");
+  myGroup->LineEdit2->setText("");
+  myGroup->SpinBox_DX->setValue(10.0);
+  myGroup->SpinBox_DY->setValue(10.0);
+  myGroup->SpinBox_DY->setEnabled(false);
+  myObject1.nullify();
+  myObject2.nullify();
+  
+  // signals and slots connections
+  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+  connect(myGroup->PushButton1, SIGNAL(clicked()),     this, SLOT(SetEditCurrentArgument()));
+  connect(myGroup->PushButton2, SIGNAL(clicked()),     this, SLOT(SetEditCurrentArgument()));
+  connect(myGroup->PushButton3, SIGNAL(clicked(bool)), this, SLOT(ButtonClicked(bool)));
+  connect(myGroup->SpinBox_DX,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
+  connect(myGroup->SpinBox_DY,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
+  
+
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+           SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  
+  initName(mainFrame()->GroupConstructors->title());
+  
+  mainFrame()->RadioButton1->setFocus();
+  
+  globalSelection(GEOM_ALLSHAPES); //TODO à changer
+  
+  myGroup->PushButton1->click();
+  SelectionIntoArgument();
+  
+  resize(minimumSizeHint());
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose  :
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::ClickOnOk()
+{
+  setIsApplyAndClose( true );
+  if (ClickOnApply())
+    ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool OperationGUI_ExtrudedFeatureDlg::ClickOnApply()
+{
+  if (!onAccept())
+    return false;
+
+  initName();
+  // activate selection and connect selection manager
+  myGroup->PushButton1->click();
+  return true;
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose  :
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::SetEditCurrentArgument()
+{
+  QPushButton* send = (QPushButton*)sender();
+
+  if (send == myGroup->PushButton1) {
+    myEditCurrentArgument = myGroup->LineEdit1;
+
+    myGroup->PushButton2->setDown(false);
+    myGroup->LineEdit2->setEnabled(false);
+  }
+  else if (send == myGroup->PushButton2) {
+    myEditCurrentArgument = myGroup->LineEdit2;
+
+    myGroup->PushButton1->setDown(false);
+    myGroup->LineEdit1->setEnabled(false);
+  }
+
+  // enable line edit
+  myEditCurrentArgument->setEnabled(true);
+  myEditCurrentArgument->setFocus();
+  // after setFocus(), because it will be setDown(false) when loses focus
+  send->setDown(true);
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose  : Called when selection is changed or on dialog initialization or activation
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::SelectionIntoArgument()
+{
+  myEditCurrentArgument->setText("");
+
+  QList<TopAbs_ShapeEnum> types;
+  types<<TopAbs_SHAPE;
+  
+  if (myEditCurrentArgument == myGroup->LineEdit1)
+  {
+    types.clear();
+    types<<TopAbs_COMPOUND<<TopAbs_SOLID;
+  }
+  if (myEditCurrentArgument == myGroup->LineEdit2)
+  {
+    types.clear();
+    types << TopAbs_EDGE << TopAbs_WIRE;
+  }
+
+  GEOM::GeomObjPtr aSelectedObject = getSelected( types );
+  TopoDS_Shape aShape;
+  if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+    QString aName = GEOMBase::GetName( aSelectedObject.get() );
+    myEditCurrentArgument->setText( aName );
+
+    // clear selection
+    disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+    myGeomGUI->getApp()->selectionMgr()->clearSelected();
+    connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+            this, SLOT(SelectionIntoArgument()));
+
+    if (myEditCurrentArgument == myGroup->LineEdit1) {
+      myObject1 = aSelectedObject;
+      if (!myObject2)
+        myGroup->PushButton2->click();
+    }
+    else if (myEditCurrentArgument == myGroup->LineEdit2) {
+      myObject2 = aSelectedObject;
+      if (!myObject1)
+        myGroup->PushButton1->click();
+    }
+    
+    displayPreview(true);
+  }
+  else {
+    if      (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
+    else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
+  }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose  :
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::ActivateThisDialog()
+{
+  GEOMBase_Skeleton::ActivateThisDialog();
+
+  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+           this, SLOT( SelectionIntoArgument() ) );
+  processPreview();
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose  : when mouse enter onto the QWidget
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::enterEvent (QEvent*)
+{
+  if (!mainFrame()->GroupConstructors->isEnabled())
+    ActivateThisDialog();
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose  :
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::ValueChangedInSpinBox()
+{
+  displayPreview(true);
+}
+
+//=================================================================================
+// function : ButtonClicked(bool checked)
+// purpose  :
+//=================================================================================
+void OperationGUI_ExtrudedFeatureDlg::ButtonClicked(bool checked)
+{
+  myGroup->SpinBox_DY->setEnabled(checked);
+  displayPreview(true);
+}
+
+//=================================================================================
+// function : createOperation
+// purpose  :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr OperationGUI_ExtrudedFeatureDlg::createOperation()
+{
+  return getGeomEngine()->GetI3DPrimOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose  :
+//=================================================================================
+bool OperationGUI_ExtrudedFeatureDlg::isValid (QString&)
+{
+  return myObject1 && myObject2; 
+}
+
+//=================================================================================
+// function : execute
+// purpose  :
+//=================================================================================
+bool OperationGUI_ExtrudedFeatureDlg::execute (ObjectList& objects)
+{
+//   GEOM::GEOM_Object_var anObj;
+
+  GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
+  
+  double angle=0.0;
+  if (myGroup->PushButton3->isChecked())
+    angle=myGroup->SpinBox_DY->value();
+    
+  bool isProtrusion = (myOperation == OperationGUI::BOSS);  
+  
+  GEOM::GEOM_Object_var anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(), 
+                                                       myGroup->SpinBox_DX->value(),
+                                                       angle,
+                                                       isProtrusion);
+//    switch (myOperation) 
+//   {
+//     case OperationGUI::BOSS:
+//       anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, true);
+//       break;
+//     case OperationGUI::CUT:
+//       anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, false);
+//       break;
+//   }
+  if (!anObj->_is_nil())
+    objects.push_back(anObj._retn());
+
+  return true;
+}
+
+
+
+
+  
+
+     
\ No newline at end of file
diff --git a/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h b/src/OperationGUI/OperationGUI_ExtrudedFeatureDlg.h
new file mode 100644 (file)
index 0000000..052c690
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2007-2011  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
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : OperationGUI_ExtrudedFeatureDlg.h
+//  Author : Renaud NEDELEC, Open CASCADE S.A.S.
+
+#ifndef BASICGUI_EXTRUDEDFEATUREDLG_H
+#define BASICGUI_EXTRUDEDFEATUREDLG_H
+
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
+#include <QMap>
+
+// class DlgRef_2Sel1Spin;
+// class DlgRef_3Spin;
+// class DlgRef_2Sel;
+// class DlgRef_1Sel3Spin;
+// class DlgRef_1Sel2Spin;
+class DlgRef_2Sel2Spin1Push;
+
+// class QLineEdit;
+// class QGroupBox;
+// class QButtonGroup;
+// class QMenu;
+class QAction;
+
+//=================================================================================
+// class    : OperationGUI_ExtrudedFeatureDlg
+// purpose  :
+//=================================================================================
+class OperationGUI_ExtrudedFeatureDlg : public GEOMBase_Skeleton
+{ 
+  Q_OBJECT
+
+public:
+  OperationGUI_ExtrudedFeatureDlg( const int, GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
+  ~OperationGUI_ExtrudedFeatureDlg();
+  
+protected:
+  // redefined from GEOMBase_Helper
+  virtual GEOM::GEOM_IOperations_ptr createOperation();
+  virtual bool                       isValid( QString& );
+  virtual bool                       execute( ObjectList& ); 
+  
+private:
+  void                        Init();
+  void                        enterEvent( QEvent* );
+  
+private:
+  int                         myOperation;
+  
+  GEOM::GeomObjPtr            myObject1;
+  GEOM::GeomObjPtr            myObject2;
+  
+  DlgRef_2Sel2Spin1Push*      myGroup;
+  
+private slots:
+  void                        ClickOnOk();
+  bool                        ClickOnApply();
+  void                        ActivateThisDialog();
+  void                        SetEditCurrentArgument();
+  void                        SelectionIntoArgument();
+  void                        ValueChangedInSpinBox();
+  void                        ButtonClicked(bool);
+  
+};
+
+#endif // BASICGUI_EXTRUDEDFEATUREDLG_H
\ No newline at end of file