1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : GEOMBase_Helper.cxx
25 // Author : Sergey ANIKIN
29 #include <SUIT_ViewModel.h>
31 #include "GEOMBase_Helper.h"
33 #include "GEOM_Operation.h"
34 #include "GeometryGUI.h"
35 #include "GEOM_Displayer.h"
36 #include "GEOMImpl_Types.hxx"
38 #include <SUIT_Session.h>
39 #include <SUIT_ViewWindow.h>
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_OverrideCursor.h>
43 #include <SalomeApp_Module.h>
44 #include <SalomeApp_Application.h>
45 #include <SalomeApp_Study.h>
46 #include <LightApp_SelectionMgr.h>
47 #include <SalomeApp_Tools.h>
48 #include <SalomeApp_DataModel.h>
50 #include <OCCViewer_ViewModel.h>
51 #include <SVTK_ViewModel.h>
53 #include <OB_Browser.h>
55 #include <TColStd_MapOfInteger.hxx>
56 #include <TCollection_AsciiString.hxx>
60 #include <SALOMEDSClient.hxx>
63 //================================================================
64 // Function : getActiveView
65 // Purpose : Get active view window, returns 0 if no open study frame
66 //================================================================
67 static SUIT_ViewWindow* getActiveView()
69 SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
71 return SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
77 //================================================================
78 // Function : getGeomEngine
79 // Purpose : Static method
80 //================================================================
81 GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
83 return GeometryGUI::GetGeomGen();
86 //================================================================
87 // Function : GEOMBase_Helper
89 //================================================================
90 GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
91 : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false )
95 //================================================================
96 // Function : ~GEOMBase_Helper
98 //================================================================
99 GEOMBase_Helper::~GEOMBase_Helper()
101 if ( !SUIT_Session::session()->activeApplication()->desktop() )
104 if ( myPreview.size() )
109 globalSelection( GEOM_ALLOBJECTS, true );
115 //================================================================
116 // Function : display
118 //================================================================
119 void GEOMBase_Helper::display( const ObjectList& objList, const bool updateView )
121 ObjectList::const_iterator it;
122 for ( it = objList.begin(); it != objList.end(); it++ ) {
123 display( *it, false );
125 if ( !objList.empty() && updateView )
126 getDisplayer()->UpdateViewer();
129 //================================================================
130 // Function : display
131 // Purpose : Display object.
132 // Important : Object must be already in study
133 //================================================================
134 void GEOMBase_Helper::display( GEOM::GEOM_Object_ptr object, const bool updateView )
136 // Unset color of shape ( this color may be set during preview displaying )
137 // Default color will be used
138 getDisplayer()->UnsetColor();
139 getDisplayer()->UnsetWidth();
141 // Enable activisation of selection
142 getDisplayer()->SetToActivate( true );
145 getDisplayer()->Display( object, updateView );
148 //================================================================
151 //================================================================
152 void GEOMBase_Helper::erase( const ObjectList& objList, const bool updateView )
154 ObjectList::const_iterator it = objList.begin();
155 for ( ; it != objList.end(); it++ ) {
158 if ( !objList.empty() && updateView )
159 getDisplayer()->UpdateViewer();
162 //================================================================
165 //================================================================
166 void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView )
168 if ( !object->_is_nil() ) {
169 string entry = getEntry( object );
170 getDisplayer()->Erase( new SALOME_InteractiveObject(
171 entry.c_str(), "GEOM", strdup( GEOMBase::GetName( object ) ) ), true, updateView );
175 //================================================================
176 // Function : redisplay
178 //================================================================
179 void GEOMBase_Helper::redisplay( const ObjectList& objList,
180 const bool withChildren,
181 const bool updateView )
183 ObjectList::const_iterator it = objList.begin();
184 for ( ; it != objList.end(); it++ ) {
185 redisplay( *it, withChildren, false );
187 if ( !objList.empty() && updateView )
188 getDisplayer()->UpdateViewer();
191 //================================================================
192 // Function : redisplay
194 //================================================================
195 void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
196 const bool withChildren,
197 const bool updateView )
199 if ( !object->_is_nil() ) {
200 // Unset color of shape ( this color may be set during preview displaying )
201 // Default color will be used
202 getDisplayer()->UnsetColor();
203 getDisplayer()->UnsetWidth();
205 // Enable activisation of selection
206 getDisplayer()->SetToActivate( true );
208 string entry = getEntry( object );
209 getDisplayer()->Redisplay(new SALOME_InteractiveObject
210 (entry.c_str(), "GEOM", strdup(GEOMBase::GetName(object))), false);
213 if ( withChildren ) {
214 SalomeApp_Study* aDoc = getStudy();
215 if ( aDoc && aDoc->studyDS() ) {
216 _PTR(Study) aStudy = aDoc->studyDS();
217 _PTR(SObject) aSObj (aStudy->FindObjectIOR(SalomeApp_Application::orb()->object_to_string(object)));
219 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
220 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
221 GEOM::GEOM_Object_var aChild = GEOM::GEOM_Object::_narrow
222 (GeometryGUI::ClientSObjectToObject(anIt->Value()));
223 if ( !CORBA::is_nil( aChild ) ) {
224 if ( !aChild->_is_nil() ) {
225 string entry = getEntry( aChild );
226 getDisplayer()->Redisplay( new SALOME_InteractiveObject(
227 entry.c_str(), "GEOM", strdup( GEOMBase::GetName( aChild ) ) ), false );
236 getDisplayer()->UpdateViewer();
239 //================================================================
240 // Function : displayPreview
241 // Purpose : Method for displaying preview based on execute() results
242 //================================================================
243 void GEOMBase_Helper::displayPreview( const bool activate,
245 const bool toRemoveFromEngine,
246 const double lineWidth )
250 if ( !isValid( msg ) )
252 erasePreview( update );
257 erasePreview( false );
260 SUIT_OverrideCursor wc;
262 if ( !execute( objects ) || !getOperation()->IsDone() ) {
266 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it )
268 displayPreview( *it, true, activate, false, lineWidth );
269 if ( toRemoveFromEngine )
270 getGeomEngine()->RemoveObject( *it );
274 catch( const SALOME::SALOME_Exception& e ) {
275 SalomeApp_Tools::QtCatchCorbaException( e );
284 //================================================================
285 // Function : displayPreview
286 // Purpose : Method for displaying preview of resulting shape
287 //================================================================
288 void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object,
292 const double lineWidth )
294 // Set color for preview shape
295 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
297 // set width of displayed shape
298 getDisplayer()->SetWidth( lineWidth );
300 // Disable activation of selection
301 getDisplayer()->SetToActivate( activate );
303 // Make a reference to GEOM_Object
304 getDisplayer()->SetName( SalomeApp_Application::orb()->object_to_string( object ) );
307 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( object );
308 if ( aPrs == 0 || aPrs->IsNull() )
312 displayPreview( aPrs, append, update );
314 getDisplayer()->UnsetName();
316 // Enable activation of displayed objects
317 getDisplayer()->SetToActivate( true );
320 //================================================================
321 // Function : displayPreview
322 // Purpose : Method for displaying arbitrary preview objects (not limited to shapes)
323 //================================================================
324 void GEOMBase_Helper::displayPreview( const SALOME_Prs* prs,
329 erasePreview( false );
331 // remember current view frame to make correct erase preview later
332 myViewWindow = getActiveView();
334 if ( myViewWindow == 0 )
338 SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
339 if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
340 aViewManager->getType() == SVTK_Viewer::Type() )
342 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
343 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
345 aView->Display( prs );
348 // Add prs to the preview list
349 myPreview.push_back( (SALOME_Prs*)prs );
353 getDisplayer()->UpdateViewer();
356 //================================================================
357 // Function : erasePreview
359 //================================================================
360 void GEOMBase_Helper::erasePreview( const bool update )
362 // check view frame where the preview was displayed
363 bool vfOK = checkViewWindow() && myViewWindow;
364 // Iterate through presentations and delete them
365 for ( PrsList::iterator anIter = myPreview.begin(); anIter != myPreview.end(); ++anIter ) {
368 SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
369 if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
370 aViewManager->getType() == SVTK_Viewer::Type() )
372 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
373 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
375 aView->Erase( *anIter, true );
387 //================================================================
388 // Function : localSelection
389 // Purpose : Activate selection of objects of a given type
390 // IMPORTANT : Works after localSelection( ... ) method call only
391 //================================================================
392 void GEOMBase_Helper::activate( const int theType )
394 if (!getStudy()) return;
395 _PTR(Study) aStudy = getStudy()->studyDS();
396 _PTR(SComponent) aGeom ( aStudy->FindComponent( "GEOM" ) );
401 _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( aGeom ) );
402 for ( ; anIter->More(); anIter->Next() )
404 _PTR(SObject) aSO ( anIter->Value() );
407 _PTR(SObject) aRefSO;
408 if ( !aSO->ReferencedObject( aRefSO ) )
410 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow
411 (GeometryGUI::ClientSObjectToObject(aSO));
412 if ( !anObj->_is_nil() && anObj->GetType() == theType )
413 aList.Append( new SALOME_InteractiveObject( aSO->GetID().c_str(), "GEOM", aSO->GetName().c_str()) );
418 getDisplayer()->LocalSelection( aList, 0 );
421 //================================================================
422 // Function : localSelection
423 // Purpose : Activate selection of subshapes in accordance with mode
424 // theMode is from TopAbs_ShapeEnum
425 //================================================================
426 void GEOMBase_Helper::localSelection( const ObjectList& theObjs, const int theMode )
428 SALOME_ListIO aListOfIO;
430 ObjectList::const_iterator anIter = theObjs.begin();
431 for ( ; anIter != theObjs.end(); ++anIter )
433 GEOM::GEOM_Object_ptr anObj = *anIter;
434 if ( anObj->_is_nil() )
436 string aEntry = getEntry( anObj );
438 aListOfIO.Append( new SALOME_InteractiveObject(
439 aEntry.c_str(), "GEOM", strdup( GEOMBase::GetName( anObj ) ) ) );
442 getDisplayer()->LocalSelection( aListOfIO, theMode );
445 //================================================================
446 // Function : localSelection
447 // Purpose : Activate selection of subshapes in accordance with mode
448 // theMode is from TopAbs_ShapeEnum
449 //================================================================
450 void GEOMBase_Helper::localSelection( GEOM::GEOM_Object_ptr obj, const int mode )
452 // If object is null local selection for all objects is activated
453 if ( obj->_is_nil() ) {
454 getDisplayer()->LocalSelection( Handle(SALOME_InteractiveObject)(), mode );
459 objList.push_back( obj );
460 localSelection( objList, mode );
464 //================================================================
465 // Function : globalSelection
466 // Purpose : Activate selection of subshapes. Set selection filters
467 // in accordance with mode. theMode is from GEOMImpl_Types
468 //================================================================
469 void GEOMBase_Helper::globalSelection( const int theMode, const bool update )
471 getDisplayer()->GlobalSelection( theMode, update );
474 //================================================================
475 // Function : globalSelection
476 // Purpose : Activate selection of subshapes. Set selection filters
477 // in accordance with mode. theMode is from GEOMImpl_Types
478 //================================================================
479 void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes,
482 getDisplayer()->GlobalSelection( theModes, update );
485 //================================================================
486 // Function : addInStudy
487 // Purpose : Add object in study
488 //================================================================
489 void GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* theName )
494 _PTR(Study) aStudy = getStudy()->studyDS();
495 if ( !aStudy || theObj->_is_nil() )
498 GEOM::GEOM_Object_ptr aFatherObj = getFather( theObj );
500 getGeomEngine()->AddInStudy(GeometryGUI::ClientStudyToStudy(aStudy),
501 theObj, theName, aFatherObj);
504 //================================================================
505 // Function : updateObjBrowser
506 // Purpose : Update object browser
507 //================================================================
508 void GEOMBase_Helper::updateObjBrowser() const
510 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
512 CAM_Module* module = app->module( "Geometry" );
513 SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>( module );
515 appMod->updateObjBrowser( true );
520 //================================================================
521 // Function : updateViewer
522 // Purpose : Update active 3D view
523 //================================================================
524 void GEOMBase_Helper::updateViewer()
526 getDisplayer()->UpdateViewer();
529 //================================================================
530 // Function : getStudyId
531 // Purpose : Get study Id
532 //================================================================
533 int GEOMBase_Helper::getStudyId() const
537 anId = getStudy()->id();
541 //================================================================
542 // Function : getStudy
543 // Purpose : Returns the active study. It is recommended to use
544 // this method instead of direct desktop->getActiveStudy() calls
545 //================================================================
546 SalomeApp_Study* GEOMBase_Helper::getStudy() const
548 SUIT_Desktop* aDesktop = getDesktop();
552 QPtrList<SUIT_Application> anAppList = SUIT_Session::session()->applications();
554 SUIT_Application* anApp = 0;
555 for ( QPtrListIterator<SUIT_Application> it( anAppList ); it.current() ; ++it )
557 anApp = it.current();
558 if ( anApp->desktop() == aDesktop )
562 return dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
565 //================================================================
566 // Function : getEntry
568 //================================================================
569 char* GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const
571 SalomeApp_Study* study = getStudy();
573 string IOR = GEOMBase::GetIORFromObject( object);
575 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
577 return TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString();
584 //================================================================
585 // Function : getDisplayer
587 //================================================================
588 GEOM_Displayer* GEOMBase_Helper::getDisplayer()
591 myDisplayer = new GEOM_Displayer( getStudy() );
595 //================================================================
596 // Function : clearShapeBuffer
598 //================================================================
599 void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
601 if ( CORBA::is_nil( theObj ) )
604 string IOR = SalomeApp_Application::orb()->object_to_string( theObj );
605 TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) );
606 GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
608 if ( !getStudy() || !getStudy()->studyDS() )
611 _PTR(Study) aStudy = getStudy()->studyDS();
612 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( IOR ) );
616 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
617 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
618 _PTR(GenericAttribute) anAttr;
619 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
620 _PTR(AttributeIOR) anIOR ( anAttr );
621 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
622 GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
627 //================================================================
628 // Function : openCommand
630 //================================================================
631 bool GEOMBase_Helper::openCommand()
634 if ( !getStudy() || hasCommand() )
637 GEOM::GEOM_IOperations_var anOp = GEOM::GEOM_IOperations::_narrow( getOperation() );
638 if ( !anOp->_is_nil() ) {
639 myCommand = new GEOM_Operation( SUIT_Session::session()->activeApplication(), anOp.in() );
647 //================================================================
648 // Function : abortCommand
650 //================================================================
651 bool GEOMBase_Helper::abortCommand()
662 //================================================================
663 // Function : commitCommand
665 //================================================================
666 bool GEOMBase_Helper::commitCommand( const char* )
677 //================================================================
678 // Function : hasCommand
680 //================================================================
681 bool GEOMBase_Helper::hasCommand() const
683 return (bool)myCommand;
686 //================================================================
687 // Function : getOperation
689 //================================================================
690 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::getOperation()
692 if ( myOperation->_is_nil() )
693 myOperation = createOperation();
700 //================================================================
701 // Function : checkViewWindow
703 //================================================================
704 bool GEOMBase_Helper::checkViewWindow()
707 QPtrList<SUIT_ViewWindow> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
708 for ( QPtrListIterator<SUIT_ViewWindow> it( aViewWindowsList ); it.current(); ++it )
710 if ( myViewWindow == it.current() )
718 //================================================================
719 // Function : onAccept
720 // Purpose : This method should be called from dialog's slots onOk() and onApply()
721 // It perfroms user input validation, then it
722 // performs a proper operation and manages transactions, etc.
723 //================================================================
724 bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
726 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
727 if ( !appStudy ) return false;
728 _PTR(Study) aStudy = appStudy->studyDS();
730 bool aLocked = (_PTR(AttributeStudyProperties) (aStudy->GetProperties()))->IsLocked();
732 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
733 SUIT_MessageBox::warn1 ( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(),
734 QObject::tr("WRN_WARNING"),
735 QObject::tr("WRN_STUDY_LOCKED"),
736 QObject::tr("BUT_OK") );
741 if ( !isValid( msg ) ) {
746 erasePreview( false );
749 if ( ( !publish && !useTransaction ) || openCommand() ) {
750 SUIT_OverrideCursor wc;
751 SUIT_Session::session()->activeApplication()->putInfo( "" );
753 if ( !execute( objects ) || !getOperation()->IsDone() ) {
759 const int nbObjs = objects.size();
761 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
763 QString aName = getNewObjectName();
766 aName = getPrefix(*it);
768 // Try to find a unique name
769 aName = GEOMBase::GetDefaultName(aName);
771 // Don't check name uniqueness in case of numerous objects
772 aName = aName + "_" + QString::number(aNumber++);
775 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
776 if ( aName.isEmpty() )
777 aName = GEOMBase::GetDefaultName( getPrefix( *it ) );
779 addInStudy( *it, aName.latin1() );
781 display( *it, false );
784 // asv : fix of PAL6454. If publish==false, then the original shape
785 // was modified, and need to be re-cached in GEOM_Client before redisplay
786 clearShapeBuffer( *it );
787 // withChildren=true, updateView=false
788 redisplay( *it, true, false );
795 SUIT_Session::session()->activeApplication()->putInfo( QObject::tr("GEOM_PRP_DONE") );
802 catch( const SALOME::SALOME_Exception& e ) {
803 SalomeApp_Tools::QtCatchCorbaException( e );
813 //================================================================
814 // Function : showError
815 // Purpose : Shows a message box with infromation about an error taken from getOperation()->GetErrorCode()
816 //================================================================
817 void GEOMBase_Helper::showError()
820 if ( !getOperation()->_is_nil() )
821 msg = QObject::tr( getOperation()->GetErrorCode() );
824 msg = QObject::tr( "GEOM_PRP_ABORT" );
826 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
827 QObject::tr( "GEOM_ERROR_STATUS" ),
829 QObject::tr( "BUT_OK" ) );
832 //================================================================
833 // Function : showError
834 // Purpose : Shows a error message followed by <msg>
835 //================================================================
836 void GEOMBase_Helper::showError( const QString& msg )
838 QString str( QObject::tr( "GEOM_INCORRECT_INPUT" ) );
839 if ( !msg.isEmpty() )
841 SUIT_MessageBox::error1(SUIT_Session::session()->activeApplication()->desktop(), QObject::tr( "GEOM_ERROR" ), str, QObject::tr( "BUT_OK" ) );
844 //////////////////////////////////////////////////////////////////
845 // Virtual methods to be redefined in dialogs
846 //////////////////////////////////////////////////////////////////
848 //================================================================
849 // Function : createOperation
850 // Purpose : Redefine this method to return proper IOperation reference
851 //================================================================
852 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::createOperation()
854 GEOM::GEOM_IOperations_var aNilOp;
855 return aNilOp._retn();
858 //================================================================
859 // Function : isValid
860 // Purpose : Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
861 //================================================================
862 bool GEOMBase_Helper::isValid( QString& )
867 //================================================================
868 // Function : execute
869 // Purpose : This method is called by onAccept().
870 // It should perform the required operation and put all new or modified objects into
871 // <objects> argument.Should return <false> if some error occurs during its execution.
872 //================================================================
873 bool GEOMBase_Helper::execute( ObjectList& objects )
878 //================================================================
879 // Function : getFather
880 // Purpose : This method is called by addInStudy(). It should return a father object
881 // for <theObj> or a nil reference if <theObj> should be published
882 // as a top-level object.
883 //================================================================
884 GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj )
886 return GEOM::GEOM_Object::_nil();
889 //================================================================
890 // Function : getNewObjectName
891 // Purpose : Redefine this method to return proper name for a new object
892 //================================================================
893 const char* GEOMBase_Helper::getNewObjectName() const
898 //================================================================
899 // Function : getPrefix
900 // Purpose : Get prefix for name of created object
901 //================================================================
902 QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const
904 if ( !myPrefix.isEmpty() || theObj->_is_nil() )
907 //TopoDS_Shape aShape;
908 //if ( !GEOMBase::GetShape( theObj, aShape ) )
911 //long aType = aShape.ShapeType();
912 GEOM::shape_type aType = theObj->GetShapeType();
916 case GEOM::VERTEX : return QObject::tr( "GEOM_VERTEX" );
917 case GEOM::EDGE : return QObject::tr( "GEOM_EDGE" );
918 case GEOM::WIRE : return QObject::tr( "GEOM_WIRE" );
919 case GEOM::FACE : return QObject::tr( "GEOM_FACE" );
920 case GEOM::SHELL : return QObject::tr( "GEOM_SHELL" );
921 case GEOM::SOLID : return QObject::tr( "GEOM_SOLID" );
922 case GEOM::COMPSOLID: return QObject::tr( "GEOM_COMPOUNDSOLID" );
923 case GEOM::COMPOUND : return QObject::tr( "GEOM_COMPOUND" );
928 //================================================================
929 // Function : selectedIO
930 // Purpose : Return the list of selected SALOME_InteractiveObject's
931 //================================================================
932 const SALOME_ListIO& GEOMBase_Helper::selectedIO()
936 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
938 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
940 aSelMgr->selectedObjects( mySelected );
946 //================================================================
947 // Function : IObjectCount
948 // Purpose : Return the number of selected objects
949 //================================================================
950 int GEOMBase_Helper::IObjectCount()
952 return selectedIO().Extent();
955 //================================================================
956 // Function : firstIObject
957 // Purpose : Return the first selected object in the selected object list
958 //================================================================
959 Handle(SALOME_InteractiveObject) GEOMBase_Helper::firstIObject()
961 const SALOME_ListIO& aList = selectedIO();
962 return aList.Extent() > 0 ? aList.First() : Handle(SALOME_InteractiveObject)();
965 //================================================================
966 // Function : lastIObject
967 // Purpose : Return the last selected object in the selected object list
968 //================================================================
969 Handle(SALOME_InteractiveObject) GEOMBase_Helper::lastIObject()
971 const SALOME_ListIO& aList = selectedIO();
972 return aList.Extent() > 0 ? aList.Last() : Handle(SALOME_InteractiveObject)();
975 //================================================================
976 // Function : getDesktop
977 // Purpose : Returns myDesktop field. Initialized in constructor, usually as dynamic_cast<SUIT_Desktop*>(parentWidget())
978 //================================================================
979 SUIT_Desktop* GEOMBase_Helper::getDesktop() const