1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 #include "HELLO_version.h"
26 #include <SalomeApp_Application.h>
27 #include <SalomeApp_Study.h>
28 #include <SalomeApp_DataObject.h>
30 #include <LightApp_SelectionMgr.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Desktop.h>
36 #include <QtxPopupMgr.h>
38 #include <SALOME_ListIO.hxx>
40 #include <SALOME_LifeCycleCORBA.hxx>
41 #include <SALOMEDS_SObject.hxx>
42 #include <SALOMEDS_Study.hxx>
44 #include <QInputDialog>
46 //! The only instance of the reference to engine
47 HELLO_ORB::HELLO_Gen_var HELLOGUI::myEngine;
52 Creates an instance of the HELLO GUI module.
53 Initializes (loads if necessary) HELLO module engine.
55 HELLOGUI::HELLOGUI() :
56 SalomeApp_Module( "HELLO" ) // module name
58 init(); // internal initialization
64 Destroys any allocated resources.
72 \brief Get a reference to the HELLO module CORBA engine
74 \note This function returns vartype in order to minimize possible crashes
75 when using this function with assignment operations.
76 On the other hand, this simplifies usage of this function when using it outside
77 the assignment operations, to minimize memory leaks caused by orphan CORBA
78 references (no need to take care of reference counting).
80 \return reference to the module engine
82 HELLO_ORB::HELLO_Gen_var HELLOGUI::engine()
84 init(); // initialize engine, if necessary
89 \brief Module initialization.
91 Overloaded from CAM_Module class.
93 Perform general module initialization (like creation of actions,
94 menus, toolbars, etc).
96 \note This function is invoked only once per study, when the module
97 is first time activated by the user.
98 The study associated with the application might not exist
99 (created or opened) when this function is invoked, so it is not
100 recommended to perform any study-dependant actions here.
102 \param app pointer to the current application instance
104 void HELLOGUI::initialize( CAM_Application* app )
106 // call the parent implementation
107 SalomeApp_Module::initialize( app );
109 // get reference to the desktop (used as a parent for actions)
110 QWidget* dsk = app->desktop();
111 // get resources manager
112 SUIT_ResourceMgr* resMgr = app->resourceMgr();
115 // ... Test me operation
116 createAction( OpTestMe, // operation id
117 tr( "TLT_OP_TESTME" ), // tooltip
118 resMgr->loadPixmap( "HELLO",tr( "ICON_OP_TESTME" ) ), // icon
119 tr( "MEN_OP_TESTME" ), // menu title
120 tr( "STS_OP_TESTME" ), // status tip
121 0, // accelerator (not set)
123 false, // togglable flag (no)
124 this, // action receiver
125 SLOT( testMe() ) ); // action slot
126 // ... Hello operation
127 createAction( OpHello, // operation id
128 tr( "TLT_OP_HELLO" ), // tooltip
129 resMgr->loadPixmap( "HELLO",tr( "ICON_OP_HELLO" ) ), // icon
130 tr( "MEN_OP_HELLO" ), // menu title
131 tr( "STS_OP_HELLO" ), // status tip
132 0, // accelerator (not set)
134 false, // togglable flag (no)
135 this, // action receiver
136 SLOT( hello() ) ); // action slot
137 // ... Goodbye operation
138 createAction( OpGoodbye, // operation id
139 tr( "TLT_OP_GOODBYE" ), // tooltip
140 resMgr->loadPixmap( "HELLO",tr( "ICON_OP_GOODBYE" ) ), // icon
141 tr( "MEN_OP_GOODBYE" ), // menu title
142 tr( "STS_OP_GOODBYE" ), // status tip
143 0, // accelerator (not set)
145 false, // togglable flag (no)
146 this, // action receiver
147 SLOT( goodbye() ) ); // action slot
151 menuId = createMenu( tr( "MEN_FILE" ), -1, -1 ); // File menu
152 createMenu( separator(), menuId, -1, 10 ); // add separator to File menu
153 menuId = createMenu( tr( "MEN_FILE_HELLO" ), menuId, -1, 10 ); // File - Hello submenu
154 createMenu( OpTestMe, menuId ); // File - Hello - Test me
155 menuId = createMenu( tr( "MEN_HELLO" ), -1, -1, 30 ); // Hello menu
156 createMenu( OpHello, menuId, 10 ); // Hello - Hello
157 createMenu( OpGoodbye, menuId, 10 ); // Hello - Goodbye
161 aToolId = createTool ( tr( "TOOL_TEST" ) ); // Test toolbar
162 createTool( OpTestMe, aToolId ); // Test - Test me
163 aToolId = createTool ( tr( "TOOL_HELLO" ) ); // Hello toolbar
164 createTool( OpHello, aToolId ); // Hello - Hello
165 createTool( OpGoodbye, aToolId ); // Hello - Goodbye
168 QtxPopupMgr* mgr = popupMgr();
169 mgr->insert( action( OpHello ), -1, -1 ); // Hello
170 mgr->insert( action( OpGoodbye ), -1, -1 ); // Goodbye
171 mgr->insert( separator(), -1, -1 ); // -----------
172 mgr->insert( action( OpTestMe ), -1, -1 ); // Test me
173 QString baseRule = "client='ObjectBrowser' and selcount=1 and $component={'HELLO'}";
174 mgr->setRule( action( OpHello ), baseRule + " and isComponent", QtxPopupMgr::VisibleRule );
175 mgr->setRule( action( OpGoodbye ), baseRule + " and !isComponent", QtxPopupMgr::VisibleRule );
179 \brief Get module engine IOR
181 Overloaded from SalomeApp_Module class.
183 \return string representing module engine IOR
185 QString HELLOGUI::engineIOR() const
187 init(); // initialize engine, if necessary
188 CORBA::String_var anIOR = getApp()->orb()->object_to_string( myEngine.in() );
189 return QString( anIOR.in() );
193 \brief Get module icon.
195 Overloaded from CAM_Module class.
197 Load and return the module icon pixmap. This icon is shown
198 in the Object browser, in modules toolbar, etc.
200 Default implementation uses iconName() function to retrieve the name
201 of the image file to be used as the module icon; tries to load this
202 file from module's resources and create pixmap from it.
203 Returns valid QPixmap instance if image is loaded correctly.
204 This function can be customized to provide another way to get module icon.
206 \return module icon pixmap
209 QPixmap HELLOGUI::moduleIcon() const
211 // nothing to do, in this example just call the parent implementation
212 return SalomeApp_Module::moduleIcon();
216 \brief Get module icon's file name.
218 Overloaded from CAM_Module class.
220 This function is used to get module icon image file name.
221 Default implementation tries to retrieve the name of the
222 icon file from the application using moduleIcon() function, which
223 in its turn retrieves the information about the module icon
224 from the configuration file (e.g. SalomeApp.xml, LightApp.xml).
225 This function can be customized to provide another way to get module icon's
228 \return module icon file name
231 QString HELLOGUI::iconName() const
233 // nothing to do, in this example just call the parent implementation
234 return SalomeApp_Module::iconName();
238 \brief Request dockable windows to be available when module is active.
240 Overloaded from LightApp_Module class.
242 Fills and returns the list of dockable windows which should be
243 available when the module is active. It is a map of integer values
244 where \c key is an enumerator from LightApp_Application::WindowTypes
245 enumeration, specifying window type, and \c value is an enumerator
246 from Qt::DockWidgetArea, specifying the window's default position
247 in the main window layout.
249 Empty map means no dockable windows available when the module is active.
251 \param theMap this map should be filled to specify the list of
252 required dockable windows withe their default positions
254 void HELLOGUI::windows( QMap<int, int>& theMap ) const
256 // want Object browser, in the left area
257 theMap.insert( SalomeApp_Application::WT_ObjectBrowser,
258 Qt::LeftDockWidgetArea );
259 // want Python console, in the bottom area
260 theMap.insert( SalomeApp_Application::WT_PyConsole,
261 Qt::BottomDockWidgetArea );
265 \brief Request view windows (types) to be activated when module is activated..
267 Overloaded from LightApp_Module class.
269 Fills and returns the list of 3D/2D view windows types compatible
270 with this module. The views of the specified type(s) will be automatically
271 activated (raised to the top of view stack) each time when the module
272 is activated by the user (the views will be automatically created if they
273 do not exist at the module activation).
274 Empty list means no compatible view windows for the module.
278 theList.append( OCCViewer_Viewer::Type() );
279 theList.append( SVTK_Viewer::Type() );
282 \param theList this list should be filled to specify the list of
283 compatible view window types
285 void HELLOGUI::viewManagers( QStringList& /*theList*/ ) const
287 // no compatible view managers, nothing to do here
291 \brief Create popup selection handler.
293 Overloaded from LightApp_Module class.
295 This function can be used to create custom popup menu handler.
296 The application takes ownership over the returned pointer,
297 so you should not destroy it.
299 This function is part of the context popup menu management mechanism.
300 Selection object (instance of LightApp_Selection class or its successor)
301 analizes the currently selected items and defines selection-dependant
302 variables which are processed by the popup manager (QtxPopupMgr class).
304 These variables can be included into the lexical constructions, named
305 "rules", which are associated with the popup menu actions (refer to the
306 QtxPopupMgr class for more details).
310 // obtain popup manager
311 QtxPopupMgr* mgr = popupMgr();
312 // create new action, with ID = 100
313 createAction( 100, "Action", QIcon(), "Action", "My action", 0, application()->desktop(),
314 false, this, SLOT( OnMyAction() ) );
315 // define popup rule for action
316 QString rule = "client='ObjectBrowser' and $type in {'MyType1' 'MyType2'} and selcount=1";
317 // set visibility rule for action
318 mgr->setRule( 100, rule, QtxPopupMgr::VisibleRule );
321 In the above code, \a selcount variable is automatically defined
322 by LightApp_Selection class, but \a type variable should be set by
323 the successor class. Note, that LightApp_Selection class implements
324 several useful variables which can be used in the lexical rules.
326 \return new selection object
327 \sa contextMenuPopup()
329 LightApp_Selection* HELLOGUI::createSelection() const
331 // nothing to do, in this example just call the parent implementation
332 // see also initialize()
333 return SalomeApp_Module::createSelection();
337 \brief Create displayer object.
339 Overloaded from LightApp_Module class.
341 This function can be used to create and return custom displayer object.
342 The application does not take the ownership over the returned value.
344 Displayer is a part of the presentations management system.
345 If can be used to implement visualization operations, like create, show
346 or hide presentation in the viewer of specific type, etc.
348 \return pointer to the module displayer
350 LightApp_Displayer* HELLOGUI::displayer()
352 // nothing to do, in this example just call the parent implementation
353 return SalomeApp_Module::displayer();
357 \brief Create context popup menu.
359 Overloaded from CAM_Module class.
361 This function can be used to customize context popup menu management.
362 The module should fill \a menu with the items (e.g. by inserting own
363 QAction items). The menu contents can be context-depending, the parameter
364 \a type can be used to test the context of the popup menu invocation
365 (e.g. "ObjectBrowser").
366 Parameter \a title can be used to return the string value to be used
367 popup menu title if required.
369 Default implementation from LightApp_Module class calls createSelection()
370 function to create popup selection handler and initialized the popup menu
373 \param type popup menu context
374 \param menu pointer to the popup menu
375 \param title custom popup menu title can be returned here
376 \sa createSelection()
378 void HELLOGUI::contextMenuPopup( const QString& type, QMenu* menu, QString& title )
380 // nothing to do, in this example just call the parent implementation
381 // see also initialize()
382 return SalomeApp_Module::contextMenuPopup( type, menu, title );
386 \brief Export module preferences.
388 Overloaded from LightApp_Module class.
390 This function is invoked only once when the common "Preferences"
391 dialog box is first time activated by the user (via the "File/Preferences"
392 menu command) or when module is first time activated.
394 This function should be used to export module preferences to the
395 common "Preferences" dialog box and associate them with the corresponding
396 widgets. The preferences items are arranged to the tree-like structure, where
397 top-level items represent just a containers for the underlying items.
398 Each low-level preferences item is linked to the resources item (via "section"
399 and "parameter" attributes). See QtxResourceMgr class for more details about
400 resources management.
404 // create top-level preferences tab page
405 int settingsId = addPreference( "Settings" );
406 // create general settings group box
407 int generalId = addPreference( tr( "General" ), settingsId );
408 // set group box property - number of columns - to 2
409 setPreferenceProperty( generalId, "columns", 2 );
410 // create shading color preferences item (color button)
411 addPreference( "Shading color", generalId, LightApp_Preferences::Color,
412 "HELLO", "shading_color" );
413 // create precision preferences item (spin box)
414 int precisionId = addPreference( tr( "GEOM_PREF_length_precision" ), generalId,
415 LightApp_Preferences::IntSpin, "HELLO", "precision" );
416 // set precision preferences item properties
417 setPreferenceProperty( precisionId, "min", 0 );
418 setPreferenceProperty( precisionId, "max", 10 );
421 \sa preferencesChanged()
423 void HELLOGUI::createPreferences()
425 // no module preferences, nothing to do here
429 \brief Process preference item change event.
431 Overloaded from LightApp_Module class.
433 This function is called every time when the preference item
434 owned by this module is changed by the user (usually this occurs when
435 the user presses "OK" or "Apply" button in the "Preferences" dialog box).
437 The module can perform any specific actions if necessary to response
438 to the preferences changes.
440 \param section resources item section name
441 \param parameter resources item parameter name
443 \sa createPreferences()
445 void HELLOGUI::preferencesChanged( const QString& section, const QString& parameter )
447 // nothing to do, in this example just call the parent implementation
448 SalomeApp_Module::preferencesChanged( section, parameter );
452 \brief Store visual state.
454 Overloaded from SalomeApp_Module class.
456 This method is called just before the study document is saved,
457 so the module has a possibility to store any visual parameters
458 in the AttributeParameter study attribute (if required).
460 \param savePoint save point unique identifier
462 void HELLOGUI::storeVisualParameters( int /*savePoint*/ )
464 // no specific visual state, nothing to do here
468 \brief Restore visual state.
470 Overloaded from SalomeApp_Module class.
472 This method is called after the study document is opened,
473 so the module has a possibility to restore the visual parameters
474 from the AttributeParameter study attribute (if required).
476 \param savePoint save point unique identifier
478 void HELLOGUI::restoreVisualParameters( int /*savePoint*/ )
480 // no specific visual state, nothing to do here
484 \brief Handle active study changing action.
486 Overloaded from LightApp_Module class.
488 This function is called each time when the active study is changed
489 (usually this happens when users switches between different studies'
492 Can be used to perform any relevant actions.
494 void HELLOGUI::studyActivated()
496 // no any specific action required, nothing to do here
500 \brief Check if the module can perform "copy" operation.
502 Overloaded from LightApp_Module class.
504 This function is a part of the general copy/paste mechanism.
506 Can be re-implemented to customize the copy/paste handling
507 in the module. Default implementation returns \c false.
509 \return \c true if the module can perform "copy" operation or \c false otherwise
510 \sa canPaste(), copy(), paste()
512 bool HELLOGUI::canCopy() const
514 // copy/paste is not supported, in this example just call the parent implementation
515 return SalomeApp_Module::canCopy();
519 \brief Check if the module can perform "paste" operation.
521 Overloaded from LightApp_Module class.
523 This function is a part of the general copy/paste mechanism.
525 Can be re-implemented to customize the copy/paste handling
526 in the module. Default implementation returns \c false.
528 \return \c true if the module can perform "paste" operation or \c false otherwise
529 \sa canCopy(), copy(), paste()
531 bool HELLOGUI::canPaste() const
533 // copy/paste is not supported, in this example just call the parent implementation
534 return SalomeApp_Module::canPaste();
538 \brief Perform "copy" operation.
540 Overloaded from LightApp_Module class.
542 This function is a part of the general copy/paste mechanism.
544 Can be re-implemented to customize the copy/paste handling
545 in the module. Default implementation does nothing.
547 \sa canCopy(), canPaste(), paste()
549 void HELLOGUI::copy()
551 // copy/paste is not supported, nothing to do here
555 \brief Perform "paste" operation.
557 Overloaded from LightApp_Module class.
559 This function is a part of the general copy/paste mechanism.
561 Can be re-implemented to customize the copy/paste handling
562 in the module. Default implementation does nothing.
564 \sa canCopy(), canPaste(), copy()
566 void HELLOGUI::paste()
568 // copy/paste is not supported, nothing to do here
572 \brief Check if the module allows "drag" operation of its objects.
574 Overloaded from LightApp_Module class.
576 This function is a part of the general drag-n-drop mechanism.
577 The goal of this function is to check data object passed as a parameter
578 and decide if it can be dragged or no.
580 \param what data object being tested for drag operation
581 \return \c true if module allows dragging of the specified object
582 \sa isDropAccepted(), dropObjects()
584 bool HELLOGUI::isDraggable( const SUIT_DataObject* what ) const
586 // we allow dragging any HELLO object, except the top-level component
587 const SalomeApp_ModuleObject* aModObj = dynamic_cast<const SalomeApp_ModuleObject*>( what );
588 return ( aModObj == 0 );
592 \brief Check if the module allows "drop" operation on the given object.
594 Overloaded from LightApp_Module class.
596 This function is a part of the general drag-n-drop mechanism.
597 The goal of this function is to check data object passed as a parameter
598 and decide if it can be used as a target for the "drop" operation.
599 The processing of the drop operation itself is done in the dropObjects() function.
601 \param where target data object
602 \return \c true if module supports dropping on the \a where data object
603 \sa isDraggable(), dropObjects()
605 bool HELLOGUI::isDropAccepted( const SUIT_DataObject* where ) const
607 // we allow dropping of all objects
608 // (temporarily implementation, we also need to check objects being dragged)
613 \brief Complete drag-n-drop operation.
615 Overloaded from LightApp_Module class.
617 This function is a part of the general drag-n-drop mechanism.
618 Its goal is to handle dropping of the objects being dragged according
619 to the chosen operation (copy or move). The dropping is performed in the
620 context of the parent data object \a where and the \a row (position in the
621 children index) at which the data should be dropped. If \a row is equal to -1,
622 this means that objects are added to the end of the children list.
624 \param what objects being dropped
625 \param where target data object
626 \param row child index at which the drop operation is performed
627 \param action drag-n-drop operation (Qt::DropAction) - copy or move
629 \sa isDraggable(), isDropAccepted()
631 void HELLOGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
632 const int row, Qt::DropAction action )
634 if (action != Qt::CopyAction && action != Qt::MoveAction)
635 return; // unsupported action
638 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
639 if ( !dataObj ) return; // wrong parent
640 _PTR(SObject) parentObj = dataObj->object();
642 // collect objects being dropped
643 HELLO_ORB::object_list_var objects = new HELLO_ORB::object_list();
644 objects->length( what.count() );
646 for ( int i = 0; i < what.count(); i++ ) {
647 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
648 if ( !dataObj ) continue; // skip wrong objects
649 _PTR(SObject) sobj = dataObj->object();
650 objects[i] = _CAST(SObject, sobj)->GetSObject();
653 objects->length( count );
655 // call engine function
656 engine()->copyOrMove( objects.in(), // what
657 _CAST(SObject, parentObj)->GetSObject(), // where
659 action == Qt::CopyAction ); // isCopy
661 // update Object browser
662 getApp()->updateObjectBrowser( false );
666 \brief Module activation.
668 Overloaded from CAM_Module class.
670 This function is called each time the module is activated
671 by the user. It is usually used to perform any relevant actions,
672 like displaying menus and toolbars, connecting specific signals/slots, etc.
674 \param theStudy current study object
675 \return \c true if activation is completed correctly or \c false
676 if module activation fails
678 \sa deactivateModule()
680 bool HELLOGUI::activateModule( SUIT_Study* theStudy )
682 // call parent implementation
683 bool bOk = SalomeApp_Module::activateModule( theStudy );
686 setMenuShown( true );
688 setToolShown( true );
690 // return the activation status
695 \brief Module deactivation.
697 Overloaded from CAM_Module class.
699 This function is called each time the module is deactivated
700 by the user. It is usually used to perform any relevant actions,
701 like hiding menus and toolbars, disconnecting specific signals/slots, etc.
703 \param theStudy current study object
704 \return \c true if deactivation is completed correctly or \c false
705 if module deactivation fails
709 bool HELLOGUI::deactivateModule( SUIT_Study* theStudy )
712 setMenuShown( false );
714 setToolShown( false );
716 // call parent implementation and return the activation status
717 return SalomeApp_Module::deactivateModule( theStudy );
721 \brief Create specific operation object.
723 Overloaded from LightApp_Module class.
725 This function is a part of operation management mechanism.
726 It can be used to create module specific operations, if module
727 implements transaction handling basing on the GUI operations instances.
729 This function is automatically called from startOperation() function.
730 After operation is created, it can be started/stopped/paused/resumed etc.
731 Compatibility between diferent simultaneously running operations is also
732 checked by invoking of the corresponding methods of the LightApp_Operation
735 The application takes ownership over the returned pointer,
736 so you should not destroy it.
738 Default implementation in LightApp_Module class processes common Show/Hide
741 \param id unique operation identifier
742 \return new operation object
744 LightApp_Operation* HELLOGUI::createOperation( const int id ) const
746 // no specific operations, in this example just call the parent implementation
747 return SalomeApp_Module::createOperation( id );
751 \brief Action slot: Test me
753 void HELLOGUI::testMe()
755 SUIT_MessageBox::information( getApp()->desktop(),
756 tr( "INF_TESTME_TITLE" ),
757 tr( "INF_TESTME_MSG" ),
762 \brief Action slot: Hello
764 void HELLOGUI::hello()
766 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
767 _PTR(Study) studyDS = study->studyDS();
771 QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HELLO_TITLE" ), tr( "QUE_ENTER_NAME" ),
772 QLineEdit::Normal, QString::null, &ok );
774 if ( ok && !name.trimmed().isEmpty() ) {
775 // say hello to SALOME
776 HELLO_ORB::status status = engine()->hello( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
778 // update Object browser
779 getApp()->updateObjectBrowser(true);
781 // process operation status
783 case HELLO_ORB::OP_OK:
785 SUIT_MessageBox::information( getApp()->desktop(),
786 tr( "INF_HELLO_TITLE" ),
787 tr( "INF_HELLO_MSG" ).arg( name ),
790 case HELLO_ORB::OP_ERR_ALREADY_MET:
791 // error: already said hello
792 SUIT_MessageBox::warning( getApp()->desktop(),
793 tr( "INF_HELLO_TITLE" ),
794 tr( "ERR_HELLO_ALREADY_MET" ).arg( name ),
797 case HELLO_ORB::OP_ERR_UNKNOWN:
800 SUIT_MessageBox::critical( getApp()->desktop(),
801 tr( "INF_HELLO_TITLE" ),
810 \brief Action slot: Goodbye
812 void HELLOGUI::goodbye()
814 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
815 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
816 _PTR(Study) studyDS = study->studyDS();
817 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
822 SALOME_ListIO selected;
823 aSelMgr->selectedObjects( selected );
824 if ( selected.Extent() == 1 ) {
825 Handle(SALOME_InteractiveObject) io = selected.First();
826 _PTR(SObject) so = studyDS->FindObjectID( io->getEntry() );
828 _PTR(SComponent) comp = so->GetFatherComponent();
829 if ( comp && comp->ComponentDataType() == "HELLO" && io->getEntry() != comp->GetID() ) {
830 name = so->GetName().c_str();
835 // request user name if not specified
836 if ( name.isEmpty() ) {
838 name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_GOODBYE_TITLE" ), tr( "QUE_ENTER_NAME" ),
839 QLineEdit::Normal, QString::null, &ok );
842 if ( !name.trimmed().isEmpty() ) {
843 // say goodby to SALOME
844 HELLO_ORB::status status = engine()->goodbye( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
846 // update Object browser
847 getApp()->updateObjectBrowser(true);
849 // process operation status
851 case HELLO_ORB::OP_OK:
853 SUIT_MessageBox::information( getApp()->desktop(),
854 tr( "INF_GOODBYE_TITLE" ),
855 tr( "INF_GOODBYE_MSG" ).arg( name ),
858 case HELLO_ORB::OP_ERR_DID_NOT_MEET:
859 // error: did not say hello yet
860 SUIT_MessageBox::warning( getApp()->desktop(),
861 tr( "INF_GOODBYE_TITLE" ),
862 tr( "ERR_GOODBYE_DID_NOT_MEET" ).arg( name ),
865 case HELLO_ORB::OP_ERR_UNKNOWN:
868 SUIT_MessageBox::critical( getApp()->desktop(),
869 tr( "INF_GOODBYE_TITLE" ),
878 \brief Perform internal initialization
880 In particular, this function initializes module engine.
882 void HELLOGUI::init()
884 // initialize HELLO module engine (load, if necessary)
885 if ( CORBA::is_nil( myEngine ) ) {
886 Engines::EngineComponent_var comp =
887 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "HELLO" );
888 myEngine = HELLO_ORB::HELLO_Gen::_narrow( comp );
894 // FACTORY FUNCTION: create an instance of the Hello module GUI
895 CAM_Module* createModule()
897 return new HELLOGUI();
899 // VERSIONING FUNCTION: get Hello module's version identifier
900 char* getModuleVersion()
902 return (char*)HELLO_VERSION_STR; // HELLO_VERSION_STR is defined in HELLO_version.h