Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
index a86ef9ea1ab2049e75c0ee0564d4c461d5358000..0aa9b4ffc96f9d7f73eb8fb9fae71462ff1b7946 100644 (file)
@@ -179,6 +179,7 @@ using namespace std;
 #include "GeometryGUI_MirrorDlg.h"        // Method MIRROR
 #include "GeometryGUI_SphereDlg.h"        // Method SPHERE
 #include "GeometryGUI_CircleDlg.h"        // Method CIRCLE
+#include "GeometryGUI_EllipseDlg.h"       // Method ELLIPSE
 #include "GeometryGUI_RevolDlg.h"         // Method REVOL
 #include "GeometryGUI_RotationDlg.h"      // Method ROTATION
 #include "GeometryGUI_TranslationDlg.h"   // Method TRANSLATION
@@ -358,7 +359,7 @@ GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop )
 
     GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
 
-    Engines::Component_var comp = desktop->getEngine("FactoryServer", "Geometry");
+    Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
     GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
     
     /* GetCurrentStudy */
@@ -716,9 +717,9 @@ GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR,
 GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
                                                  Standard_Boolean& testResult )
 {
-  GEOM::GEOM_Shape_var aShape ;
+  GEOM::GEOM_Shape_ptr aShape ;
   testResult = false ;
-  
+
   /* case SObject */
   if ( IO->hasEntry() ) {
     SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
@@ -726,23 +727,23 @@ GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_Inte
     SALOMEDS::GenericAttribute_var anAttr;
     SALOMEDS::AttributeIOR_var     anIOR;
     if ( !obj->_is_nil() ) {
-      if (obj->FindAttribute(anAttr, "AttributeIOR")) {
-       anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-       aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
-       if(!CORBA::is_nil(aShape)) testResult = true ;
-       return aShape._retn();
-      }
+       if (obj->FindAttribute(anAttr, "AttributeIOR")) {
+         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+        aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
+        testResult = true ;
+        return aShape;
+       }
     }
   }
   /* case Graphical Object */
   if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
     Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
     Standard_CString ior = GIObject->getIOR();
+    testResult = true ;
     aShape = myComponentGeom->GetIORFromString(ior) ;
-    if(!CORBA::is_nil(aShape)) testResult = true ;
-    return aShape._retn();
-  }
-  return aShape._retn();
+    return aShape;
+  } 
+  return aShape ;
 }
 
 
@@ -1783,6 +1784,35 @@ void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir d
 }
 
 
+//=====================================================================================
+// function : MakeEllipseAndDisplay()
+// purpose  :
+//=====================================================================================
+void GeometryGUI::MakeEllipseAndDisplay( const gp_Pnt CenterPoint,
+                                        const gp_Dir dir,
+                                        const Standard_Real Major_Radius,
+                                        const Standard_Real Minor_Radius )
+{
+  try {
+    GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(),  CenterPoint.Z() ) ;
+    GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
+    GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+    
+    GEOM::GEOM_Shape_var result = myComponentGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius) ;
+    if ( result->_is_nil() ) {
+      myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+      return ;
+    }
+    result->NameType(tr("GEOM_ELLIPSE"));
+    if ( Display( result ) )
+      myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+  }
+  catch (const SALOME::SALOME_Exception& S_ex) {
+    QtCatchCorbaException(S_ex);
+  }
+  return  ;
+}
+
 
 //=====================================================================================
 // function : MakeWireAndDisplay()
@@ -3296,6 +3326,14 @@ bool GeometryGUI::OnGUIEvent(int theCommandID,   QAD_Desktop* parent)
        break ;
       }
 
+    case 3014:  // ELLIPSE
+      {
+       GeomGUI->EmitSignalDeactivateDialog() ;
+       SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+       GeometryGUI_EllipseDlg *aDlg = new GeometryGUI_EllipseDlg( parent, "", Sel ) ;
+       break ;
+      }
+
     case 3015:  // ARC
       {
        GeomGUI->EmitSignalDeactivateDialog() ;
@@ -4216,7 +4254,7 @@ bool GeometryGUI::OnGUIEvent(int theCommandID,    QAD_Desktop* parent)
                if (!obj->FindAttribute(anAttr, "AttributeIOR") &&
                    obj->FindAttribute(anAttr, "AttributePersistentRef")) {
                  // load
-                 Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","Geometry");
+                 Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","GEOM");
                  if (!CORBA::is_nil(comp)) {
                    SALOMEDS::Driver_var   driver = SALOMEDS::Driver::_narrow(comp);
 
@@ -5011,7 +5049,8 @@ bool GeometryGUI::Import( )
       father = aStudyBuilder->NewComponent("GEOM");
       anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-      aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+      //      aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+      aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
       anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
       aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
       aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
@@ -5215,7 +5254,8 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape,
     father = aStudyBuilder->NewComponent("GEOM");
     anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
     aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+    //    aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+    aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
     anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
     aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
     aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
@@ -5329,7 +5369,8 @@ bool GeometryGUI::AddInStudy( bool selection,
     father = aStudyBuilder->NewComponent("GEOM");
     anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
     aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+    //    aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+    aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
     anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
     aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
     aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );