-// GEOM GEOMGUI : GUI for Geometry component
+// GEOM GEOMGUI : GUI for Geometry component
//
-// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// Copyright (C) 2003 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
+//
+// File : GEOMBase.cxx
+// Author : Damien COQUERET, Open CASCADE S.A.S.
//
-// File : GEOMBase.cxx
-// Author : Damien COQUERET
-// Module : GEOM
-// $Header$
#include "GEOMBase.h"
-#include "GeometryGUI.h"
-#include "GEOMBase_aParameterDlg.h"
+
+#include <GeometryGUI.h>
+#include <GEOM_Client.hxx>
//// SALOME Includes
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
-
-#include "QAD_Config.h"
-#include "QAD_Desktop.h"
-#include "QAD_RightFrame.h"
-#include "QAD_MessageBox.h"
-#include "QAD_Resource.h"
-#include "QAD_MessageBox.h"
-#include "SALOME_Selection.h"
-
-#include "GEOM_AssemblyBuilder.h"
-#include "GEOM_Actor.h"
-#include "VTKViewer_ViewFrame.h"
-#include "VTKViewer_RenderWindowInteractor.h"
-#include "OCCViewer_ViewPort3d.h"
-#include "OCCViewer_Viewer3d.h"
-#include "OCCViewer_ViewFrame.h"
-
-#include "SALOME_ListIteratorOfListIO.hxx"
-#include "GEOM_AISTrihedron.hxx"
-#include "SALOMEGUI_ImportOperation.h"
-#include "SALOMEGUI_NameDlg.h"
+#include <GEOM_Actor.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_MessageBox.h>
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
// // Open CASCADE Includes
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
-#include <Geom_Circle.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
#include <Precision.hxx>
#include <vtkRenderer.h>
-#include <qvaluelist.h>
-#include <qstringlist.h>
-#include "GEOMImpl_Types.hxx"
-
-using namespace std;
-
-//=======================================================================
-// function : GEOMBase()
-// purpose : Constructor
-//=======================================================================
-GEOMBase::GEOMBase()
-{
-}
-
-
-//=======================================================================
-// function : ~GEOMBase()
-// purpose : Destructor
-//=======================================================================
-GEOMBase::~GEOMBase()
-{
-}
+#include <set>
//=====================================================================================
// function : GetShapeFromIOR()
TopoDS_Shape GEOMBase::GetShapeFromIOR(QString IOR)
{
TopoDS_Shape result;
- if(IOR.stripWhiteSpace().isEmpty())
+ if(IOR.trimmed().isEmpty())
return result;
- CORBA::Object_var obj = GeometryGUI::GetORB()->string_to_object((char*)(IOR.latin1()));
+ CORBA::Object_var obj = SalomeApp_Application::orb()->string_to_object(IOR.toLatin1().data());
if(CORBA::is_nil(obj))
return result;
GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( obj );
if (GeomObject->_is_nil())
return result;
- result = GeometryGUI::GetGeomGUI()->GetShapeReader().GetShape(GeometryGUI::GetGeomGUI()->GetGeomGen(), GeomObject);
+ result = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
return result;
}
// function : GetTopoFromSelection()
// purpose : Define tds from a single selection and retuen true
//=======================================================================
-bool GEOMBase::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds)
+bool GEOMBase::GetTopoFromSelection(const SALOME_ListIO& aList, TopoDS_Shape& tds)
{
- if(Sel->IObjectCount() != 1)
+ if(aList.Extent() != 1)
return false;
- Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
+ Handle(SALOME_InteractiveObject) IO = aList.First();
/* case SObject */
if(IO->hasEntry()) {
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if(!obj->_is_nil()) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return false;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) obj ( aStudy->FindObjectID(IO->getEntry()) );
+ _PTR(GenericAttribute) anAttr;
+ if( obj ) {
if(obj->FindAttribute(anAttr, "AttributeIOR")) {
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- tds = GetShapeFromIOR(anIOR->Value());
+ _PTR(AttributeIOR) anIOR ( anAttr );
+ tds = GetShapeFromIOR(anIOR->Value().c_str());
if(tds.IsNull())
return false;
else
// function : GetNameOfSelectedIObjects()
// purpose : Define the name geom++ or other name of mono or multi sel.
//=======================================================================
-int GEOMBase::GetNameOfSelectedIObjects( SALOME_Selection* theSel,
+int GEOMBase::GetNameOfSelectedIObjects( const SALOME_ListIO& aList,
QString& theName,
const bool theShapesOnly )
{
if ( !theShapesOnly )
- {
- int nbSel = theSel->IObjectCount();
- if ( nbSel == 1 )
{
- Handle(SALOME_InteractiveObject) anIObj = theSel->firstIObject();
- theName = anIObj->getName();
- }
- else
- theName = QObject::tr("%1_objects").arg(nbSel);
+ int nbSel = aList.Extent();
+ if ( nbSel == 1 )
+ {
+ Handle(SALOME_InteractiveObject) anIObj = aList.First();
+ if(anIObj->hasEntry()) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return nbSel;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) obj ( aStudy->FindObjectID(anIObj->getEntry()) );
+
+ _PTR(GenericAttribute) anAttr;
+
+ if ( obj && obj->FindAttribute( anAttr, "AttributeName") )
+ {
+ _PTR(AttributeName) aNameAttr ( anAttr );
+ theName = aNameAttr->Value().c_str();
+ }
+ }
+ }
+ else
+ theName = QObject::tr("%1_objects").arg(nbSel);
- return nbSel;
- }
+ return nbSel;
+ }
else
- {
- QStringList aNames;
- GEOM::ListOfGO anObjs;
- ConvertListOfIOInListOfGO( theSel->StoredIObjects(), anObjs, theShapesOnly );
- if ( anObjs.length() == 1 )
- theName = GetName( anObjs[ 0 ] );
- else
- theName = QString( "%1_objects" ).arg( anObjs.length() );
-
- return anObjs.length();
- }
+ {
+ GEOM::ListOfGO anObjs;
+ ConvertListOfIOInListOfGO( aList, anObjs, theShapesOnly );
+ if ( anObjs.length() == 1 ) {
+ theName = GetName( anObjs[ 0 ] );
+ }
+ else
+ theName = QString( "%1_objects" ).arg( anObjs.length() );
+
+ return anObjs.length();
+ }
}
{
case TopAbs_COMPOUND:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_COMPOUND"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_COMPOUND").toLatin1().constData());
return true;
}
case TopAbs_COMPSOLID:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_COMPOUNDSOLID")) ;
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_COMPOUNDSOLID").toLatin1().constData()) ;
return true ;
}
case TopAbs_SOLID:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SOLID")) ;
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SOLID").toLatin1().constData()) ;
return true ;
}
case TopAbs_SHELL:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SHELL")) ;
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SHELL").toLatin1().constData()) ;
return true ;
}
case TopAbs_FACE:
{
BRepAdaptor_Surface surf(TopoDS::Face(aShape));
if(surf.GetType() == GeomAbs_Plane) {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_PLANE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_PLANE").toLatin1().constData());
return true;
}
else if(surf.GetType() == GeomAbs_Cylinder) {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFCYLINDER"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFCYLINDER").toLatin1().constData());
return true;
}
else if(surf.GetType() == GeomAbs_Sphere) {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFSPHERE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFSPHERE").toLatin1().constData());
return true ;
}
else if(surf.GetType() == GeomAbs_Torus) {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFTORUS"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFTORUS").toLatin1().constData());
return true ;
}
else if(surf.GetType() == GeomAbs_Cone) {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFCONE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFCONE").toLatin1().constData());
return true ;
}
else {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_FACE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_FACE").toLatin1().constData());
return true;
}
}
case TopAbs_WIRE:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_WIRE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_WIRE").toLatin1().constData());
return true;
}
case TopAbs_EDGE:
BRepAdaptor_Curve curv(TopoDS::Edge(aShape));
if(curv.GetType() == GeomAbs_Line) {
if((Abs(curv.FirstParameter()) >= 1E6) || (Abs(curv.LastParameter()) >= 1E6))
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_LINE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_LINE").toLatin1().constData());
else
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_EDGE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_EDGE").toLatin1().constData());
return true;
}
else if(curv.GetType() == GeomAbs_Circle) {
if(curv.IsClosed())
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_CIRCLE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_CIRCLE").toLatin1().constData());
else
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_ARC"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_ARC").toLatin1().constData());
return true;
}
else {
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_EDGE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_EDGE").toLatin1().constData());
return true;
}
}
case TopAbs_VERTEX:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_VERTEX"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_VERTEX").toLatin1().constData());
return true;
}
case TopAbs_SHAPE:
{
- aTypeString = CORBA::string_dup(QObject::tr("GEOM_SHAPE"));
+ aTypeString = CORBA::string_dup(QObject::tr("GEOM_SHAPE").toLatin1().constData());
return true;
}
}
Handle(GEOM_AISShape) resultShape;
testResult = false;
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::SObject_var anObj = aStudy->FindObjectIOR( IOR );
- if ( anObj->_is_nil() )
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return resultShape;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) anObj ( aStudy->FindObjectIOR( IOR ) );
+ if ( !anObj )
return resultShape;
- int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
- for(int i = 0; i < nbSf; i++) {
- QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i);
- if(sf->getTypeView() == VIEW_OCC) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
- Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+ QList<SUIT_ViewWindow*> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
+
+ QListIterator<SUIT_ViewWindow*> it( aViewWindowsList );
+ while ( it.hasNext() ) {
+ SUIT_ViewWindow* aVW = it.next();
+ if (aVW && aVW->getViewManager()->getType() == OCCViewer_Viewer::Type()) {
+ Handle (AIS_InteractiveContext) ic = ((OCCViewer_Viewer*)aVW->getViewManager()->getViewModel())->getAISContext();
AIS_ListOfInteractive List;
ic->DisplayedObjects(List);
Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
if(aSh->hasIO()) {
Handle(SALOME_InteractiveObject) GIO = Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
- if(GIO->hasEntry() && strcmp(GIO->getEntry(), anObj->GetID()) == 0) {
+ if(GIO->hasEntry() && strcmp(GIO->getEntry(), anObj->GetID().c_str()) == 0) {
if(!onlyInActiveView ||
- sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) {
+ aVW == SUIT_Session::session()->activeApplication()->desktop()->activeWindow()) {
testResult = true;
resultShape = aSh;
return resultShape;
{
testResult = false;
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::SObject_var anObj = aStudy->FindObjectIOR( IOR );
- if ( anObj->_is_nil() )
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return GEOM_Actor::New();
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) anObj ( aStudy->FindObjectIOR( IOR ) );
+ if ( !anObj )
return GEOM_Actor::New();
- int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
- for(int i = 0; i < nbSf; i++) {
- QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i);
- if(sf->getTypeView() == VIEW_VTK) {
- vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
+ QList<SUIT_ViewWindow*> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
+
+ QListIterator<SUIT_ViewWindow*> it( aViewWindowsList );
+ while ( it.hasNext() ) {
+ SUIT_ViewWindow* aVW = it.next();
+ if (aVW && aVW->getViewManager()->getType() == SVTK_Viewer::Type()) {
+ SVTK_ViewWindow* aVTKViewWindow = dynamic_cast<SVTK_ViewWindow*>( aVW );
+ if( !aVTKViewWindow )
+ continue;
+ vtkRenderer* Renderer = aVTKViewWindow->getRenderer();
vtkActorCollection* theActors = Renderer->GetActors();
theActors->InitTraversal();
vtkActor *ac = theActors->GetNextActor();
GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(ac);
if(anActor->hasIO()) {
Handle(SALOME_InteractiveObject) GIO = Handle(SALOME_InteractiveObject)::DownCast(anActor->getIO());
- if(GIO->hasEntry() && strcmp(GIO->getEntry(), anObj->GetID()) == 0) {
+ if(GIO->hasEntry() && strcmp(GIO->getEntry(), anObj->GetID().c_str()) == 0) {
if(!onlyInActiveView ||
- sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) {
+ aVW == SUIT_Session::session()->activeApplication()->desktop()->activeWindow()) {
testResult = true;
return anActor;
}
if ( theIO.IsNull() || !theIO->hasEntry() )
return Handle(AIS_InteractiveObject)();
- int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
-
- for ( int i = 0; i < nbSf; i++ )
- {
- QAD_StudyFrame* aStudyFrame =
- QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame( i );
+ QList<SUIT_ViewWindow*> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
- if ( aStudyFrame->getTypeView() != VIEW_OCC )
+ QListIterator<SUIT_ViewWindow*> it( aViewWindowsList );
+ while ( it.hasNext() ) {
+ SUIT_ViewWindow* aVW = it.next();
+ if (!aVW || aVW->getViewManager()->getType() != OCCViewer_Viewer::Type())
continue;
-
- OCCViewer_Viewer3d* v3d =
- ((OCCViewer_ViewFrame*)aStudyFrame->getRightFrame()->getViewFrame())->getViewer();
-
- Handle(AIS_InteractiveContext) anIC = v3d->getAISContext();
+ Handle (AIS_InteractiveContext) anIC = ((OCCViewer_Viewer*)aVW->getViewManager()->getViewModel())->getAISContext();
AIS_ListOfInteractive aList;
anIC->DisplayedObjects( aList );
{
Handle(SALOME_InteractiveObject) anObj =
Handle(SALOME_InteractiveObject)::DownCast( anIter.Value()->GetOwner() );
-
+
if( !anObj.IsNull() && strcmp( anObj->getEntry(), theIO->getEntry() ) == 0 )
{
if( isOnlyInActiveView )
{
- if ( aStudyFrame == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame() )
+ if ( aVW == SUIT_Session::session()->activeApplication()->desktop()->activeWindow() )
return anIter.Value();
}
else
}
}
}
-
+
return Handle(AIS_InteractiveObject)();
}
testResult = false;
return res;
}
-
- int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
- for(int i = 0; i < nbSf; i++) {
- QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i);
- if(sf->getTypeView() == VIEW_OCC) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
- Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ QList<SUIT_ViewWindow*> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
+
+ QListIterator<SUIT_ViewWindow*> it( aViewWindowsList );
+ while ( it.hasNext() ) {
+ SUIT_ViewWindow* aVW = it.next();
+ if (aVW && aVW->getViewManager()->getType() == OCCViewer_Viewer::Type()) {
+ Handle (AIS_InteractiveContext) ic = ((OCCViewer_Viewer*)aVW->getViewManager()->getViewModel())->getAISContext();
AIS_ListOfInteractive List;
ic->DisplayedObjects(List);
AIS_ListOfInteractive List1;
ic->ObjectsInCollector(List1);
List.Append(List1);
-
+
AIS_ListIteratorOfListOfInteractive ite(List);
while(ite.More())
{
{
if(onlyInActiveView)
{
- if(sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame())
+ if(aVW == SUIT_Session::session()->activeApplication()->desktop()->activeWindow())
{
testResult = true;
return aSh;
}
}
ite.Next();
- }
+ }
}
}
testResult = false;
{
GEOM::GEOM_Object_var aShape;
testResult = false;
-
+
/* case SObject */
if(IO->hasEntry()) {
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if(!obj->_is_nil()) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return GEOM::GEOM_Object::_nil();
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) obj ( aStudy->FindObjectID(IO->getEntry()) );
+ _PTR(GenericAttribute) anAttr;
+ if(obj) {
if(obj->FindAttribute(anAttr, "AttributeIOR")) {
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- aShape = GeometryGUI::GetGeomGUI()->GetGeomGen()->GetIORFromString(anIOR->Value());
+ _PTR(AttributeIOR) anIOR ( anAttr );
+ aShape = GeometryGUI::GetGeomGen()->GetIORFromString(anIOR->Value().c_str());
if(!CORBA::is_nil(aShape))
testResult = true;
return aShape._retn();
//=======================================================================
// function : ConvertListOfIOInListOfIOR()
-// purpose :
+// purpose :
//=======================================================================
void GEOMBase::ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, GEOM::string_array& listIOR)
{
- int nbSel = aList.Extent();
+ int nbSel = aList.Extent();
listIOR.length(nbSel);
int j=0;
SALOME_ListIteratorOfListIO It(aList);
- for(int i=0; It.More(); It.Next(), i++) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
+ ( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ for (int i=0; It.More(); It.Next(), i++) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
- if(IObject->hasEntry()) {
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if(!obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR")) {
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
- CORBA::ORB_var& _orb = init.orb();
- CORBA::String_var theValue = anIOR->Value();
- CORBA::Object_var theObj = _orb->string_to_object(theValue);
- if(theObj->_is_a("IDL:GEOM/GEOM_Object:1.0")) {
- listIOR[j] = CORBA::string_dup(theValue);
+ if (IObject->hasEntry()) {
+ _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
+ _PTR(GenericAttribute) anAttr;
+ if (obj && obj->FindAttribute(anAttr, "AttributeIOR")) {
+ _PTR(AttributeIOR) anIOR (anAttr);
+ //CORBA::Object_var theObj = dynamic_cast<SALOMEDS_Study*>
+ // (aStudy.get())->ConvertIORToObject(anIOR->Value());
+ CORBA::Object_var theObj = GeometryGUI::ClientSObjectToObject(obj);
+ if (!CORBA::is_nil(theObj) && theObj->_is_a("IDL:GEOM/GEOM_Object:1.0")) {
+ listIOR[j] = CORBA::string_dup(anIOR->Value().c_str());
j++;
}
}
- }
+ }
}
listIOR.length(j);
}
//=======================================================================
// function : ConvertIOinGEOMObject()
-// purpose :
+// purpose :
//=======================================================================
-GEOM::GEOM_Object_ptr GEOMBase::ConvertIOinGEOMObject( const Handle(SALOME_InteractiveObject)& theIO,
+GEOM::GEOM_Object_ptr GEOMBase::ConvertIOinGEOMObject( const Handle(SALOME_InteractiveObject)& theIO,
Standard_Boolean& theResult )
-{
+{
theResult = Standard_False;
GEOM::GEOM_Object_var aReturnObject;
if ( !theIO.IsNull() )
{
const char* anEntry = theIO->getEntry();
- SALOMEDS::SObject_var aSObj = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->FindObjectID( anEntry );
- if ( !CORBA::is_nil( aSObj ) )
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
+ ( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return GEOM::GEOM_Object::_nil();
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ _PTR(SObject) aSObj ( aStudy->FindObjectID( anEntry ) );
+
+ if (aSObj)
{
- aReturnObject = GEOM::GEOM_Object::_narrow( aSObj->GetObject() );
+ aReturnObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
theResult = !CORBA::is_nil( aReturnObject );
}
}
//=======================================================================
// function : ConvertListOfIOInListOfGO()
-// purpose :
+// purpose :
//=======================================================================
void GEOMBase::ConvertListOfIOInListOfGO( const SALOME_ListIO& theList,
GEOM::ListOfGO& theListGO,
const bool theShapesOnly )
{
- int nbSel = theList.Extent();
+ int nbSel = theList.Extent();
theListGO.length( nbSel );
SALOME_ListIteratorOfListIO anIter( theList );
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
int j = 0;
for ( int i=0; anIter.More(); anIter.Next(), i++ )
{
Handle(SALOME_InteractiveObject) anIObj = anIter.Value();
- SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( anIObj->getEntry() );
+ _PTR(SObject) aSObj ( aStudy->FindObjectID( anIObj->getEntry() ) );
- if ( !aSObj->_is_nil() )
+ if ( aSObj )
{
- GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aSObj->GetObject());
+ GEOM::GEOM_Object_var aGeomObj =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
if ( !CORBA::is_nil( aGeomObj ) && ( !theShapesOnly || IsShape( aGeomObj ) ) )
theListGO[ j++ ] = aGeomObj;
}
}
-
+
theListGO.length( j );
}
//=================================================================================
bool GEOMBase::CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone)
{
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE)
+ if(SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
+ != OCCViewer_Viewer::Type() || tds.ShapeType() != TopAbs_EDGE)
return false;
-
- OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
- Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
+
+ OCCViewer_ViewPort3d* vp3d = ((OCCViewer_ViewWindow*)SUIT_Session::session()->activeApplication()->desktop()->activeWindow())->getViewPort();
+ Handle( V3d_View) view3d = vp3d->getView();
Standard_Real Width, Height;
view3d->Size(Width, Height);
const Standard_Real aHeight = (Width + Height) / 50.0;
-
+
try {
Standard_Real first, last;
Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
curv->D1( param, middleParamPoint, V1);
if(V1.Magnitude() < Precision::Confusion())
return false;
-
+
/* Topology orientation not geom orientation */
if(tds.Orientation() == TopAbs_REVERSED)
V1 *= -1.0;
-
+
gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1));
const Standard_Real radius1 = aHeight / 5.0;
if(radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion()) {
}
catch(Standard_Failure) {
// OCC failures are hard to catch in GUI.
- // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
+ // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
// in SALOME environment : compilation error !
}
return false;
//=================================================================================
// function : GetBipointDxDyDz()
-// purpose :
+// purpose :
//=================================================================================
void GEOMBase::GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz)
{
}
-//=======================================================================
-// function : Parameter()
-// purpose : return a parameter (float) from a dialog box
-//
-// avalue1 : is a float or integer used as a default value displayed
-// aTitle1 : is the title for aValue1
-// aTitle : is the main title
-// bottom : maximum value to be entered
-// top : minimum value to be entered
-// decimals : number of decimals
-//=======================================================================
-double GEOMBase::Parameter(Standard_Boolean& res, const char* aValue1, const char* aTitle1, const char* aTitle, const double bottom, const double top, const int decimals)
-{
- GEOMBase_aParameterDlg * Dialog = new GEOMBase_aParameterDlg(aValue1, aTitle1, QAD_Application::getDesktop(), aTitle, TRUE, 0, bottom, top, decimals);
- int r = Dialog->exec();
- float X = 0.0;
- if(r == QDialog::Accepted) {
- res = Standard_True;
- X = Dialog->getValue();
- }
- else
- res = Standard_False;
- delete Dialog;
- return X;
-}
-
-
//=======================================================================
// function : SelectionByNameInDialogs()
// purpose : Called when user has entered a name of object in a LineEdit.
-// : The selection is changed. Dialog box will receive the
+// : The selection is changed. Dialog box will receive the
// : corresponding signal to manage this event.
//=======================================================================
-bool GEOMBase::SelectionByNameInDialogs(QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel)
+bool GEOMBase::SelectionByNameInDialogs(QWidget* aWidget, const QString& objectUserName, const SALOME_ListIO& aList)
{
/* Find SObject with name in component GEOM */
- SALOMEDS::Study_var ST = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject;
- listSO = ST->FindObjectByName(objectUserName, "GEOM");
-
- if(listSO->length() < 1) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return false;
+ _PTR(Study) ST = appStudy->studyDS();
+
+ std::vector<_PTR(SObject)> listSO;
+ listSO = ST->FindObjectByName(objectUserName.toStdString(), "GEOM");
+
+ if(listSO.size() < 1) {
const QString caption = QObject::tr("GEOM_WRN_WARNING");
const QString text = QObject::tr("GEOM_NAME_INCORRECT");
const QString button0 = QObject::tr("GEOM_BUT_OK");
- QAD_MessageBox::error1(aWidget, caption, text, button0);
+ SUIT_MessageBox::critical(aWidget, caption, text, button0);
return false;
}
/* More than one object with same name */
- if(listSO->length() > 1) {
+ if(listSO.size() > 1) {
const QString caption = QObject::tr("GEOM_WRN_WARNING");
const QString text = QObject::tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE");
const QString button0 = QObject::tr("GEOM_BUT_OK") ;
- QAD_MessageBox::error1(aWidget, caption, text, button0) ;
+ SUIT_MessageBox::critical(aWidget, caption, text, button0) ;
+ listSO.clear();
return false;
}
- SALOMEDS::SObject_var theObj = listSO[0];
+ _PTR(SObject) theObj ( listSO[0] );
/* Create a SALOME_InteractiveObject with a SALOME::SObject */
- Standard_CString anEntry = theObj->GetID();
- char* aCopyobjectUserName = CORBA::string_dup(objectUserName);
- Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject(anEntry, "GEOM", aCopyobjectUserName);
+ char* aCopyobjectUserName = CORBA::string_dup(objectUserName.toLatin1().constData());
+ Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject(theObj->GetID().c_str(), "GEOM", aCopyobjectUserName);
delete(aCopyobjectUserName);
/* Add as a selected object */
/* Clear any previous selection : */
- /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
- Sel->ClearIObjects();
- Sel->AddIObject(SI);
+ /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
+ // Sel->ClearIObjects(); //mzn
+ // Sel->AddIObject(SI); //mzn
return true;
}
bool GEOMBase::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
{
/* Here the position is on the bottom right corner - 10 */
- QAD_Desktop* PP = QAD_Application::getDesktop();
+ SUIT_Desktop* PP = SUIT_Session::session()->activeApplication()->desktop();
x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
- return true;
+ return true;
}
//=======================================================================
QString GEOMBase::GetDefaultName(const QString& theOperation)
{
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- int aNumber = 0;
- QString aName;
- SALOMEDS::SObject_var obj;
+ QString aName = "";
+
+ // collect all object names of GEOM component
+ SalomeApp_Study* appStudy =
+ dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !appStudy ) return aName;
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ std::set<std::string> aSet;
+ _PTR(SComponent) aGeomCompo (aStudy->FindComponent("GEOM"));
+ if (aGeomCompo) {
+ _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeomCompo));
+ _PTR(SObject) obj;
+ for (it->InitEx(true); it->More(); it->Next()) {
+ obj = it->Value();
+ aSet.insert(obj->GetName());
+ }
+ }
- do
- {
- aName = theOperation+"_"+QString::number(++aNumber);
- obj = aStudy->FindObject(aName);
- }
- while (!obj->_is_nil());
+ // build a unique name
+ int aNumber = 0;
+ bool isUnique = false;
+ while (!isUnique) {
+ aName = theOperation + "_" + QString::number(++aNumber);
+ isUnique = (aSet.count(aName.toStdString()) == 0);
+ }
return aName;
}
{
QString anErrorCode(theErrorCode);
QString aComment(theComment);
-
+
QString aText = "";
if (!anErrorCode.isEmpty())
- aText.append("\n" + QObject::tr(anErrorCode));
+ aText.append("\n" + QObject::tr(anErrorCode.toLatin1().constData()));
if (!aComment.isEmpty())
aText.append("\n" + QString(theComment));
-
- QAD_MessageBox::error1( QAD_Application::getDesktop(), QObject::tr( "GEOM_ERROR" ),
- QObject::tr("GEOM_PRP_ABORT") + aText, "OK" );
+
+ SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), QObject::tr( "GEOM_ERROR" ),
+ QObject::tr("GEOM_PRP_ABORT") + aText, "OK" );
}
if ( theIOR == NULL || strlen( theIOR ) == 0 )
return anObject._retn(); // returning nil object
- anObject = GEOM::GEOM_Object::_narrow( GeometryGUI::GetORB()->string_to_object( theIOR ) );
+ anObject = GEOM::GEOM_Object::_narrow( SalomeApp_Application::orb()->string_to_object( theIOR ) );
return anObject._retn();
}
if ( CORBA::is_nil( theObject ) )
return NULL;
- return GeometryGUI::GetORB()->object_to_string( theObject );
+ return SalomeApp_Application::orb()->object_to_string( theObject );
}
//=======================================================================
{
if ( !CORBA::is_nil( theObject ) )
{
- TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGUI()->GetGeomGen(), theObject );
+ TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObject );
if ( !aTopoDSShape.IsNull() && ( theType == TopAbs_SHAPE || theType == aTopoDSShape.ShapeType() ) )
{
theShape = aTopoDSShape;
// function : GetName()
// purpose : Get name of object
//=======================================================================
-const char* GEOMBase::GetName( GEOM::GEOM_Object_ptr theObj )
+QString GEOMBase::GetName( GEOM::GEOM_Object_ptr theObj )
{
- QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
-
- if ( aStudy )
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+
+ if ( appStudy )
{
- string anIOR = GeometryGUI::GetORB()->object_to_string( theObj );
- if ( anIOR != "" )
+ CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( theObj );
+ if ( strcmp(anIOR.in(), "") != 0 )
{
- SALOMEDS::SObject_var aSObj = aStudy->getStudyDocument()->FindObjectIOR( anIOR.c_str() );
- SALOMEDS::GenericAttribute_var anAttr;
-
- if ( !aSObj->_is_nil() && aSObj->FindAttribute( anAttr, "AttributeName") )
+ _PTR(SObject) aSObj ( appStudy->studyDS()->FindObjectIOR( std::string( anIOR ) ) );
+
+ _PTR(GenericAttribute) anAttr;
+
+ if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
{
- SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr );
- return aNameAttr->Value();
+ _PTR(AttributeName) aNameAttr ( anAttr );
+ return QString( aNameAttr->Value().c_str() );
}
}
}
-
- return "";
+
+ return QString("");
}
bool GEOMBase::IsShape( GEOM::GEOM_Object_ptr theObj )
{
return !theObj->_is_nil() && theObj->IsShape();
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-