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.org
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 <SalomeApp_SelectionMgr.h>
47 #include <SalomeApp_Tools.h>
48 #include <SalomeApp_DataModel.h>
49 #include <SalomeApp_Module.h>
51 #include <OCCViewer_ViewModel.h>
52 #include <VTKViewer_ViewModel.h>
54 #include <OB_Browser.h>
56 #include <TColStd_MapOfInteger.hxx>
57 #include <TCollection_AsciiString.hxx>
61 #include <SALOMEDSClient.hxx>
64 //================================================================
65 // Function : getActiveView
66 // Purpose : Get active view window, returns 0 if no open study frame
67 //================================================================
68 static SUIT_ViewWindow* getActiveView()
70 SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
72 return SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
78 //================================================================
79 // Function : getGeomEngine
80 // Purpose : Static method
81 //================================================================
82 GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
84 return GeometryGUI::GetGeomGen();
87 //================================================================
88 // Function : GEOMBase_Helper
90 //================================================================
91 GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
92 : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false )
96 //================================================================
97 // Function : ~GEOMBase_Helper
99 //================================================================
100 GEOMBase_Helper::~GEOMBase_Helper()
102 if ( !SUIT_Session::session()->activeApplication()->desktop() )
105 if ( myPreview.size() )
110 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() == VTKViewer_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() == VTKViewer_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();
760 bool withChildren = false;
761 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
765 aName = strlen( getNewObjectName() ) ? GEOMBase::GetDefaultName( getNewObjectName() ) : GEOMBase::GetDefaultName( getPrefix( *it ) );
767 aName = getNewObjectName();
768 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
769 if ( aName.isEmpty() )
770 aName = GEOMBase::GetDefaultName( getPrefix( *it ) );
772 addInStudy( *it, aName.latin1() );
773 withChildren = false;
774 display( *it, false );
776 else { // asv : fix of PAL6454. If publish==false, then the original shape was modified, and need to be re-cached in GEOM_Client
778 clearShapeBuffer( *it );
780 redisplay( *it, withChildren, false );
787 SUIT_Session::session()->activeApplication()->putInfo( QObject::tr("GEOM_PRP_DONE") );
794 catch( const SALOME::SALOME_Exception& e ) {
795 SalomeApp_Tools::QtCatchCorbaException( e );
805 //================================================================
806 // Function : showError
807 // Purpose : Shows a message box with infromation about an error taken from getOperation()->GetErrorCode()
808 //================================================================
809 void GEOMBase_Helper::showError()
812 if ( !getOperation()->_is_nil() )
813 msg = QObject::tr( getOperation()->GetErrorCode() );
816 msg = QObject::tr( "GEOM_PRP_ABORT" );
818 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
819 QObject::tr( "GEOM_ERROR_STATUS" ),
821 QObject::tr( "BUT_OK" ) );
824 //================================================================
825 // Function : showError
826 // Purpose : Shows a error message followed by <msg>
827 //================================================================
828 void GEOMBase_Helper::showError( const QString& msg )
830 QString str( QObject::tr( "GEOM_INCORRECT_INPUT" ) );
831 if ( !msg.isEmpty() )
833 SUIT_MessageBox::error1(SUIT_Session::session()->activeApplication()->desktop(), QObject::tr( "GEOM_ERROR" ), str, QObject::tr( "BUT_OK" ) );
836 //////////////////////////////////////////////////////////////////
837 // Virtual methods to be redefined in dialogs
838 //////////////////////////////////////////////////////////////////
840 //================================================================
841 // Function : createOperation
842 // Purpose : Redefine this method to return proper IOperation reference
843 //================================================================
844 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::createOperation()
846 GEOM::GEOM_IOperations_var aNilOp;
847 return aNilOp._retn();
850 //================================================================
851 // Function : isValid
852 // Purpose : Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
853 //================================================================
854 bool GEOMBase_Helper::isValid( QString& )
859 //================================================================
860 // Function : execute
861 // Purpose : This method is called by onAccept().
862 // It should perform the required operation and put all new or modified objects into
863 // <objects> argument.Should return <false> if some error occurs during its execution.
864 //================================================================
865 bool GEOMBase_Helper::execute( ObjectList& objects )
870 //================================================================
871 // Function : getFather
872 // Purpose : This method is called by addInStudy(). It should return a father object
873 // for <theObj> or a nil reference if <theObj> should be published
874 // as a top-level object.
875 //================================================================
876 GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj )
878 return GEOM::GEOM_Object::_nil();
881 //================================================================
882 // Function : getNewObjectName
883 // Purpose : Redefine this method to return proper name for a new object
884 //================================================================
885 const char* GEOMBase_Helper::getNewObjectName() const
890 //================================================================
891 // Function : getPrefix
892 // Purpose : Get prefix for name of created object
893 //================================================================
894 QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const
896 if ( !myPrefix.isEmpty() || theObj->_is_nil() )
900 if ( !GEOMBase::GetShape( theObj, aShape ) )
903 long aType = aShape.ShapeType();
907 case TopAbs_VERTEX : return QObject::tr( "GEOM_VERTEX" );
908 case TopAbs_EDGE : return QObject::tr( "GEOM_EDGE" );
909 case TopAbs_WIRE : return QObject::tr( "GEOM_WIRE" );
910 case TopAbs_FACE : return QObject::tr( "GEOM_FACE" );
911 case TopAbs_SHELL : return QObject::tr( "GEOM_SHELL" );
912 case TopAbs_SOLID : return QObject::tr( "GEOM_SOLID" );
913 case TopAbs_COMPSOLID: return QObject::tr( "GEOM_COMPOUNDSOLID" );
914 case TopAbs_COMPOUND : return QObject::tr( "GEOM_COMPOUND" );
919 //================================================================
920 // Function : selectedIO
921 // Purpose : Return the list of selected SALOME_InteractiveObject's
922 //================================================================
923 const SALOME_ListIO& GEOMBase_Helper::selectedIO()
927 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
929 SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
931 aSelMgr->selectedObjects( mySelected );
937 //================================================================
938 // Function : IObjectCount
939 // Purpose : Return the number of selected objects
940 //================================================================
941 int GEOMBase_Helper::IObjectCount()
943 return selectedIO().Extent();
946 //================================================================
947 // Function : firstIObject
948 // Purpose : Return the first selected object in the selected object list
949 //================================================================
950 Handle(SALOME_InteractiveObject) GEOMBase_Helper::firstIObject()
952 const SALOME_ListIO& aList = selectedIO();
953 return aList.Extent() > 0 ? aList.First() : Handle(SALOME_InteractiveObject)();
956 //================================================================
957 // Function : lastIObject
958 // Purpose : Return the last selected object in the selected object list
959 //================================================================
960 Handle(SALOME_InteractiveObject) GEOMBase_Helper::lastIObject()
962 const SALOME_ListIO& aList = selectedIO();
963 return aList.Extent() > 0 ? aList.Last() : Handle(SALOME_InteractiveObject)();
966 //================================================================
967 // Function : getDesktop
968 // Purpose : Returns myDesktop field. Initialized in constructor, usually as dynamic_cast<SUIT_Desktop*>(parentWidget())
969 //================================================================
970 SUIT_Desktop* GEOMBase_Helper::getDesktop() const