1 // Copyright (C) 2007-2021 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, or (at your option) any later version.
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>
43 #include "SALOME_NamingService_Abstract.hxx"
44 #include "SALOME_KernelServices.hxx"
46 #include <QInputDialog>
48 //! The only instance of the reference to engine
49 HELLO_ORB::HELLO_Gen_var HELLOGUI::myEngine;
54 Creates an instance of the HELLO GUI module.
55 Initializes (loads if necessary) HELLO module engine.
57 HELLOGUI::HELLOGUI() :
58 SalomeApp_Module( "HELLO" ) // module name
60 init(); // internal initialization
66 Destroys any allocated resources.
74 \brief Get a reference to the HELLO module CORBA engine
76 \note This function returns vartype in order to minimize possible crashes
77 when using this function with assignment operations.
78 On the other hand, this simplifies usage of this function when using it outside
79 the assignment operations, to minimize memory leaks caused by orphan CORBA
80 references (no need to take care of reference counting).
82 \return reference to the module engine
84 HELLO_ORB::HELLO_Gen_var HELLOGUI::engine()
86 init(); // initialize engine, if necessary
91 \brief Module initialization.
93 Overloaded from CAM_Module class.
95 Perform general module initialization (like creation of actions,
96 menus, toolbars, etc).
98 \note This function is invoked only once, when the module
99 is first time activated by the user.
100 The study associated with the application might not exist
101 (created or opened) when this function is invoked, so it is not
102 recommended to perform any study-dependant actions here.
104 \param app pointer to the current application instance
106 void HELLOGUI::initialize( CAM_Application* app )
108 // call the parent implementation
109 SalomeApp_Module::initialize( app );
111 // get reference to the desktop (used as a parent for actions)
112 QWidget* dsk = app->desktop();
113 // get resources manager
114 SUIT_ResourceMgr* resMgr = app->resourceMgr();
117 // ... Test me operation
118 createAction( OpTestMe, // operation id
119 tr( "TLT_OP_TESTME" ), // tooltip
120 resMgr->loadPixmap( "HELLO",tr( "ICON_OP_TESTME" ) ), // icon
121 tr( "MEN_OP_TESTME" ), // menu title
122 tr( "STS_OP_TESTME" ), // status tip
123 0, // accelerator (not set)
125 false, // togglable flag (no)
126 this, // action receiver
127 SLOT( testMe() ) ); // action slot
128 // ... Hello operation
129 createAction( OpHello, // operation id
130 tr( "TLT_OP_HELLO" ), // tooltip
131 resMgr->loadPixmap( "HELLO",tr( "ICON_OP_HELLO" ) ), // icon
132 tr( "MEN_OP_HELLO" ), // menu title
133 tr( "STS_OP_HELLO" ), // status tip
134 0, // accelerator (not set)
136 false, // togglable flag (no)
137 this, // action receiver
138 SLOT( hello() ) ); // action slot
139 // ... Goodbye operation
140 createAction( OpGoodbye, // operation id
141 tr( "TLT_OP_GOODBYE" ), // tooltip
142 resMgr->loadPixmap( "HELLO",tr( "ICON_OP_GOODBYE" ) ), // icon
143 tr( "MEN_OP_GOODBYE" ), // menu title
144 tr( "STS_OP_GOODBYE" ), // status tip
145 0, // accelerator (not set)
147 false, // togglable flag (no)
148 this, // action receiver
149 SLOT( goodbye() ) ); // action slot
153 menuId = createMenu( tr( "MEN_FILE" ), -1, -1 ); // File menu
154 createMenu( separator(), menuId, -1, 10 ); // add separator to File menu
155 menuId = createMenu( tr( "MEN_FILE_HELLO" ), menuId, -1, 10 ); // File - Hello submenu
156 createMenu( OpTestMe, menuId ); // File - Hello - Test me
157 menuId = createMenu( tr( "MEN_HELLO" ), -1, -1, 30 ); // Hello menu
158 createMenu( OpHello, menuId, 10 ); // Hello - Hello
159 createMenu( OpGoodbye, menuId, 10 ); // Hello - Goodbye
163 aToolId = createTool ( tr( "TOOL_TEST" ), QString( "HelloTest" ) ); // Test toolbar
164 createTool( OpTestMe, aToolId ); // Test - Test me
165 aToolId = createTool ( tr( "TOOL_HELLO" ), QString( "HelloMain" ) ); // Hello toolbar
166 createTool( OpHello, aToolId ); // Hello - Hello
167 createTool( OpGoodbye, aToolId ); // Hello - Goodbye
170 QtxPopupMgr* mgr = popupMgr();
171 mgr->insert( action( OpHello ), -1, -1 ); // Hello
172 mgr->insert( action( OpGoodbye ), -1, -1 ); // Goodbye
173 mgr->insert( separator(), -1, -1 ); // -----------
174 mgr->insert( action( OpTestMe ), -1, -1 ); // Test me
175 QString baseRule = "client='ObjectBrowser' and selcount=1 and $component={'HELLO'}";
176 mgr->setRule( action( OpHello ), baseRule + " and isComponent", QtxPopupMgr::VisibleRule );
177 mgr->setRule( action( OpGoodbye ), baseRule + " and !isComponent", QtxPopupMgr::VisibleRule );
181 \brief Get module engine IOR
183 Overloaded from SalomeApp_Module class.
185 \return string representing module engine IOR
187 QString HELLOGUI::engineIOR() const
189 init(); // initialize engine, if necessary
190 CORBA::String_var anIOR = getApp()->orb()->object_to_string( myEngine.in() );
191 return QString( anIOR.in() );
195 \brief Get module icon.
197 Overloaded from CAM_Module class.
199 Load and return the module icon pixmap. This icon is shown
200 in the Object browser, in modules toolbar, etc.
202 Default implementation uses iconName() function to retrieve the name
203 of the image file to be used as the module icon; tries to load this
204 file from module's resources and create pixmap from it.
205 Returns valid QPixmap instance if image is loaded correctly.
206 This function can be customized to provide another way to get module icon.
208 \return module icon pixmap
211 QPixmap HELLOGUI::moduleIcon() const
213 // nothing to do, in this example just call the parent implementation
214 return SalomeApp_Module::moduleIcon();
218 \brief Get module icon's file name.
220 Overloaded from CAM_Module class.
222 This function is used to get module icon image file name.
223 Default implementation tries to retrieve the name of the
224 icon file from the application using moduleIcon() function, which
225 in its turn retrieves the information about the module icon
226 from the configuration file (e.g. SalomeApp.xml, LightApp.xml).
227 This function can be customized to provide another way to get module icon's
230 \return module icon file name
233 QString HELLOGUI::iconName() const
235 // nothing to do, in this example just call the parent implementation
236 return SalomeApp_Module::iconName();
240 \brief Request dockable windows to be available when module is active.
242 Overloaded from LightApp_Module class.
244 Fills and returns the list of dockable windows which should be
245 available when the module is active. It is a map of integer values
246 where \c key is an enumerator from LightApp_Application::WindowTypes
247 enumeration, specifying window type, and \c value is an enumerator
248 from Qt::DockWidgetArea, specifying the window's default position
249 in the main window layout.
251 Empty map means no dockable windows available when the module is active.
253 \param theMap this map should be filled to specify the list of
254 required dockable windows withe their default positions
256 void HELLOGUI::windows( QMap<int, int>& theMap ) const
258 // want Object browser, in the left area
259 theMap.insert( SalomeApp_Application::WT_ObjectBrowser,
260 Qt::LeftDockWidgetArea );
261 #ifndef DISABLE_PYCONSOLE
262 // want Python console, in the bottom area
263 theMap.insert( SalomeApp_Application::WT_PyConsole,
264 Qt::BottomDockWidgetArea );
269 \brief Request view windows (types) to be activated when module is activated..
271 Overloaded from LightApp_Module class.
273 Fills and returns the list of 3D/2D view windows types compatible
274 with this module. The views of the specified type(s) will be automatically
275 activated (raised to the top of view stack) each time when the module
276 is activated by the user (the views will be automatically created if they
277 do not exist at the module activation).
278 Empty list means no compatible view windows for the module.
282 theList.append( OCCViewer_Viewer::Type() );
283 theList.append( SVTK_Viewer::Type() );
286 \param theList this list should be filled to specify the list of
287 compatible view window types
289 void HELLOGUI::viewManagers( QStringList& /*theList*/ ) const
291 // no compatible view managers, nothing to do here
295 \brief Create popup selection handler.
297 Overloaded from LightApp_Module class.
299 This function can be used to create custom popup menu handler.
300 The application takes ownership over the returned pointer,
301 so you should not destroy it.
303 This function is part of the context popup menu management mechanism.
304 Selection object (instance of LightApp_Selection class or its successor)
305 analizes the currently selected items and defines selection-dependant
306 variables which are processed by the popup manager (QtxPopupMgr class).
308 These variables can be included into the lexical constructions, named
309 "rules", which are associated with the popup menu actions (refer to the
310 QtxPopupMgr class for more details).
314 // obtain popup manager
315 QtxPopupMgr* mgr = popupMgr();
316 // create new action, with ID = 100
317 createAction( 100, "Action", QIcon(), "Action", "My action", 0, application()->desktop(),
318 false, this, SLOT( OnMyAction() ) );
319 // define popup rule for action
320 QString rule = "client='ObjectBrowser' and $type in {'MyType1' 'MyType2'} and selcount=1";
321 // set visibility rule for action
322 mgr->setRule( 100, rule, QtxPopupMgr::VisibleRule );
325 In the above code, \a selcount variable is automatically defined
326 by LightApp_Selection class, but \a type variable should be set by
327 the successor class. Note, that LightApp_Selection class implements
328 several useful variables which can be used in the lexical rules.
330 \return new selection object
331 \sa contextMenuPopup()
333 LightApp_Selection* HELLOGUI::createSelection() const
335 // nothing to do, in this example just call the parent implementation
336 // see also initialize()
337 return SalomeApp_Module::createSelection();
341 \brief Create displayer object.
343 Overloaded from LightApp_Module class.
345 This function can be used to create and return custom displayer object.
346 The application does not take the ownership over the returned value.
348 Displayer is a part of the presentations management system.
349 If can be used to implement visualization operations, like create, show
350 or hide presentation in the viewer of specific type, etc.
352 \return pointer to the module displayer
354 LightApp_Displayer* HELLOGUI::displayer()
356 // nothing to do, in this example just call the parent implementation
357 return SalomeApp_Module::displayer();
361 \brief Create context popup menu.
363 Overloaded from CAM_Module class.
365 This function can be used to customize context popup menu management.
366 The module should fill \a menu with the items (e.g. by inserting own
367 QAction items). The menu contents can be context-depending, the parameter
368 \a type can be used to test the context of the popup menu invocation
369 (e.g. "ObjectBrowser").
370 Parameter \a title can be used to return the string value to be used
371 popup menu title if required.
373 Default implementation from LightApp_Module class calls createSelection()
374 function to create popup selection handler and initialized the popup menu
377 \param type popup menu context
378 \param menu pointer to the popup menu
379 \param title custom popup menu title can be returned here
380 \sa createSelection()
382 void HELLOGUI::contextMenuPopup( const QString& type, QMenu* menu, QString& title )
384 // nothing to do, in this example just call the parent implementation
385 // see also initialize()
386 return SalomeApp_Module::contextMenuPopup( type, menu, title );
390 \brief Export module preferences.
392 Overloaded from LightApp_Module class.
394 This function is invoked only once when the common "Preferences"
395 dialog box is first time activated by the user (via the "File/Preferences"
396 menu command) or when module is first time activated.
398 This function should be used to export module preferences to the
399 common "Preferences" dialog box and associate them with the corresponding
400 widgets. The preferences items are arranged to the tree-like structure, where
401 top-level items represent just a containers for the underlying items.
402 Each low-level preferences item is linked to the resources item (via "section"
403 and "parameter" attributes). See QtxResourceMgr class for more details about
404 resources management.
408 // create top-level preferences tab page
409 int settingsId = addPreference( "Settings" );
410 // create general settings group box
411 int generalId = addPreference( tr( "General" ), settingsId );
412 // set group box property - number of columns - to 2
413 setPreferenceProperty( generalId, "columns", 2 );
414 // create shading color preferences item (color button)
415 addPreference( "Shading color", generalId, LightApp_Preferences::Color,
416 "HELLO", "shading_color" );
417 // create precision preferences item (spin box)
418 int precisionId = addPreference( tr( "GEOM_PREF_length_precision" ), generalId,
419 LightApp_Preferences::IntSpin, "HELLO", "precision" );
420 // set precision preferences item properties
421 setPreferenceProperty( precisionId, "min", 0 );
422 setPreferenceProperty( precisionId, "max", 10 );
425 \sa preferencesChanged()
427 void HELLOGUI::createPreferences()
429 // no module preferences, nothing to do here
433 \brief Process preference item change event.
435 Overloaded from LightApp_Module class.
437 This function is called every time when the preference item
438 owned by this module is changed by the user (usually this occurs when
439 the user presses "OK" or "Apply" button in the "Preferences" dialog box).
441 The module can perform any specific actions if necessary to response
442 to the preferences changes.
444 \param section resources item section name
445 \param parameter resources item parameter name
447 \sa createPreferences()
449 void HELLOGUI::preferencesChanged( const QString& section, const QString& parameter )
451 // nothing to do, in this example just call the parent implementation
452 SalomeApp_Module::preferencesChanged( section, parameter );
456 \brief Store visual state.
458 Overloaded from SalomeApp_Module class.
460 This method is called just before the study document is saved,
461 so the module has a possibility to store any visual parameters
462 in the AttributeParameter study attribute (if required).
464 \param savePoint save point unique identifier
466 void HELLOGUI::storeVisualParameters( int /*savePoint*/ )
468 // no specific visual state, nothing to do here
472 \brief Restore visual state.
474 Overloaded from SalomeApp_Module class.
476 This method is called after the study document is opened,
477 so the module has a possibility to restore the visual parameters
478 from the AttributeParameter study attribute (if required).
480 \param savePoint save point unique identifier
482 void HELLOGUI::restoreVisualParameters( int /*savePoint*/ )
484 // no specific visual state, nothing to do here
488 \brief Handle active study changing action.
490 Overloaded from LightApp_Module class.
492 This function is called each time when the active study is changed
493 (usually this happens when users switches between different studies'
496 Can be used to perform any relevant actions.
498 void HELLOGUI::studyActivated()
500 // no any specific action required, nothing to do here
504 \brief Check if the module can perform "copy" operation.
506 Overloaded from LightApp_Module class.
508 This function is a part of the general copy/paste mechanism.
510 Can be re-implemented to customize the copy/paste handling
511 in the module. Default implementation returns \c false.
513 \return \c true if the module can perform "copy" operation or \c false otherwise
514 \sa canPaste(), copy(), paste()
516 bool HELLOGUI::canCopy() const
518 // copy/paste is not supported, in this example just call the parent implementation
519 return SalomeApp_Module::canCopy();
523 \brief Check if the module can perform "paste" operation.
525 Overloaded from LightApp_Module class.
527 This function is a part of the general copy/paste mechanism.
529 Can be re-implemented to customize the copy/paste handling
530 in the module. Default implementation returns \c false.
532 \return \c true if the module can perform "paste" operation or \c false otherwise
533 \sa canCopy(), copy(), paste()
535 bool HELLOGUI::canPaste() const
537 // copy/paste is not supported, in this example just call the parent implementation
538 return SalomeApp_Module::canPaste();
542 \brief Perform "copy" operation.
544 Overloaded from LightApp_Module class.
546 This function is a part of the general copy/paste mechanism.
548 Can be re-implemented to customize the copy/paste handling
549 in the module. Default implementation does nothing.
551 \sa canCopy(), canPaste(), paste()
553 void HELLOGUI::copy()
555 // copy/paste is not supported, nothing to do here
559 \brief Perform "paste" operation.
561 Overloaded from LightApp_Module class.
563 This function is a part of the general copy/paste mechanism.
565 Can be re-implemented to customize the copy/paste handling
566 in the module. Default implementation does nothing.
568 \sa canCopy(), canPaste(), copy()
570 void HELLOGUI::paste()
572 // copy/paste is not supported, nothing to do here
576 \brief Check if the module allows "drag" operation of its objects.
578 Overloaded from LightApp_Module class.
580 This function is a part of the general drag-n-drop mechanism.
581 The goal of this function is to check data object passed as a parameter
582 and decide if it can be dragged or no.
584 \param what data object being tested for drag operation
585 \return \c true if module allows dragging of the specified object
586 \sa isDropAccepted(), dropObjects()
588 bool HELLOGUI::isDraggable( const SUIT_DataObject* what ) const
590 // we allow dragging any HELLO object, except the top-level component
591 const SalomeApp_ModuleObject* aModObj = dynamic_cast<const SalomeApp_ModuleObject*>( what );
592 return ( aModObj == 0 );
596 \brief Check if the module allows "drop" operation on the given object.
598 Overloaded from LightApp_Module class.
600 This function is a part of the general drag-n-drop mechanism.
601 The goal of this function is to check data object passed as a parameter
602 and decide if it can be used as a target for the "drop" operation.
603 The processing of the drop operation itself is done in the dropObjects() function.
605 \param where target data object
606 \return \c true if module supports dropping on the \a where data object
607 \sa isDraggable(), dropObjects()
609 bool HELLOGUI::isDropAccepted( const SUIT_DataObject* where ) const
611 // we allow dropping of all objects
612 // (temporarily implementation, we also need to check objects being dragged)
617 \brief Complete drag-n-drop operation.
619 Overloaded from LightApp_Module class.
621 This function is a part of the general drag-n-drop mechanism.
622 Its goal is to handle dropping of the objects being dragged according
623 to the chosen operation (copy or move). The dropping is performed in the
624 context of the parent data object \a where and the \a row (position in the
625 children index) at which the data should be dropped. If \a row is equal to -1,
626 this means that objects are added to the end of the children list.
628 \param what objects being dropped
629 \param where target data object
630 \param row child index at which the drop operation is performed
631 \param action drag-n-drop operation (Qt::DropAction) - copy or move
633 \sa isDraggable(), isDropAccepted()
635 void HELLOGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
636 const int row, Qt::DropAction action )
638 if (action != Qt::CopyAction && action != Qt::MoveAction)
639 return; // unsupported action
642 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
643 if ( !dataObj ) return; // wrong parent
644 _PTR(SObject) parentObj = dataObj->object();
646 // collect objects being dropped
647 HELLO_ORB::object_list_var objects = new HELLO_ORB::object_list();
648 objects->length( what.count() );
650 for ( int i = 0; i < what.count(); i++ ) {
651 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
652 if ( !dataObj ) continue; // skip wrong objects
653 _PTR(SObject) sobj = dataObj->object();
654 objects[i] = _CAST(SObject, sobj)->GetSObject();
657 objects->length( count );
659 // call engine function
660 engine()->copyOrMove( objects.in(), // what
661 _CAST(SObject, parentObj)->GetSObject(), // where
663 action == Qt::CopyAction ); // isCopy
665 // update Object browser
666 getApp()->updateObjectBrowser( false );
670 \brief Module activation.
672 Overloaded from CAM_Module class.
674 This function is called each time the module is activated
675 by the user. It is usually used to perform any relevant actions,
676 like displaying menus and toolbars, connecting specific signals/slots, etc.
678 \param theStudy current study object
679 \return \c true if activation is completed correctly or \c false
680 if module activation fails
682 \sa deactivateModule()
684 bool HELLOGUI::activateModule( SUIT_Study* theStudy )
686 // call parent implementation
687 bool bOk = SalomeApp_Module::activateModule( theStudy );
690 setMenuShown( true );
692 setToolShown( true );
694 // return the activation status
699 \brief Module deactivation.
701 Overloaded from CAM_Module class.
703 This function is called each time the module is deactivated
704 by the user. It is usually used to perform any relevant actions,
705 like hiding menus and toolbars, disconnecting specific signals/slots, etc.
707 \param theStudy current study object
708 \return \c true if deactivation is completed correctly or \c false
709 if module deactivation fails
713 bool HELLOGUI::deactivateModule( SUIT_Study* theStudy )
716 setMenuShown( false );
718 setToolShown( false );
720 // call parent implementation and return the activation status
721 return SalomeApp_Module::deactivateModule( theStudy );
725 \brief Create specific operation object.
727 Overloaded from LightApp_Module class.
729 This function is a part of operation management mechanism.
730 It can be used to create module specific operations, if module
731 implements transaction handling basing on the GUI operations instances.
733 This function is automatically called from startOperation() function.
734 After operation is created, it can be started/stopped/paused/resumed etc.
735 Compatibility between diferent simultaneously running operations is also
736 checked by invoking of the corresponding methods of the LightApp_Operation
739 The application takes ownership over the returned pointer,
740 so you should not destroy it.
742 Default implementation in LightApp_Module class processes common Show/Hide
745 \param id unique operation identifier
746 \return new operation object
748 LightApp_Operation* HELLOGUI::createOperation( const int id ) const
750 // no specific operations, in this example just call the parent implementation
751 return SalomeApp_Module::createOperation( id );
755 \brief Action slot: Test me
757 void HELLOGUI::testMe()
759 SUIT_MessageBox::information( getApp()->desktop(),
760 tr( "INF_TESTME_TITLE" ),
761 tr( "INF_TESTME_MSG" ),
766 \brief Action slot: Hello
768 void HELLOGUI::hello()
772 QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_HELLO_TITLE" ), tr( "QUE_ENTER_NAME" ),
773 QLineEdit::Normal, QString::null, &ok );
775 if ( ok && !name.trimmed().isEmpty() ) {
776 // say hello to SALOME
777 HELLO_ORB::status status = engine()->hello( (const char*)name.toLatin1() );
779 // update Object browser
780 getApp()->updateObjectBrowser(true);
782 // process operation status
784 case HELLO_ORB::OP_OK:
786 SUIT_MessageBox::information( getApp()->desktop(),
787 tr( "INF_HELLO_TITLE" ),
788 tr( "INF_HELLO_MSG" ).arg( name ),
791 case HELLO_ORB::OP_ERR_ALREADY_MET:
792 // error: already said hello
793 SUIT_MessageBox::warning( getApp()->desktop(),
794 tr( "INF_HELLO_TITLE" ),
795 tr( "ERR_HELLO_ALREADY_MET" ).arg( name ),
798 case HELLO_ORB::OP_ERR_UNKNOWN:
801 SUIT_MessageBox::critical( getApp()->desktop(),
802 tr( "INF_HELLO_TITLE" ),
811 \brief Action slot: Goodbye
813 void HELLOGUI::goodbye()
815 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
816 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
817 _PTR(Study) studyDS = study->studyDS();
818 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
823 SALOME_ListIO selected;
824 aSelMgr->selectedObjects( selected );
825 if ( selected.Extent() == 1 ) {
826 Handle(SALOME_InteractiveObject) io = selected.First();
827 _PTR(SObject) so = studyDS->FindObjectID( io->getEntry() );
829 _PTR(SComponent) comp = so->GetFatherComponent();
830 if ( comp && comp->ComponentDataType() == "HELLO" && io->getEntry() != comp->GetID() ) {
831 name = so->GetName().c_str();
836 // request user name if not specified
837 if ( name.isEmpty() ) {
839 name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_GOODBYE_TITLE" ), tr( "QUE_ENTER_NAME" ),
840 QLineEdit::Normal, QString::null, &ok );
843 if ( !name.trimmed().isEmpty() ) {
844 // say goodby to SALOME
845 HELLO_ORB::status status = engine()->goodbye( (const char*)name.toLatin1() );
847 // update Object browser
848 getApp()->updateObjectBrowser(true);
850 // process operation status
852 case HELLO_ORB::OP_OK:
854 SUIT_MessageBox::information( getApp()->desktop(),
855 tr( "INF_GOODBYE_TITLE" ),
856 tr( "INF_GOODBYE_MSG" ).arg( name ),
859 case HELLO_ORB::OP_ERR_DID_NOT_MEET:
860 // error: did not say hello yet
861 SUIT_MessageBox::warning( getApp()->desktop(),
862 tr( "INF_GOODBYE_TITLE" ),
863 tr( "ERR_GOODBYE_DID_NOT_MEET" ).arg( name ),
866 case HELLO_ORB::OP_ERR_UNKNOWN:
869 SUIT_MessageBox::critical( getApp()->desktop(),
870 tr( "INF_GOODBYE_TITLE" ),
879 \brief Perform internal initialization
881 In particular, this function initializes module engine.
883 void HELLOGUI::init()
885 // initialize HELLO module engine (load, if necessary)
886 if ( CORBA::is_nil( myEngine ) )
888 SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
889 Engines::EngineComponent_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component("FactoryServer", "HELLO");
890 myEngine = HELLO_ORB::HELLO_Gen::_narrow( comp );
896 // FACTORY FUNCTION: create an instance of the Hello module GUI
898 CAM_Module* createModule()
900 return new HELLOGUI();
902 // VERSIONING FUNCTION: get Hello module's version identifier
904 char* getModuleVersion()
906 return (char*)HELLO_VERSION_STR; // HELLO_VERSION_STR is defined in HELLO_version.h