]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Issue 0020154 : improve ellipse creeation function
authorvsr <vsr@opencascade.com>
Wed, 25 Feb 2009 13:31:16 +0000 (13:31 +0000)
committervsr <vsr@opencascade.com>
Wed, 25 Feb 2009 13:31:16 +0000 (13:31 +0000)
21 files changed:
doc/salome/gui/GEOM/images/ellipse.png
doc/salome/gui/GEOM/input/creating_ellipse.doc
doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
src/BasicGUI/BasicGUI_EllipseDlg.cxx
src/BasicGUI/BasicGUI_EllipseDlg.h
src/DlgRef/DlgRef.cxx
src/DlgRef/DlgRef.h
src/DlgRef/DlgRef_3Sel2Spin_QTD.ui [new file with mode: 0644]
src/DlgRef/Makefile.am
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_EllipseDriver.cxx
src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx
src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx
src/GEOMImpl/GEOMImpl_IEllipse.hxx
src/GEOM_I/GEOM_ICurvesOperations_i.cc
src/GEOM_I/GEOM_ICurvesOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/GEOM_SWIG/geompyDC.py

index 8eea6cae629ab918cdd81998187a6b73c742c769..9b31501158cb4357ec703dfcbcb9853df4170d74 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/ellipse.png and b/doc/salome/gui/GEOM/images/ellipse.png differ
index 2beaa908664c9439bcff80f0dc7051750d0ea16e..b2dace5910d4d4f123e5c97de0e95f45bab23b80 100644 (file)
@@ -4,17 +4,30 @@
 
 To create an \b Ellipse in the <b>Main Menu</b> select <b>New Entity - > Basic - > Ellipse</b>
 
-\n You can define an \b Ellipse by its <b>Center Point</b>, a \b
-Vector giving its normal, and its <b>Major & Minor Radiuses</b>.
+\n You can define an \b Ellipse by its <b>Center</b> point, a \b
+Vector giving its normal, another vector specifying the direction of
+ellipse's <b>Major Axis</b> and its <b>Major</b> & <b>Minor Radiuses</b>.
 \n The \b Result of the operation will be a GEOM_Object (edge).
 
-\n <b>TUI Command:</b> <em>geompy.MakeEllipse(Point, Vector, RadiusMajor, RadiusMinor)</em>
+\note The parameters <b>Center</b>, <b>Vector</b> and <b>Major Axis</b>
+are optional. By default it is presumed that the <b>Center</b> point
+is located at the origin of the global coordinate system, the \b Vector
+corresponds to the OZ axis of the global coordinate system and <b>Major Axis</b>
+corresponds to the OX axis of the global coordinate system.
+
+
+\note Actual direction of the major axis vector is defined as
+<EM> Vmaj' = (Vn * Vmaj) * Vn</em> where \em Vn is a normal vector and
+\em Vmaj is an original vector of the major axis.
+
+\n <b>TUI Command (no major axis):</b> <em>geompy.MakeEllipse(Point, Vector, RadiusMajor, RadiusMinor)</em>
 \n <b>Arguments:</b> Name + 1 vertex (for the center) + 1 edge (for
 the direction) + 1 X Radius + 1 Y Radius.
 
-\note By default it is presumed that the <b>Center Point</b> is located at the  Origin of the global
-coordinate system, and the  \b Vector corresponds to OZ axis of the global
-coordinate system.
+\n <b>TUI Command (use major axis):</b><em>geompy.MakeEllipseVec(Point, Vector, RadiusMajor, RadiusMinor, VectorMajor)</em>
+\n <b>Arguments:</b> Name + 1 vertex (for the center) + 1 edge (for
+the normal direction) + 1 X Radius + 1 Y Radius + 1 edge (for the
+major axis direction)
 
 \image html ellipse.png
 
index 89baf140d5ad9bbf223a9951ebc2d15501052812..51da40037ec1ec3eaead2d09370434a33539170f 100644 (file)
@@ -116,21 +116,32 @@ gg = salome.ImportComponentGUI("GEOM")
 
 # create vertices
 p0 = geompy.MakeVertex(0., 0., 0.)
-p50 = geompy.MakeVertex(50., 50., 50.)
+p1 = geompy.MakeVertex(50., 50., 50.)
+p2 = geompy.MakeVertex(0., 50., 0.)
 
-# create a vector from two points
-vector  = geompy.MakeVector(p0, p50)
+# create a normal vector from two points
+normal  = geompy.MakeVector(p0, p1)
+
+# create a major axis vector from two points
+major   = geompy.MakeVector(p0, p2)
 
 # create an ellipse from a point, a vector and radiuses
-ellipse = geompy.MakeEllipse(p50, vector, 50, 25)
+ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25)
+
+# create an ellipse from a point, a normal vector, radiuses and a major axis vector
+ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major)
 
 # add objects in the study
-id_vector  = geompy.addToStudy(vector, "Vector")
-id_ellipse = geompy.addToStudy(ellipse,"Ellipse")
+id_normal   = geompy.addToStudy(normal,   "Normal")
+id_major    = geompy.addToStudy(major,    "Major Axis")
+id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1")
+id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2")
 
 # display the ellipse and its normal vector
-gg.createAndDisplayGO(id_vector)
-gg.createAndDisplayGO(id_ellipse)
+gg.createAndDisplayGO(id_normal)
+gg.createAndDisplayGO(id_major)
+gg.createAndDisplayGO(id_ellipse1)
+gg.createAndDisplayGO(id_ellipse2)
 \endcode
 
 \anchor tui_creation_arc
@@ -302,4 +313,4 @@ gg.setDisplayMode(id_plane3,1)
 gg.setTransparency(id_plane3,0.5) 
 \endcode
 
-*/
\ No newline at end of file
+*/
index 7a64111e229fc3f0b5d9efadfcb91f217cd161ef..2be25f9636f6f95e4e14f97acbae9a91a3775b33 100644 (file)
@@ -2102,6 +2102,21 @@ module GEOM
                             in double theRMajor,
                             in double theRMinor);
 
+    /*!
+     *  Create an ellipse with given center, normal vector, main axis vector and radiuses.
+     *  \param thePnt Ellipse center.
+     *  \param theVec Vector, normal to the plane of the ellipse.
+     *  \param theRMajor Major ellipse radius.
+     *  \param theRMinor Minor ellipse radius.
+     *  \param theVecMaj Vector, direction of the ellipse's main axis.
+     *  \return New GEOM_Object, containing the created ellipse.
+     */
+    GEOM_Object MakeEllipseVec (in GEOM_Object thePnt,
+                               in GEOM_Object theVec,
+                               in double theRMajor,
+                               in double theRMinor,
+                               in GEOM_Object theVecMaj);
+
     /*!
      *  Create an arc of circle, passing through three given points.
      *  \param thePnt1 Start point of the arc.
index 4690e7e7ee702bfed1bfd3ecd027435fc49b078c..1ee41d6420ff901607ce0896622ca0a5ac92fa3a 100644 (file)
@@ -478,6 +478,11 @@ module GEOM
                             in GEOM_Object theVec,
                             in double      theRMajor,
                             in double      theRMinor) ;
+    GEOM_Object MakeEllipseVec (in GEOM_Object thePnt,
+                               in GEOM_Object theVec,
+                               in double      theRMajor,
+                               in double      theRMinor,
+                               in GEOM_Object theVecMaj) ;
     GEOM_Object MakeArc (in GEOM_Object thePnt1,
                         in GEOM_Object thePnt2,
                         in GEOM_Object thePnt3) ;
index 9b9eb6c07b7f2059c473b7060964722298eab5d7..dee60ede93b426581618fd752cd71deb68ff393d 100644 (file)
@@ -68,19 +68,23 @@ BasicGUI_EllipseDlg::BasicGUI_EllipseDlg( GeometryGUI* theGeometryGUI, QWidget*
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
-  GroupPoints = new DlgRef_2Sel2Spin( centralWidget() );
+  GroupPoints = new DlgRef_3Sel2Spin( centralWidget() );
   GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
-  GroupPoints->TextLabel1->setText( tr( "GEOM_CENTER" ) + " (Origin by default)" );
-  GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " (Z axis by default)" );
-  GroupPoints->TextLabel3->setText( tr( "GEOM_RADIUS_MAJOR" ) );
-  GroupPoints->TextLabel4->setText( tr( "GEOM_RADIUS_MINOR" ) );
+  GroupPoints->TextLabel1->setText( tr( "%1 (%2)" ).arg( tr( "GEOM_CENTER" ), tr( "ORIGIN_DEFAULT" ) ) );
+  GroupPoints->TextLabel2->setText( tr( "%1 (%2)" ).arg( tr( "GEOM_VECTOR" ), tr( "Z_AXIS_DEFAULT" ) ) );
+  GroupPoints->TextLabel3->setText( tr( "%1 (%2)" ).arg( tr( "GEOM_VECTOR_MAJOR" ), tr( "X_AXIS_DEFAULT" ) ) );
+  GroupPoints->TextLabel4->setText( tr( "GEOM_RADIUS_MAJOR" ) );
+  GroupPoints->TextLabel5->setText( tr( "GEOM_RADIUS_MINOR" ) );
   GroupPoints->PushButton1->setIcon( image1 );
   GroupPoints->PushButton2->setIcon( image1 );
+  GroupPoints->PushButton3->setIcon( image1 );
 
   GroupPoints->LineEdit1->setReadOnly( true );
   GroupPoints->LineEdit2->setReadOnly( true );
+  GroupPoints->LineEdit3->setReadOnly( true );
   GroupPoints->LineEdit1->setEnabled( true );
   GroupPoints->LineEdit2->setEnabled( false );
+  GroupPoints->LineEdit3->setEnabled( false );
 
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
@@ -114,7 +118,7 @@ void BasicGUI_EllipseDlg::Init()
   localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
   GroupPoints->PushButton1->setDown(true);
 
-  myPoint = myDir = GEOM::GEOM_Object::_nil();
+  myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil();
 
   /* Get setting of step value from file configuration */
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@@ -137,9 +141,11 @@ void BasicGUI_EllipseDlg::Init()
 
   connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
   connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
 
   connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
   connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( GroupPoints->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
 
   connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
   connect( GroupPoints->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@@ -188,13 +194,16 @@ bool BasicGUI_EllipseDlg::ClickOnApply()
   initName();
 
   // reset
-  myPoint = myDir = GEOM::GEOM_Object::_nil();
+  myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil();
   GroupPoints->LineEdit1->setText( "" );
   GroupPoints->LineEdit2->setText( "" );
+  GroupPoints->LineEdit3->setText( "" );
   GroupPoints->PushButton1->setDown(true);
   GroupPoints->PushButton2->setDown(false);
+  GroupPoints->PushButton3->setDown(false);
   GroupPoints->LineEdit1->setEnabled( true );
   GroupPoints->LineEdit2->setEnabled( false );
+  GroupPoints->LineEdit3->setEnabled( false );
   myEditCurrentArgument = GroupPoints->LineEdit1;
 
   globalSelection(); // close local contexts, if any
@@ -219,6 +228,7 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
   if (aSelList.Extent() != 1) {
     if      (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
     else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir   = GEOM::GEOM_Object::_nil();
+    else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor = GEOM::GEOM_Object::_nil();
     return;
   }
 
@@ -232,7 +242,7 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
     TopoDS_Shape aShape;
 
     TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
-    if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
+    if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 )
       aNeedType = TopAbs_EDGE;
     
     if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
@@ -278,7 +288,12 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
     }
     else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
       myDir   = aSelectedObject;
-      if ( !myDir->_is_nil() && myPoint->_is_nil() )
+      if ( !myDir->_is_nil() && myMajor->_is_nil() )
+       GroupPoints->PushButton3->click();
+    }
+    else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
+      myMajor = aSelectedObject;
+      if ( !myMajor->_is_nil() && myPoint->_is_nil() )
        GroupPoints->PushButton1->click();
     }
   }
@@ -298,19 +313,31 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument()
   if ( send == GroupPoints->PushButton1 ) {
     myEditCurrentArgument = GroupPoints->LineEdit1;
     GroupPoints->PushButton2->setDown(false);
+    GroupPoints->PushButton3->setDown(false);
     GroupPoints->LineEdit1->setEnabled( true );
     GroupPoints->LineEdit2->setEnabled( false );
+    GroupPoints->LineEdit3->setEnabled( false );
   }
   else if ( send == GroupPoints->PushButton2 ) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
     GroupPoints->PushButton1->setDown(false);
+    GroupPoints->PushButton3->setDown(false);
     GroupPoints->LineEdit1->setEnabled( false );
     GroupPoints->LineEdit2->setEnabled( true );
+    GroupPoints->LineEdit3->setEnabled( false );
+  }
+  else if ( send == GroupPoints->PushButton3 ) {
+    myEditCurrentArgument = GroupPoints->LineEdit3;
+    GroupPoints->PushButton1->setDown(false);
+    GroupPoints->PushButton2->setDown(false);
+    GroupPoints->LineEdit1->setEnabled( false );
+    GroupPoints->LineEdit2->setEnabled( false );
+    GroupPoints->LineEdit3->setEnabled( true );
   }
 
   globalSelection(); // close local contexts, if any
   TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
-  if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
+  if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 )
     aNeedType = TopAbs_EDGE;
   localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
   
@@ -328,7 +355,8 @@ void BasicGUI_EllipseDlg::LineEditReturnPressed()
 {
   QLineEdit* send = (QLineEdit*)sender();
   if ( send == GroupPoints->LineEdit1 ||
-       send == GroupPoints->LineEdit2 ) {
+       send == GroupPoints->LineEdit2 ||
+       send == GroupPoints->LineEdit3 ) {
     myEditCurrentArgument = send;
     GEOMBase_Skeleton::LineEditReturnPressed();
   }
@@ -350,6 +378,7 @@ void BasicGUI_EllipseDlg::ActivateThisDialog()
 
   GroupPoints->LineEdit1->setText( "" );
   GroupPoints->LineEdit2->setText( "" );
+  GroupPoints->LineEdit3->setText( "" );
 
   myPoint = myDir = GEOM::GEOM_Object::_nil();
   //globalSelection( GEOM_POINT );
@@ -429,7 +458,9 @@ bool BasicGUI_EllipseDlg::execute( ObjectList& objects )
   aParameters<<GroupPoints->SpinBox_DX->text();
   aParameters<<GroupPoints->SpinBox_DY->text();
   
-  GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipse( myPoint, myDir, aMajorR, aMinorR );
+  GEOM::GEOM_Object_var anObj = myMajor->_is_nil() ? 
+    GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipse   ( myPoint, myDir, aMajorR, aMinorR )         :
+    GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipseVec( myPoint, myDir, aMajorR, aMinorR, myMajor );
   if ( !anObj->_is_nil() ) {
     if ( !IsPreview() )
       anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
@@ -450,6 +481,8 @@ void BasicGUI_EllipseDlg::addSubshapesToStudy()
     objMap[GroupPoints->LineEdit1->text()] = myPoint;
   if (!CORBA::is_nil(myDir))
     objMap[GroupPoints->LineEdit2->text()] = myDir;
+  if (!CORBA::is_nil(myMajor))
+    objMap[GroupPoints->LineEdit3->text()] = myMajor;
 
   addSubshapesToFather( objMap );
 }
index ab6ef7cb49ed8b6d425767126ba79c04b0c17480..c80bce197165566632eb60c00d0bc4cbd2c68549 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <GEOMBase_Skeleton.h>
 
-class DlgRef_2Sel2Spin;
+class DlgRef_3Sel2Spin;
 
 //=================================================================================
 // class    : BasicGUI_EllipseDlg
@@ -54,9 +54,9 @@ private:
   void                               enterEvent( QEvent* );
 
 private:
-  GEOM::GEOM_Object_var              myPoint, myDir;
+  GEOM::GEOM_Object_var              myPoint, myDir, myMajor;
   
-  DlgRef_2Sel2Spin*                  GroupPoints;
+  DlgRef_3Sel2Spin*                  GroupPoints;
   
 private slots:
   void                               ClickOnOk();
index 0b0f48585454a86a320e89d41f77ab6248ab77d9..2d876aed24bb77bbce2f129ca6ecfdfde52821c6 100644 (file)
@@ -542,6 +542,20 @@ DlgRef_3Sel1Spin::~DlgRef_3Sel1Spin()
 {
 }
 
+//////////////////////////////////////////
+// DlgRef_3Sel2Spin
+//////////////////////////////////////////
+
+DlgRef_3Sel2Spin::DlgRef_3Sel2Spin( QWidget* parent, Qt::WindowFlags f )
+: QWidget( parent, f )
+{
+  setupUi( this );
+}
+
+DlgRef_3Sel2Spin::~DlgRef_3Sel2Spin()
+{
+}
+
 //////////////////////////////////////////
 // DlgRef_3Sel3Spin1Check
 //////////////////////////////////////////
@@ -766,7 +780,7 @@ QString DlgRef::PrintDoubleValue( double theValue, int thePrecision )
 {
   const double prec = 1e-12;
   
-  if ( abs(theValue) < thePrecision)
+  if ( qAbs(theValue) < prec )
     return "0";
 
   QString aRes;
index 69b58ca64fe929291f4ab6950aceaa6a48403be8..3ef90ccebd137092eb968b202698607cca2bd17d 100644 (file)
@@ -629,6 +629,22 @@ public:
   ~DlgRef_3Sel1Spin();
 };
 
+//////////////////////////////////////////
+// DlgRef_3Sel2Spin
+//////////////////////////////////////////
+
+#include "ui_DlgRef_3Sel2Spin_QTD.h"
+
+class DLGREF_EXPORT DlgRef_3Sel2Spin : public QWidget, 
+                                       public Ui::DlgRef_3Sel2Spin_QTD
+{
+  Q_OBJECT
+
+public:
+  DlgRef_3Sel2Spin( QWidget* = 0, Qt::WindowFlags = 0 );
+  ~DlgRef_3Sel2Spin();
+};
+
 //////////////////////////////////////////
 // DlgRef_3Sel3Spin1Check
 //////////////////////////////////////////
diff --git a/src/DlgRef/DlgRef_3Sel2Spin_QTD.ui b/src/DlgRef/DlgRef_3Sel2Spin_QTD.ui
new file mode 100644 (file)
index 0000000..5092829
--- /dev/null
@@ -0,0 +1,199 @@
+<ui version="4.0" >
+ <class>DlgRef_3Sel2Spin_QTD</class>
+ <widget class="QWidget" name="DlgRef_3Sel2Spin_QTD" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>120</width>
+    <height>177</height>
+   </rect>
+  </property>
+  <property name="sizePolicy" >
+   <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </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="sizePolicy" >
+      <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title" >
+      <string/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout" >
+      <item row="0" column="0" >
+       <widget class="QLabel" name="TextLabel1" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="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 vsizetype="Fixed" hsizetype="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 vsizetype="Fixed" hsizetype="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 vsizetype="Fixed" hsizetype="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 vsizetype="Fixed" hsizetype="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" >
+       <widget class="QPushButton" name="PushButton3" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="2" >
+       <widget class="QLineEdit" name="LineEdit3" />
+      </item>
+      <item row="3" column="0" >
+       <widget class="QLabel" name="TextLabel4" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>TL4</string>
+        </property>
+        <property name="wordWrap" >
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1" colspan="2" >
+       <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
+      </item>
+      <item row="4" column="0" >
+       <widget class="QLabel" name="TextLabel5" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>TL5</string>
+        </property>
+        <property name="wordWrap" >
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="1" colspan="2" >
+       <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY" />
+      </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>PushButton3</tabstop>
+  <tabstop>LineEdit3</tabstop>
+  <tabstop>SpinBox_DX</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
index cbd156bb1dc1060c7ebcb7c1ef3c25dc95f755d0..54cb1abe70d92ec4780ba6dc5cc4ac7985464fd6 100644 (file)
@@ -75,6 +75,7 @@ UIC_FILES =                                   \
        ui_DlgRef_3Radio1Sel1Spin_QTD.h         \
        ui_DlgRef_3Sel1Check_QTD.h              \
        ui_DlgRef_3Sel1Spin_QTD.h               \
+       ui_DlgRef_3Sel2Spin_QTD.h               \
        ui_DlgRef_3Sel3Spin1Check_QTD.h         \
        ui_DlgRef_3Sel3Spin2Check_QTD.h         \
        ui_DlgRef_3Sel4Spin2Check_QTD.h         \
index 15ac7e838d33acea79a84df4a978227438c82fe8..13210b5377e54d1420eaf387c8c4d1c26b68d7fd 100644 (file)
@@ -3760,6 +3760,25 @@ Please, select face, shell or solid and try again</translation>
             <translation>Import operation has finished with errors:</translation>
         </message>
     </context>
+    <context>
+        <name>BasicGUI_EllipseDlg</name>
+        <message>
+            <source>GEOM_VECTOR_MAJOR</source>
+            <translation>Major Axis</translation>
+        </message>
+        <message>
+            <source>ORIGIN_DEFAULT</source>
+            <translation>Origin by default</translation>
+        </message>
+        <message>
+            <source>X_AXIS_DEFAULT</source>
+            <translation>X axis by default</translation>
+        </message>
+        <message>
+            <source>Z_AXIS_DEFAULT</source>
+            <translation>Z axis by default</translation>
+        </message>
+    </context>
     <context>
         <name>BasicGUI_MarkerDlg</name>
         <message>
index 24ac23eb6e986e101680265743d08e29ee1475cd..176ba05df87847634b3b2a088a43aed4e89115f6 100644 (file)
@@ -79,7 +79,7 @@ Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
       TopoDS_Shape aShapePnt = aRefPoint->GetValue();
       if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
         Standard_ConstructionError::Raise
-          ("Circle creation aborted: invalid center argument, must be a point");
+          ("Ellipse creation aborted: invalid center argument, must be a point");
       }
       aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
     }
@@ -90,7 +90,7 @@ Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
       TopoDS_Shape aShapeVec = aRefVector->GetValue();
       if (aShapeVec.ShapeType() != TopAbs_EDGE) {
         Standard_ConstructionError::Raise
-          ("Circle creation aborted: invalid vector argument, must be a vector or an edge");
+          ("Ellipse creation aborted: invalid normal vector argument, must be a vector or an edge");
       }
       TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
       TopoDS_Vertex V1, V2;
@@ -99,12 +99,37 @@ Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
         aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
         if (aV.Magnitude() < gp::Resolution()) {
           Standard_ConstructionError::Raise
-            ("Circle creation aborted: vector of zero length is given");
+            ("Ellipse creation aborted: normal vector of zero length is given");
         }
       }
     }
+    // Main Axis vector
+    gp_Vec aVM = gp::DX();
+    Handle(GEOM_Function) aRefVectorMaj = aCI.GetVectorMajor();
+    if (!aRefVectorMaj.IsNull()) {
+      TopoDS_Shape aShapeVec = aRefVectorMaj->GetValue();
+      if (aShapeVec.ShapeType() != TopAbs_EDGE) {
+        Standard_ConstructionError::Raise
+          ("Ellipse creation aborted: invalid major axis vector argument, must be a vector or an edge");
+      }
+      TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
+      TopoDS_Vertex V1, V2;
+      TopExp::Vertices(anE, V1, V2, Standard_True);
+      if (!V1.IsNull() && !V2.IsNull()) {
+        aVM = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
+        if (aVM.Magnitude() < gp::Resolution()) {
+          Standard_ConstructionError::Raise
+            ("Ellipse creation aborted: major axis vector of zero length is given");
+        }
+       if (aV.IsParallel(aVM, Precision::Angular())) {
+         Standard_ConstructionError::Raise
+           ("Ellipse creation aborted: normal and major axis vectors are parallel");
+       }
+      }
+    }
+
     // Axes
-    gp_Ax2 anAxes (aP, aV);
+    gp_Ax2 anAxes (aP, aV, aVM);
     // Ellipse
     gp_Elips anEll (anAxes, aCI.GetRMajor(), aCI.GetRMinor());
     aShape = BRepBuilderAPI_MakeEdge(anEll).Edge();
index 6a6b8f9ef257d21b2d4ee2100df8f92446718695..72fb49c63f681f5980943a74a3595cc63b9a4a2a 100644 (file)
@@ -334,12 +334,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
                        (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
-                        double theRMajor, double theRMinor)
+                        double theRMajor, double theRMinor,
+                       Handle(GEOM_Object) theVecMaj)
 {
   SetErrorCode(KO);
 
   // Not set thePnt means origin of global CS,
   // Not set theVec means Z axis of global CS
+  // Not set theVecMaj means X axis of global CS
   //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
 
   //Add a new Ellipse object
@@ -370,6 +372,12 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
   aCI.SetRMajor(theRMajor);
   aCI.SetRMinor(theRMinor);
 
+  if (!theVecMaj.IsNull()) {
+    Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
+    if (aRefVecMaj.IsNull()) return NULL;
+    aCI.SetVectorMajor(aRefVecMaj);
+  }
+
   //Compute the Ellipse value
   try {
 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
@@ -387,8 +395,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
   }
 
   //Make a Python command
-  GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
-    << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+  if (!theVecMaj.IsNull()) {
+    GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+                                << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
+                                << ", " << theVecMaj << ")";
+  }
+  else {
+    GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+                                << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+  }
 
   SetErrorCode(OK);
   return anEll;
index 7380a097764ed8445018e5b1c7e197276b71971d..dbf5ecee0cfab3c2a713f87f4432758e79399047 100644 (file)
@@ -51,7 +51,8 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
 
   Standard_EXPORT Handle(GEOM_Object) MakeEllipse (Handle(GEOM_Object) thePnt,
                                                    Handle(GEOM_Object) theVec,
-                                                   double theRMajor, double theRMinor);
+                                                   double theRMajor, double theRMinor,
+                                                  Handle(GEOM_Object) theVecMaj);
 
   Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1,
                                                Handle(GEOM_Object) thePnt2,
index 8a199e7609e9d047ebf36481ada3331c250d89db..8fe39a5f3a51ba369e556af31d170a97077c131e 100644 (file)
 //
 #include "GEOM_Function.hxx"
 
-#define ELLIPS_ARG_CC   1
-#define ELLIPS_ARG_VV   2
-#define ELLIPS_ARG_RMAJ 3
-#define ELLIPS_ARG_RMIN 4
+#define ELLIPS_ARG_CC    1
+#define ELLIPS_ARG_VV    2
+#define ELLIPS_ARG_RMAJ  3
+#define ELLIPS_ARG_RMIN  4
+#define ELLIPS_ARG_VVMAJ 5
 
 class GEOMImpl_IEllipse
 {
@@ -40,12 +41,16 @@ class GEOMImpl_IEllipse
   void SetRMajor(double theR) { _func->SetReal(ELLIPS_ARG_RMAJ, theR); }
   void SetRMinor(double theR) { _func->SetReal(ELLIPS_ARG_RMIN, theR); }
 
+  void SetVectorMajor(Handle(GEOM_Function) theV) { _func->SetReference(ELLIPS_ARG_VVMAJ, theV); }
+
   Handle(GEOM_Function) GetCenter() { return _func->GetReference(ELLIPS_ARG_CC); }
   Handle(GEOM_Function) GetVector() { return _func->GetReference(ELLIPS_ARG_VV); }
 
   double GetRMajor() { return _func->GetReal(ELLIPS_ARG_RMAJ); }
   double GetRMinor() { return _func->GetReal(ELLIPS_ARG_RMIN); }
 
+  Handle(GEOM_Function) GetVectorMajor() { return _func->GetReference(ELLIPS_ARG_VVMAJ); }
+
  private:
 
   Handle(GEOM_Function) _func;
index 2b15af49fbb5819a0656a1eaaa7bdd206014759f..572a2918b97f2eb0533ab090f012ccc29915623d 100644 (file)
@@ -181,7 +181,49 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
   //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
 
   //Get the arguments
-  Handle(GEOM_Object) aPnt, aVec;
+  Handle(GEOM_Object) aPnt, aVec, aVecMaj;
+  if (!CORBA::is_nil(thePnt)) {
+    aPnt = GetOperations()->GetEngine()->GetObject
+      (thePnt->GetStudyID(), thePnt->GetEntry());
+    if (aPnt.IsNull()) return aGEOMObject._retn();
+  }
+  if (!CORBA::is_nil(theVec)) {
+    aVec = GetOperations()->GetEngine()->GetObject
+      (theVec->GetStudyID(), theVec->GetEntry());
+    if (aVec.IsNull()) return aGEOMObject._retn();
+  }
+
+  // Make Ellipse
+  Handle(GEOM_Object) anObject =
+    GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeEllipseVec
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipseVec
+                      (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
+                      CORBA::Double theRMajor, double theRMinor,
+                      GEOM::GEOM_Object_ptr theVecMaj)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Not set thePnt means origin of global CS,
+  // Not set theVec means Z axis of global CS
+  // Not set theVecMaj means X axis of global CS
+  //if (thePnt == NULL || theVec == NULL || theVecMaj == NULL) return aGEOMObject._retn();
+
+  //Get the arguments
+  Handle(GEOM_Object) aPnt, aVec, aVecMaj;
   if (!CORBA::is_nil(thePnt)) {
     aPnt = GetOperations()->GetEngine()->GetObject
       (thePnt->GetStudyID(), thePnt->GetEntry());
@@ -192,10 +234,15 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
       (theVec->GetStudyID(), theVec->GetEntry());
     if (aVec.IsNull()) return aGEOMObject._retn();
   }
+  if (!CORBA::is_nil(theVecMaj)) {
+    aVecMaj = GetOperations()->GetEngine()->GetObject
+      (theVecMaj->GetStudyID(), theVecMaj->GetEntry());
+    if (aVecMaj.IsNull()) return aGEOMObject._retn();
+  }
 
   // Make Ellipse
   Handle(GEOM_Object) anObject =
-    GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
+    GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
index 24179fc1f7ec6ba7c4f5e72e81351a11f360bef6..728f567e0ece002e231867a16e3b89ccfdb1cc71 100644 (file)
@@ -57,6 +57,11 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
                                     GEOM::GEOM_Object_ptr theVector,
                                     double theRMajor, double theRMinor);
 
+  GEOM::GEOM_Object_ptr MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
+                                       GEOM::GEOM_Object_ptr theVector,
+                                       double theRMajor, double theRMinor,
+                                       GEOM::GEOM_Object_ptr theVectorMajor);
+
   GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1,
                                 GEOM::GEOM_Object_ptr thePnt2,
                                 GEOM::GEOM_Object_ptr thePnt3);
index 159bb6f4997a021ac5aa51250174cdb690ccab06..094b6e99fef0247b72851e5e733a0d9a97096db3 100644 (file)
@@ -2532,6 +2532,23 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEllipse (GEOM::GEOM_Object_ptr theCente
   return anObj;
 }
 
+//=============================================================================
+//  MakeEllipseVec:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
+                                                    GEOM::GEOM_Object_ptr theVector,
+                                                    CORBA::Double theRMajor, 
+                                                    CORBA::Double theRMinor,
+                                                    GEOM::GEOM_Object_ptr theVectorMajor)
+{
+  beginService( " GEOM_Superv_i::MakeEllipseVec" );
+  MESSAGE("GEOM_Superv_i::MakeEllipseVec");
+  getCurvesOp();
+  GEOM::GEOM_Object_ptr anObj = myCurvesOp->MakeEllipseVec(theCenter, theVector, theRMajor, theRMinor, theVectorMajor);
+  endService( " GEOM_Superv_i::MakeEllipseVec" );
+  return anObj;
+}
+
 //=============================================================================
 //  MakeArc:
 //=============================================================================
index b34c13214be5b0fc316bedb1fa6ca172d9e334e3..e9e2dd24283dcf004dd501791c170ae5f47edc60 100644 (file)
@@ -557,6 +557,10 @@ public:
   GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter,
                                     GEOM::GEOM_Object_ptr theVector,
                                     CORBA::Double theRMajor, CORBA::Double theRMinor);
+  GEOM::GEOM_Object_ptr MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
+                                       GEOM::GEOM_Object_ptr theVector,
+                                       CORBA::Double theRMajor, CORBA::Double theRMinor,
+                                       GEOM::GEOM_Object_ptr theVectorMajor);
   GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1,
                                 GEOM::GEOM_Object_ptr thePnt2,
                                 GEOM::GEOM_Object_ptr thePnt3);
index 56e0ba3fb9230e4bd59bfa5040bd14280041d388..61f6380c3dafd22dfdbba24474f670a99b6eae9d 100644 (file)
@@ -652,13 +652,18 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  @param theVec Vector, normal to the plane of the ellipse.
         #  @param theRMajor Major ellipse radius.
         #  @param theRMinor Minor ellipse radius.
+        #  @param theVecMaj Vector, direction by the main exis.
         #  @return New GEOM_Object, containing the created ellipse.
         #
         #  @ref tui_creation_ellipse "Example"
-        def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor):
+        def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor, theVecMaj=None):
             # Example: see GEOM_TestAll.py
             theRMajor, theRMinor, Parameters = ParseParameters(theRMajor, theRMinor)
-            anObj = self.CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
+            if theVecMaj is not None:
+                anObj = self.CurvesOp.MakeEllipseVec(thePnt, theVec, theRMajor, theRMinor, theVecMaj)
+            else:
+                anObj = self.CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
+                pass
             RaiseIfFailed("MakeEllipse", self.CurvesOp)
             anObj.SetParameters(Parameters)
             return anObj