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 <LightApp_SelectionMgr.h>
47 #include <SalomeApp_Tools.h>
48 #include <SalomeApp_DataModel.h>
49 #include <SalomeApp_Module.h>
51 #include <OCCViewer_ViewModel.h>
52 #include <SVTK_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 );
116 //================================================================
117 // Function : display
119 //================================================================
120 void GEOMBase_Helper::display( const ObjectList& objList, const bool updateView )
122 ObjectList::const_iterator it;
123 for ( it = objList.begin(); it != objList.end(); it++ ) {
124 display( *it, false );
126 if ( !objList.empty() && updateView )
127 getDisplayer()->UpdateViewer();
130 //================================================================
131 // Function : display
132 // Purpose : Display object.
133 // Important : Object must be already in study
134 //================================================================
135 void GEOMBase_Helper::display( GEOM::GEOM_Object_ptr object, const bool updateView )
137 // Unset color of shape ( this color may be set during preview displaying )
138 // Default color will be used
139 getDisplayer()->UnsetColor();
140 getDisplayer()->UnsetWidth();
142 // Enable activisation of selection
143 getDisplayer()->SetToActivate( true );
146 getDisplayer()->Display( object, updateView );
149 //================================================================
152 //================================================================
153 void GEOMBase_Helper::erase( const ObjectList& objList, const bool updateView )
155 ObjectList::const_iterator it = objList.begin();
156 for ( ; it != objList.end(); it++ ) {
159 if ( !objList.empty() && updateView )
160 getDisplayer()->UpdateViewer();
163 //================================================================
166 //================================================================
167 void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView )
169 if ( !object->_is_nil() ) {
170 string entry = getEntry( object );
171 getDisplayer()->Erase( new SALOME_InteractiveObject(
172 entry.c_str(), "GEOM", strdup( GEOMBase::GetName( object ) ) ), true, updateView );
176 //================================================================
177 // Function : redisplay
179 //================================================================
180 void GEOMBase_Helper::redisplay( const ObjectList& objList,
181 const bool withChildren,
182 const bool updateView )
184 ObjectList::const_iterator it = objList.begin();
185 for ( ; it != objList.end(); it++ ) {
186 redisplay( *it, withChildren, false );
188 if ( !objList.empty() && updateView )
189 getDisplayer()->UpdateViewer();
192 //================================================================
193 // Function : redisplay
195 //================================================================
196 void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
197 const bool withChildren,
198 const bool updateView )
200 if ( !object->_is_nil() ) {
201 // Unset color of shape ( this color may be set during preview displaying )
202 // Default color will be used
203 getDisplayer()->UnsetColor();
204 getDisplayer()->UnsetWidth();
206 // Enable activisation of selection
207 getDisplayer()->SetToActivate( true );
209 string entry = getEntry( object );
210 getDisplayer()->Redisplay(new SALOME_InteractiveObject
211 (entry.c_str(), "GEOM", strdup(GEOMBase::GetName(object))), false);
214 if ( withChildren ) {
215 SalomeApp_Study* aDoc = getStudy();
216 if ( aDoc && aDoc->studyDS() ) {
217 _PTR(Study) aStudy = aDoc->studyDS();
218 _PTR(SObject) aSObj (aStudy->FindObjectIOR(SalomeApp_Application::orb()->object_to_string(object)));
220 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
221 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
222 GEOM::GEOM_Object_var aChild = GEOM::GEOM_Object::_narrow
223 (GeometryGUI::ClientSObjectToObject(anIt->Value()));
224 if ( !CORBA::is_nil( aChild ) ) {
225 if ( !aChild->_is_nil() ) {
226 string entry = getEntry( aChild );
227 getDisplayer()->Redisplay( new SALOME_InteractiveObject(
228 entry.c_str(), "GEOM", strdup( GEOMBase::GetName( aChild ) ) ), false );
237 getDisplayer()->UpdateViewer();
240 //================================================================
241 // Function : displayPreview
242 // Purpose : Method for displaying preview based on execute() results
243 //================================================================
244 void GEOMBase_Helper::displayPreview( const bool activate,
246 const bool toRemoveFromEngine,
247 const double lineWidth )
251 if ( !isValid( msg ) )
253 erasePreview( update );
258 erasePreview( false );
261 SUIT_OverrideCursor wc;
263 if ( !execute( objects ) || !getOperation()->IsDone() ) {
267 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it )
269 displayPreview( *it, true, activate, false, lineWidth );
270 if ( toRemoveFromEngine )
271 getGeomEngine()->RemoveObject( *it );
275 catch( const SALOME::SALOME_Exception& e ) {
276 SalomeApp_Tools::QtCatchCorbaException( e );
285 //================================================================
286 // Function : displayPreview
287 // Purpose : Method for displaying preview of resulting shape
288 //================================================================
289 void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object,
293 const double lineWidth )
295 // Set color for preview shape
296 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
298 // set width of displayed shape
299 getDisplayer()->SetWidth( lineWidth );
301 // Disable activation of selection
302 getDisplayer()->SetToActivate( activate );
304 // Make a reference to GEOM_Object
305 getDisplayer()->SetName( SalomeApp_Application::orb()->object_to_string( object ) );
308 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( object );
309 if ( aPrs == 0 || aPrs->IsNull() )
313 displayPreview( aPrs, append, update );
315 getDisplayer()->UnsetName();
317 // Enable activation of displayed objects
318 getDisplayer()->SetToActivate( true );
321 //================================================================
322 // Function : displayPreview
323 // Purpose : Method for displaying arbitrary preview objects (not limited to shapes)
324 //================================================================
325 void GEOMBase_Helper::displayPreview( const SALOME_Prs* prs,
330 erasePreview( false );
332 // remember current view frame to make correct erase preview later
333 myViewWindow = getActiveView();
335 if ( myViewWindow == 0 )
339 SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
340 if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
341 aViewManager->getType() == SVTK_Viewer::Type() )
343 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
344 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
346 aView->Display( prs );
349 // Add prs to the preview list
350 myPreview.push_back( (SALOME_Prs*)prs );
354 getDisplayer()->UpdateViewer();
357 //================================================================
358 // Function : erasePreview
360 //================================================================
361 void GEOMBase_Helper::erasePreview( const bool update )
363 // check view frame where the preview was displayed
364 bool vfOK = checkViewWindow() && myViewWindow;
365 // Iterate through presentations and delete them
366 for ( PrsList::iterator anIter = myPreview.begin(); anIter != myPreview.end(); ++anIter ) {
369 SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
370 if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
371 aViewManager->getType() == SVTK_Viewer::Type() )
373 SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
374 SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
376 aView->Erase( *anIter, true );
388 //================================================================
389 // Function : localSelection
390 // Purpose : Activate selection of objects of a given type
391 // IMPORTANT : Works after localSelection( ... ) method call only
392 //================================================================
393 void GEOMBase_Helper::activate( const int theType )
395 if (!getStudy()) return;
396 _PTR(Study) aStudy = getStudy()->studyDS();
397 _PTR(SComponent) aGeom ( aStudy->FindComponent( "GEOM" ) );
402 _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( aGeom ) );
403 for ( ; anIter->More(); anIter->Next() )
405 _PTR(SObject) aSO ( anIter->Value() );
408 _PTR(SObject) aRefSO;
409 if ( !aSO->ReferencedObject( aRefSO ) )
411 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow
412 (GeometryGUI::ClientSObjectToObject(aSO));
413 if ( !anObj->_is_nil() && anObj->GetType() == theType )
414 aList.Append( new SALOME_InteractiveObject( aSO->GetID().c_str(), "GEOM", aSO->GetName().c_str()) );
419 getDisplayer()->LocalSelection( aList, 0 );
422 //================================================================
423 // Function : localSelection
424 // Purpose : Activate selection of subshapes in accordance with mode
425 // theMode is from TopAbs_ShapeEnum
426 //================================================================
427 void GEOMBase_Helper::localSelection( const ObjectList& theObjs, const int theMode )
429 SALOME_ListIO aListOfIO;
431 ObjectList::const_iterator anIter = theObjs.begin();
432 for ( ; anIter != theObjs.end(); ++anIter )
434 GEOM::GEOM_Object_ptr anObj = *anIter;
435 if ( anObj->_is_nil() )
437 string aEntry = getEntry( anObj );
439 aListOfIO.Append( new SALOME_InteractiveObject(
440 aEntry.c_str(), "GEOM", strdup( GEOMBase::GetName( anObj ) ) ) );
443 getDisplayer()->LocalSelection( aListOfIO, theMode );
446 //================================================================
447 // Function : localSelection
448 // Purpose : Activate selection of subshapes in accordance with mode
449 // theMode is from TopAbs_ShapeEnum
450 //================================================================
451 void GEOMBase_Helper::localSelection( GEOM::GEOM_Object_ptr obj, const int mode )
453 // If object is null local selection for all objects is activated
454 if ( obj->_is_nil() ) {
455 getDisplayer()->LocalSelection( Handle(SALOME_InteractiveObject)(), mode );
460 objList.push_back( obj );
461 localSelection( objList, mode );
465 //================================================================
466 // Function : globalSelection
467 // Purpose : Activate selection of subshapes. Set selection filters
468 // in accordance with mode. theMode is from GEOMImpl_Types
469 //================================================================
470 void GEOMBase_Helper::globalSelection( const int theMode, const bool update )
472 getDisplayer()->GlobalSelection( theMode, update );
475 //================================================================
476 // Function : globalSelection
477 // Purpose : Activate selection of subshapes. Set selection filters
478 // in accordance with mode. theMode is from GEOMImpl_Types
479 //================================================================
480 void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes,
483 getDisplayer()->GlobalSelection( theModes, update );
486 //================================================================
487 // Function : addInStudy
488 // Purpose : Add object in study
489 //================================================================
490 void GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* theName )
495 _PTR(Study) aStudy = getStudy()->studyDS();
496 if ( !aStudy || theObj->_is_nil() )
499 GEOM::GEOM_Object_ptr aFatherObj = getFather( theObj );
501 getGeomEngine()->AddInStudy(GeometryGUI::ClientStudyToStudy(aStudy),
502 theObj, theName, aFatherObj);
505 //================================================================
506 // Function : updateObjBrowser
507 // Purpose : Update object browser
508 //================================================================
509 void GEOMBase_Helper::updateObjBrowser() const
511 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
513 CAM_Module* module = app->module( "Geometry" );
514 SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>( module );
516 appMod->updateObjBrowser( true );
521 //================================================================
522 // Function : updateViewer
523 // Purpose : Update active 3D view
524 //================================================================
525 void GEOMBase_Helper::updateViewer()
527 getDisplayer()->UpdateViewer();
530 //================================================================
531 // Function : getStudyId
532 // Purpose : Get study Id
533 //================================================================
534 int GEOMBase_Helper::getStudyId() const
538 anId = getStudy()->id();
542 //================================================================
543 // Function : getStudy
544 // Purpose : Returns the active study. It is recommended to use
545 // this method instead of direct desktop->getActiveStudy() calls
546 //================================================================
547 SalomeApp_Study* GEOMBase_Helper::getStudy() const
549 SUIT_Desktop* aDesktop = getDesktop();
553 QPtrList<SUIT_Application> anAppList = SUIT_Session::session()->applications();
555 SUIT_Application* anApp = 0;
556 for ( QPtrListIterator<SUIT_Application> it( anAppList ); it.current() ; ++it )
558 anApp = it.current();
559 if ( anApp->desktop() == aDesktop )
563 return dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
566 //================================================================
567 // Function : getEntry
569 //================================================================
570 char* GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const
572 SalomeApp_Study* study = getStudy();
574 string IOR = GEOMBase::GetIORFromObject( object);
576 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
578 return TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString();
585 //================================================================
586 // Function : getDisplayer
588 //================================================================
589 GEOM_Displayer* GEOMBase_Helper::getDisplayer()
592 myDisplayer = new GEOM_Displayer( getStudy() );
596 //================================================================
597 // Function : clearShapeBuffer
599 //================================================================
600 void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
602 if ( CORBA::is_nil( theObj ) )
605 string IOR = SalomeApp_Application::orb()->object_to_string( theObj );
606 TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) );
607 GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
609 if ( !getStudy() || !getStudy()->studyDS() )
612 _PTR(Study) aStudy = getStudy()->studyDS();
613 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( IOR ) );
617 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
618 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
619 _PTR(GenericAttribute) anAttr;
620 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
621 _PTR(AttributeIOR) anIOR ( anAttr );
622 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
623 GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
628 //================================================================
629 // Function : openCommand
631 //================================================================
632 bool GEOMBase_Helper::openCommand()
635 if ( !getStudy() || hasCommand() )
638 GEOM::GEOM_IOperations_var anOp = GEOM::GEOM_IOperations::_narrow( getOperation() );
639 if ( !anOp->_is_nil() ) {
640 myCommand = new GEOM_Operation( SUIT_Session::session()->activeApplication(), anOp.in() );
648 //================================================================
649 // Function : abortCommand
651 //================================================================
652 bool GEOMBase_Helper::abortCommand()
663 //================================================================
664 // Function : commitCommand
666 //================================================================
667 bool GEOMBase_Helper::commitCommand( const char* )
678 //================================================================
679 // Function : hasCommand
681 //================================================================
682 bool GEOMBase_Helper::hasCommand() const
684 return (bool)myCommand;
687 //================================================================
688 // Function : getOperation
690 //================================================================
691 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::getOperation()
693 if ( myOperation->_is_nil() )
694 myOperation = createOperation();
701 //================================================================
702 // Function : checkViewWindow
704 //================================================================
705 bool GEOMBase_Helper::checkViewWindow()
708 QPtrList<SUIT_ViewWindow> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
709 for ( QPtrListIterator<SUIT_ViewWindow> it( aViewWindowsList ); it.current(); ++it )
711 if ( myViewWindow == it.current() )
719 //================================================================
720 // Function : onAccept
721 // Purpose : This method should be called from dialog's slots onOk() and onApply()
722 // It perfroms user input validation, then it
723 // performs a proper operation and manages transactions, etc.
724 //================================================================
725 bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
727 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
728 if ( !appStudy ) return false;
729 _PTR(Study) aStudy = appStudy->studyDS();
731 bool aLocked = (_PTR(AttributeStudyProperties) (aStudy->GetProperties()))->IsLocked();
733 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
734 SUIT_MessageBox::warn1 ( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(),
735 QObject::tr("WRN_WARNING"),
736 QObject::tr("WRN_STUDY_LOCKED"),
737 QObject::tr("BUT_OK") );
742 if ( !isValid( msg ) ) {
747 erasePreview( false );
750 if ( ( !publish && !useTransaction ) || openCommand() ) {
751 SUIT_OverrideCursor wc;
752 SUIT_Session::session()->activeApplication()->putInfo( "" );
754 if ( !execute( objects ) || !getOperation()->IsDone() ) {
760 const int nbObjs = objects.size();
761 bool withChildren = false;
763 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
765 QString aName = getNewObjectName();
768 aName = getPrefix(*it);
770 // Try to find a unique name
771 aName = GEOMBase::GetDefaultName(aName);
773 // Don't check name uniqueness in case of numerous objects
774 aName = aName + "_" + QString::number(aNumber++);
777 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
778 if ( aName.isEmpty() )
779 aName = GEOMBase::GetDefaultName( getPrefix( *it ) );
781 addInStudy( *it, aName.latin1() );
782 withChildren = false;
783 display( *it, false );
785 else { // asv : fix of PAL6454. If publish==false, then the original shape was modified, and need to be re-cached in GEOM_Client
787 clearShapeBuffer( *it );
789 redisplay( *it, withChildren, false );
796 SUIT_Session::session()->activeApplication()->putInfo( QObject::tr("GEOM_PRP_DONE") );
803 catch( const SALOME::SALOME_Exception& e ) {
804 SalomeApp_Tools::QtCatchCorbaException( e );
814 //================================================================
815 // Function : showError
816 // Purpose : Shows a message box with infromation about an error taken from getOperation()->GetErrorCode()
817 //================================================================
818 void GEOMBase_Helper::showError()
821 if ( !getOperation()->_is_nil() )
822 msg = QObject::tr( getOperation()->GetErrorCode() );
825 msg = QObject::tr( "GEOM_PRP_ABORT" );
827 SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
828 QObject::tr( "GEOM_ERROR_STATUS" ),
830 QObject::tr( "BUT_OK" ) );
833 //================================================================
834 // Function : showError
835 // Purpose : Shows a error message followed by <msg>
836 //================================================================
837 void GEOMBase_Helper::showError( const QString& msg )
839 QString str( QObject::tr( "GEOM_INCORRECT_INPUT" ) );
840 if ( !msg.isEmpty() )
842 SUIT_MessageBox::error1(SUIT_Session::session()->activeApplication()->desktop(), QObject::tr( "GEOM_ERROR" ), str, QObject::tr( "BUT_OK" ) );
845 //////////////////////////////////////////////////////////////////
846 // Virtual methods to be redefined in dialogs
847 //////////////////////////////////////////////////////////////////
849 //================================================================
850 // Function : createOperation
851 // Purpose : Redefine this method to return proper IOperation reference
852 //================================================================
853 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::createOperation()
855 GEOM::GEOM_IOperations_var aNilOp;
856 return aNilOp._retn();
859 //================================================================
860 // Function : isValid
861 // Purpose : Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
862 //================================================================
863 bool GEOMBase_Helper::isValid( QString& )
868 //================================================================
869 // Function : execute
870 // Purpose : This method is called by onAccept().
871 // It should perform the required operation and put all new or modified objects into
872 // <objects> argument.Should return <false> if some error occurs during its execution.
873 //================================================================
874 bool GEOMBase_Helper::execute( ObjectList& objects )
879 //================================================================
880 // Function : getFather
881 // Purpose : This method is called by addInStudy(). It should return a father object
882 // for <theObj> or a nil reference if <theObj> should be published
883 // as a top-level object.
884 //================================================================
885 GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj )
887 return GEOM::GEOM_Object::_nil();
890 //================================================================
891 // Function : getNewObjectName
892 // Purpose : Redefine this method to return proper name for a new object
893 //================================================================
894 const char* GEOMBase_Helper::getNewObjectName() const
899 //================================================================
900 // Function : getPrefix
901 // Purpose : Get prefix for name of created object
902 //================================================================
903 QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const
905 if ( !myPrefix.isEmpty() || theObj->_is_nil() )
909 if ( !GEOMBase::GetShape( theObj, aShape ) )
912 long aType = aShape.ShapeType();
916 case TopAbs_VERTEX : return QObject::tr( "GEOM_VERTEX" );
917 case TopAbs_EDGE : return QObject::tr( "GEOM_EDGE" );
918 case TopAbs_WIRE : return QObject::tr( "GEOM_WIRE" );
919 case TopAbs_FACE : return QObject::tr( "GEOM_FACE" );
920 case TopAbs_SHELL : return QObject::tr( "GEOM_SHELL" );
921 case TopAbs_SOLID : return QObject::tr( "GEOM_SOLID" );
922 case TopAbs_COMPSOLID: return QObject::tr( "GEOM_COMPOUNDSOLID" );
923 case TopAbs_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