]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Implement GUI
authorskv <skv@opencascade.com>
Mon, 20 Oct 2014 11:06:23 +0000 (15:06 +0400)
committerskv <skv@opencascade.com>
Mon, 20 Oct 2014 11:06:23 +0000 (15:06 +0400)
resources/CMakeLists.txt
resources/build_face_surface.png [new file with mode: 0644]
src/BuildGUI/BuildGUI_FaceDlg.cxx
src/BuildGUI/BuildGUI_FaceDlg.h
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts

index 1fa4e9d9dcab40900dd344f3d5a0ce551ba0ed3b..e3afdf6cb91e8a0c9629e92d01f88ad45d30a6e3 100755 (executable)
@@ -54,6 +54,7 @@ SET( _res_files
   build_edge_wire.png
   build_edge_curve.png
   build_face.png
+  build_face_surface.png
   build_shell.png
   build_solid.png
   build_wire.png
diff --git a/resources/build_face_surface.png b/resources/build_face_surface.png
new file mode 100644 (file)
index 0000000..328f5a9
Binary files /dev/null and b/resources/build_face_surface.png differ
index bdd72265b573ccb3c28a6525efc1bbaafaad3932..3420aa2af599239f198390018d939d0ef0c912b3 100644 (file)
 //            TRUE to construct a modal dialog.
 //=================================================================================
 BuildGUI_FaceDlg::BuildGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
-  : GEOMBase_Skeleton( theGeometryGUI, parent )
+  : GEOMBase_Skeleton( theGeometryGUI, parent ),
+    GroupWire        (0),
+    myGroupSurf      (0)
 {
-  QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_FACE" ) ) );
-  QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+  QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+  QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_FACE" ) ) );
+  QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_FACE_SURFACE" ) ) );
 
   setWindowTitle( tr( "GEOM_FACE_TITLE" ) );
 
   /***************************************************************/
   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FACE" ) );
-  mainFrame()->RadioButton1->setIcon( image0 );
-  mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
-  mainFrame()->RadioButton2->close();
+  mainFrame()->RadioButton1->setIcon( image1 );
+  mainFrame()->RadioButton2->setIcon( image2 );
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
@@ -69,11 +71,20 @@ BuildGUI_FaceDlg::BuildGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget* parent
   GroupWire->GroupBox1->setTitle( tr( "GEOM_FACE_FFW" ) );
   GroupWire->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
   GroupWire->CheckButton1->setText( tr( "GEOM_FACE_OPT" ) );
-  GroupWire->PushButton1->setIcon( image1 );
+  GroupWire->PushButton1->setIcon( image0 );
+
+  myGroupSurf = new DlgRef_2Sel(centralWidget());
+
+  myGroupSurf->GroupBox1->setTitle(tr("GEOM_FACE_FROM_SURFACE" ) );
+  myGroupSurf->TextLabel1->setText(tr("GEOM_FACE"));
+  myGroupSurf->TextLabel2->setText(tr("GEOM_WIRE"));
+  myGroupSurf->PushButton1->setIcon(image0);
+  myGroupSurf->PushButton2->setIcon(image0);
 
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
   layout->addWidget( GroupWire );
+  layout->addWidget(myGroupSurf);
   /***************************************************************/
 
   setHelpFileName("create_face_page.html");
@@ -102,27 +113,79 @@ void BuildGUI_FaceDlg::Init()
   /* init variables */
   myEditCurrentArgument = GroupWire->LineEdit1;
   GroupWire->LineEdit1->setReadOnly( true );
+  myGroupSurf->LineEdit1->setReadOnly( true );
+  myGroupSurf->LineEdit2->setReadOnly( true );
 
   GroupWire->CheckButton1->setChecked( true );
   myWires.clear();
-
-  TColStd_MapOfInteger aMap;
-  aMap.Add( GEOM_EDGE );
-  aMap.Add( GEOM_WIRE );
-  globalSelection( aMap );
+  myFace.nullify();
+  myWire.nullify();
 
   /* signals and slots connections */
+  connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
+  connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()),        this, SLOT(ClickOnCancel()));
+
+  connect(this,      SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
+
   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
   connect( GroupWire->LineEdit1,   SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) );
   connect( GroupWire->PushButton1, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
+  connect( myGroupSurf->LineEdit1,   SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) );
+  connect( myGroupSurf->PushButton1, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
+  connect( myGroupSurf->LineEdit2,   SIGNAL( returnPressed()), this, SLOT( LineEditReturnPressed() ) );
+  connect( myGroupSurf->PushButton2, SIGNAL( clicked() ),      this, SLOT( SetEditCurrentArgument() ) );
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   initName( tr( "GEOM_FACE" ) );
-  SelectionIntoArgument();
+
+  ConstructorsClicked(0);
 }
 
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose  : Radio button management
+//=================================================================================
+void BuildGUI_FaceDlg::ConstructorsClicked(int constructorId)
+{
+  switch (constructorId) {
+  case 0:
+    {
+      TColStd_MapOfInteger aMap;
+
+      aMap.Add(GEOM_EDGE);
+      aMap.Add(GEOM_WIRE);
+      globalSelection(aMap);
+
+      myEditCurrentArgument = GroupWire->LineEdit1;
+      GroupWire->LineEdit1->setText("");
+      GroupWire->show();
+      myGroupSurf->hide();
+      break;
+    }
+  case 1:
+    {
+      globalSelection(GEOM_FACE); // For the first element.
+
+      myEditCurrentArgument = myGroupSurf->LineEdit1;
+      myGroupSurf->LineEdit1->setText("");
+      myGroupSurf->PushButton1->setDown(true);
+      myGroupSurf->PushButton2->setDown(false);
+      GroupWire->hide();
+      myGroupSurf->show();
+      break;
+    }
+  }
+
+  myWires.clear();
+  myFace.nullify();
+  myWire.nullify();
+  qApp->processEvents();
+  updateGeometry();
+  resize(minimumSizeHint());
+  SelectionIntoArgument();
+}
 
 //=================================================================================
 // function : ClickOnOk()
@@ -156,16 +219,44 @@ bool BuildGUI_FaceDlg::ClickOnApply()
 //=================================================================================
 void BuildGUI_FaceDlg::SelectionIntoArgument()
 {
-  myEditCurrentArgument->setText( "" );
+  if (myEditCurrentArgument == GroupWire->LineEdit1) {
+    myEditCurrentArgument->setText( "" );
+
+    QList<TopAbs_ShapeEnum> types;
+    types << TopAbs_EDGE << TopAbs_WIRE;
+    myWires = getSelected( types, -1 );
 
-  QList<TopAbs_ShapeEnum> types;
-  types << TopAbs_EDGE << TopAbs_WIRE;
-  myWires = getSelected( types, -1 );
+    if ( !myWires.isEmpty() ) {
+      QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() );
+      myEditCurrentArgument->setText( aName );
+    }
+  } else if (myEditCurrentArgument == myGroupSurf->LineEdit1 ||
+             myEditCurrentArgument == myGroupSurf->LineEdit2) {
+    const bool isEditFace = myEditCurrentArgument == myGroupSurf->LineEdit1;
+    const TopAbs_ShapeEnum aType = isEditFace ? TopAbs_FACE : TopAbs_WIRE;
+    GEOM::GeomObjPtr aSelectedObject = getSelected(aType);
+    GEOM::GeomObjPtr &anObj = isEditFace ? myFace : myWire;
+
+    if (aSelectedObject) {
+      myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject.get()));
+      anObj = aSelectedObject;
+    } else {
+      myEditCurrentArgument->setText("");
+      anObj.nullify();
+    }
 
-  if ( !myWires.isEmpty() ) {
-    QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() );
-    myEditCurrentArgument->setText( aName );
+    if (isEditFace) {
+      if (myFace && !myWire) {
+        myGroupSurf->PushButton2->click();
+      }
+    } else {
+      if (!myFace && myWire) {
+        myGroupSurf->PushButton1->click();
+      }
+    }
   }
+
+  displayPreview(true);
 }
 
 
@@ -176,18 +267,33 @@ void BuildGUI_FaceDlg::SelectionIntoArgument()
 void BuildGUI_FaceDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
-  if ( send != GroupWire->PushButton1 )
-    return;
-  
-  TColStd_MapOfInteger aMap;
-  aMap.Add( GEOM_EDGE );
-  aMap.Add( GEOM_WIRE );
-  globalSelection( aMap );
 
-  myEditCurrentArgument = GroupWire->LineEdit1;
+  if (send == GroupWire->PushButton1) {
+    TColStd_MapOfInteger aMap;
+  
+    aMap.Add(GEOM_EDGE);
+    aMap.Add(GEOM_WIRE);
+    globalSelection(aMap);
+    myEditCurrentArgument = GroupWire->LineEdit1;
+  }
+  else if (send == myGroupSurf->PushButton1) {
+    globalSelection(GEOM_FACE);
+    myEditCurrentArgument = myGroupSurf->LineEdit1;
+    myGroupSurf->PushButton2->setDown(false);
+    myGroupSurf->LineEdit2->setEnabled(false);
+  }
+  else if (send == myGroupSurf->PushButton2) {
+    globalSelection(GEOM_WIRE);
+    myEditCurrentArgument = myGroupSurf->LineEdit2;
+    myGroupSurf->PushButton1->setDown(false);
+    myGroupSurf->LineEdit1->setEnabled(false);
+  }
 
+  // enable line edit
+  myEditCurrentArgument->setEnabled(true);
   myEditCurrentArgument->setFocus();
-  SelectionIntoArgument();
+  send->setDown(true);
+  displayPreview(true);
 }
 
 
@@ -198,12 +304,11 @@ void BuildGUI_FaceDlg::SetEditCurrentArgument()
 void BuildGUI_FaceDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
-           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-  TColStd_MapOfInteger aMap;
-  aMap.Add( GEOM_EDGE );
-  aMap.Add( GEOM_WIRE );
-  globalSelection( aMap );
+
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+           this, SLOT(SelectionIntoArgument()));
+
+  ConstructorsClicked(getConstructorId());
 }
 
 
@@ -232,7 +337,20 @@ GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation()
 //=================================================================================
 bool BuildGUI_FaceDlg::isValid( QString& )
 {
-  return !myWires.isEmpty();
+  bool ok = false;
+
+  switch (getConstructorId()) {
+  case 0:
+    ok = !myWires.isEmpty();
+    break;
+  case 1:
+    ok = myFace && myWire;
+    break;
+  default:
+    break;
+  }
+
+  return ok;
 }
 
 //=================================================================================
@@ -241,14 +359,32 @@ bool BuildGUI_FaceDlg::isValid( QString& )
 //=================================================================================
 bool BuildGUI_FaceDlg::execute( ObjectList& objects )
 {
+  bool res = false;
   GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
+  GEOM::GEOM_Object_var anObj;
 
-  GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
-  objlist->length( myWires.count() );
-  for ( int i = 0; i < myWires.count(); i++ )
-    objlist[i] = myWires[i].copy();
+  switch (getConstructorId()) {
+  case 0:
+    {
+      GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
+      
+      objlist->length( myWires.count() );
 
-  GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() );
+      for ( int i = 0; i < myWires.count(); i++ ) {
+        objlist[i] = myWires[i].copy();
+      }
+
+      anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() );
+      res   = true;
+    }
+    break;
+  case 1:
+    anObj = anOper->MakeFaceFromSurface(myFace.get(), myWire.get());
+    res   = true;
+    break;
+  default:
+    break;
+  }
 
   if (!anObj->_is_nil()) {
     objects.push_back(anObj._retn());
@@ -262,5 +398,5 @@ bool BuildGUI_FaceDlg::execute( ObjectList& objects )
     }
   }
 
-  return true;
+  return res;
 }
index d0e6670727152f142d9d8866902c2f95404500bc..570961c4c51bfc6f599cb97a64dc017e324159dd 100644 (file)
@@ -31,6 +31,7 @@
 #include "GEOM_GenericObjPtr.h"
 
 class DlgRef_1Sel1Check;
+class DlgRef_2Sel;
 
 //=================================================================================
 // class    : BuildGUI_FaceDlg
@@ -56,10 +57,14 @@ private:
   
 private:
   QList<GEOM::GeomObjPtr>            myWires;
+  GEOM::GeomObjPtr                   myFace;
+  GEOM::GeomObjPtr                   myWire;
   
   DlgRef_1Sel1Check*                 GroupWire;
+  DlgRef_2Sel                       *myGroupSurf;
 
 private slots:
+  void                               ConstructorsClicked (int);
   void                               ClickOnOk();
   bool                               ClickOnApply();
   void                               ActivateThisDialog();
index 115e51e67bf40a4ac764b069bc639d7aa86b34a2..900d965ad3e423b1aef6388b31e2b4356716c7ea 100644 (file)
             <source>ICON_DLG_BUILD_FACE</source>
             <translation>build_face.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_BUILD_FACE_SURFACE</source>
+            <translation>build_face_surface.png</translation>
+        </message>
        <message>
             <source>ICON_DLG_FACE_HW</source>
             <translation>face_hw.png</translation>
index 5b5c8bb6388d2ba8bc67dd15b4e298f78b00b9e2..ff3ded1072d678087db3f1afb1ba39170af8c71c 100644 (file)
@@ -691,6 +691,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_FACE_FFW</source>
         <translation>Face creation from wires and/or edges</translation>
     </message>
+    <message>
+        <source>GEOM_FACE_FROM_SURFACE</source>
+        <translation>Face creation from surface bounded by wire</translation>
+    </message>
     <message>
         <source>GEOM_FACE_OPT</source>
         <translation>Try to create a planar face</translation>