+/*!
+ \brief Get module icon.
+
+ Overloaded from CAM_Module class.
+
+ Load and return the module icon pixmap. This icon is shown
+ in the Object browser, in modules toolbar, etc.
+
+ Default implementation uses iconName() function to retrieve the name
+ of the image file to be used as the module icon; tries to load this
+ file from module's resources and create pixmap from it.
+ Returns valid QPixmap instance if image is loaded correctly.
+ This function can be customized to provide another way to get module icon.
+
+ \return module icon pixmap
+ \sa iconName()
+*/
+QPixmap HELLOGUI::moduleIcon() const
+{
+ // nothing to do, in this example just call the parent implementation
+ return SalomeApp_Module::moduleIcon();
+}
+
+/*!
+ \brief Get module icon's file name.
+
+ Overloaded from CAM_Module class.
+
+ This function is used to get module icon image file name.
+ Default implementation tries to retrieve the name of the
+ icon file from the application using moduleIcon() function, which
+ in its turn retrieves the information about the module icon
+ from the configuration file (e.g. SalomeApp.xml, LightApp.xml).
+ This function can be customized to provide another way to get module icon's
+ file name.
+
+ \return module icon file name
+ \sa moduleIcon()
+*/
+QString HELLOGUI::iconName() const
+{
+ // nothing to do, in this example just call the parent implementation
+ return SalomeApp_Module::iconName();
+}
+
+/*!
+ \brief Request dockable windows to be available when module is active.
+
+ Overloaded from LightApp_Module class.
+
+ Fills and returns the list of dockable windows which should be
+ available when the module is active. It is a map of integer values
+ where \c key is an enumerator from LightApp_Application::WindowTypes
+ enumeration, specifying window type, and \c value is an enumerator
+ from Qt::DockWidgetArea, specifying the window's default position
+ in the main window layout.
+
+ Empty map means no dockable windows available when the module is active.
+
+ \param theMap this map should be filled to specify the list of
+ required dockable windows withe their default positions
+*/
+void HELLOGUI::windows( QMap<int, int>& theMap ) const
+{
+ // want Object browser, in the left area
+ theMap.insert( SalomeApp_Application::WT_ObjectBrowser,
+ Qt::LeftDockWidgetArea );
+#ifndef DISABLE_PYCONSOLE
+ // want Python console, in the bottom area
+ theMap.insert( SalomeApp_Application::WT_PyConsole,
+ Qt::BottomDockWidgetArea );
+#endif
+}
+
+/*!
+ \brief Request view windows (types) to be activated when module is activated..
+
+ Overloaded from LightApp_Module class.
+
+ Fills and returns the list of 3D/2D view windows types compatible
+ with this module. The views of the specified type(s) will be automatically
+ activated (raised to the top of view stack) each time when the module
+ is activated by the user (the views will be automatically created if they
+ do not exist at the module activation).
+ Empty list means no compatible view windows for the module.
+
+ Example:
+ \code
+ theList.append( OCCViewer_Viewer::Type() );
+ theList.append( SVTK_Viewer::Type() );
+ \endcode
+
+ \param theList this list should be filled to specify the list of
+ compatible view window types
+*/
+void HELLOGUI::viewManagers( QStringList& /*theList*/ ) const
+{
+ // no compatible view managers, nothing to do here
+}
+
+/*!
+ \brief Create popup selection handler.
+
+ Overloaded from LightApp_Module class.
+
+ This function can be used to create custom popup menu handler.
+ The application takes ownership over the returned pointer,
+ so you should not destroy it.
+
+ This function is part of the context popup menu management mechanism.
+ Selection object (instance of LightApp_Selection class or its successor)
+ analizes the currently selected items and defines selection-dependant
+ variables which are processed by the popup manager (QtxPopupMgr class).
+
+ These variables can be included into the lexical constructions, named
+ "rules", which are associated with the popup menu actions (refer to the
+ QtxPopupMgr class for more details).
+
+ Exampe:
+ \code
+ // obtain popup manager
+ QtxPopupMgr* mgr = popupMgr();
+ // create new action, with ID = 100
+ createAction( 100, "Action", QIcon(), "Action", "My action", 0, application()->desktop(),
+ false, this, SLOT( OnMyAction() ) );
+ // define popup rule for action
+ QString rule = "client='ObjectBrowser' and $type in {'MyType1' 'MyType2'} and selcount=1";
+ // set visibility rule for action
+ mgr->setRule( 100, rule, QtxPopupMgr::VisibleRule );
+ \endcode
+
+ In the above code, \a selcount variable is automatically defined
+ by LightApp_Selection class, but \a type variable should be set by
+ the successor class. Note, that LightApp_Selection class implements
+ several useful variables which can be used in the lexical rules.
+
+ \return new selection object
+ \sa contextMenuPopup()
+*/
+LightApp_Selection* HELLOGUI::createSelection() const
+{
+ // nothing to do, in this example just call the parent implementation
+ // see also initialize()
+ return SalomeApp_Module::createSelection();
+}
+
+/*!
+ \brief Create displayer object.
+
+ Overloaded from LightApp_Module class.
+
+ This function can be used to create and return custom displayer object.
+ The application does not take the ownership over the returned value.
+
+ Displayer is a part of the presentations management system.
+ If can be used to implement visualization operations, like create, show
+ or hide presentation in the viewer of specific type, etc.
+
+ \return pointer to the module displayer
+ */
+LightApp_Displayer* HELLOGUI::displayer()
+{
+ // nothing to do, in this example just call the parent implementation
+ return SalomeApp_Module::displayer();
+}
+
+/*!
+ \brief Create context popup menu.
+
+ Overloaded from CAM_Module class.
+
+ This function can be used to customize context popup menu management.
+ The module should fill \a menu with the items (e.g. by inserting own
+ QAction items). The menu contents can be context-depending, the parameter
+ \a type can be used to test the context of the popup menu invocation
+ (e.g. "ObjectBrowser").
+ Parameter \a title can be used to return the string value to be used
+ popup menu title if required.
+
+ Default implementation from LightApp_Module class calls createSelection()
+ function to create popup selection handler and initialized the popup menu
+ using popup manager.
+
+ \param type popup menu context
+ \param menu pointer to the popup menu
+ \param title custom popup menu title can be returned here
+ \sa createSelection()
+*/
+void HELLOGUI::contextMenuPopup( const QString& type, QMenu* menu, QString& title )
+{
+ // nothing to do, in this example just call the parent implementation
+ // see also initialize()
+ return SalomeApp_Module::contextMenuPopup( type, menu, title );
+}
+
+/*!
+ \brief Export module preferences.
+
+ Overloaded from LightApp_Module class.
+
+ This function is invoked only once when the common "Preferences"
+ dialog box is first time activated by the user (via the "File/Preferences"
+ menu command) or when module is first time activated.
+
+ This function should be used to export module preferences to the
+ common "Preferences" dialog box and associate them with the corresponding
+ widgets. The preferences items are arranged to the tree-like structure, where
+ top-level items represent just a containers for the underlying items.
+ Each low-level preferences item is linked to the resources item (via "section"
+ and "parameter" attributes). See QtxResourceMgr class for more details about
+ resources management.
+
+ Example:
+ \code
+ // create top-level preferences tab page
+ int settingsId = addPreference( "Settings" );
+ // create general settings group box
+ int generalId = addPreference( tr( "General" ), settingsId );
+ // set group box property - number of columns - to 2
+ setPreferenceProperty( generalId, "columns", 2 );
+ // create shading color preferences item (color button)
+ addPreference( "Shading color", generalId, LightApp_Preferences::Color,
+ "HELLO", "shading_color" );
+ // create precision preferences item (spin box)
+ int precisionId = addPreference( tr( "GEOM_PREF_length_precision" ), generalId,
+ LightApp_Preferences::IntSpin, "HELLO", "precision" );
+ // set precision preferences item properties
+ setPreferenceProperty( precisionId, "min", 0 );
+ setPreferenceProperty( precisionId, "max", 10 );
+ \endcode
+
+ \sa preferencesChanged()
+*/
+void HELLOGUI::createPreferences()
+{
+ // no module preferences, nothing to do here
+}
+
+/*!
+ \brief Process preference item change event.
+
+ Overloaded from LightApp_Module class.
+
+ This function is called every time when the preference item
+ owned by this module is changed by the user (usually this occurs when
+ the user presses "OK" or "Apply" button in the "Preferences" dialog box).
+
+ The module can perform any specific actions if necessary to response
+ to the preferences changes.
+
+ \param section resources item section name
+ \param parameter resources item parameter name
+
+ \sa createPreferences()
+*/
+void HELLOGUI::preferencesChanged( const QString& section, const QString& parameter )
+{
+ // nothing to do, in this example just call the parent implementation
+ SalomeApp_Module::preferencesChanged( section, parameter );
+}
+
+/*!
+ \brief Store visual state.
+
+ Overloaded from SalomeApp_Module class.
+
+ This method is called just before the study document is saved,
+ so the module has a possibility to store any visual parameters
+ in the AttributeParameter study attribute (if required).
+
+ \param savePoint save point unique identifier
+*/
+void HELLOGUI::storeVisualParameters( int /*savePoint*/ )
+{
+ // no specific visual state, nothing to do here
+}
+
+/*!
+ \brief Restore visual state.
+
+ Overloaded from SalomeApp_Module class.
+
+ This method is called after the study document is opened,
+ so the module has a possibility to restore the visual parameters
+ from the AttributeParameter study attribute (if required).
+
+ \param savePoint save point unique identifier
+*/
+void HELLOGUI::restoreVisualParameters( int /*savePoint*/ )
+{
+ // no specific visual state, nothing to do here
+}
+
+/*!
+ \brief Handle active study changing action.
+
+ Overloaded from LightApp_Module class.
+
+ This function is called each time when the active study is changed
+ (usually this happens when users switches between different studies'
+ desktops).
+
+ Can be used to perform any relevant actions.
+*/
+void HELLOGUI::studyActivated()
+{
+ // no any specific action required, nothing to do here
+}
+
+/*!
+ \brief Check if the module can perform "copy" operation.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general copy/paste mechanism.
+
+ Can be re-implemented to customize the copy/paste handling
+ in the module. Default implementation returns \c false.
+
+ \return \c true if the module can perform "copy" operation or \c false otherwise
+ \sa canPaste(), copy(), paste()
+*/
+bool HELLOGUI::canCopy() const
+{
+ // copy/paste is not supported, in this example just call the parent implementation
+ return SalomeApp_Module::canCopy();
+}
+
+/*!
+ \brief Check if the module can perform "paste" operation.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general copy/paste mechanism.
+
+ Can be re-implemented to customize the copy/paste handling
+ in the module. Default implementation returns \c false.
+
+ \return \c true if the module can perform "paste" operation or \c false otherwise
+ \sa canCopy(), copy(), paste()
+*/
+bool HELLOGUI::canPaste() const
+{
+ // copy/paste is not supported, in this example just call the parent implementation
+ return SalomeApp_Module::canPaste();
+}
+
+/*!
+ \brief Perform "copy" operation.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general copy/paste mechanism.
+
+ Can be re-implemented to customize the copy/paste handling
+ in the module. Default implementation does nothing.
+
+ \sa canCopy(), canPaste(), paste()
+*/
+void HELLOGUI::copy()
+{
+ // copy/paste is not supported, nothing to do here
+}
+
+/*!
+ \brief Perform "paste" operation.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general copy/paste mechanism.
+
+ Can be re-implemented to customize the copy/paste handling
+ in the module. Default implementation does nothing.
+
+ \sa canCopy(), canPaste(), copy()
+*/
+void HELLOGUI::paste()
+{
+ // copy/paste is not supported, nothing to do here
+}
+
+/*!
+ \brief Check if the module allows "drag" operation of its objects.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general drag-n-drop mechanism.
+ The goal of this function is to check data object passed as a parameter
+ and decide if it can be dragged or no.
+
+ \param what data object being tested for drag operation
+ \return \c true if module allows dragging of the specified object
+ \sa isDropAccepted(), dropObjects()
+*/
+bool HELLOGUI::isDraggable( const SUIT_DataObject* what ) const
+{
+ // we allow dragging any HELLO object, except the top-level component
+ const SalomeApp_ModuleObject* aModObj = dynamic_cast<const SalomeApp_ModuleObject*>( what );
+ return ( aModObj == 0 );
+}
+
+/*!
+ \brief Check if the module allows "drop" operation on the given object.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general drag-n-drop mechanism.
+ The goal of this function is to check data object passed as a parameter
+ and decide if it can be used as a target for the "drop" operation.
+ The processing of the drop operation itself is done in the dropObjects() function.
+
+ \param where target data object
+ \return \c true if module supports dropping on the \a where data object
+ \sa isDraggable(), dropObjects()
+*/
+bool HELLOGUI::isDropAccepted( const SUIT_DataObject* where ) const
+{
+ // we allow dropping of all objects
+ // (temporarily implementation, we also need to check objects being dragged)
+ return true;
+}
+
+/*!
+ \brief Complete drag-n-drop operation.
+
+ Overloaded from LightApp_Module class.
+
+ This function is a part of the general drag-n-drop mechanism.
+ Its goal is to handle dropping of the objects being dragged according
+ to the chosen operation (copy or move). The dropping is performed in the
+ context of the parent data object \a where and the \a row (position in the
+ children index) at which the data should be dropped. If \a row is equal to -1,
+ this means that objects are added to the end of the children list.
+
+ \param what objects being dropped
+ \param where target data object
+ \param row child index at which the drop operation is performed
+ \param action drag-n-drop operation (Qt::DropAction) - copy or move
+
+ \sa isDraggable(), isDropAccepted()
+*/
+void HELLOGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
+ const int row, Qt::DropAction action )
+{
+ if (action != Qt::CopyAction && action != Qt::MoveAction)
+ return; // unsupported action
+
+ // get parent object
+ SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
+ if ( !dataObj ) return; // wrong parent
+ _PTR(SObject) parentObj = dataObj->object();
+
+ // collect objects being dropped
+ HELLO_ORB::object_list_var objects = new HELLO_ORB::object_list();
+ objects->length( what.count() );
+ int count = 0;
+ for ( int i = 0; i < what.count(); i++ ) {
+ dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
+ if ( !dataObj ) continue; // skip wrong objects
+ _PTR(SObject) sobj = dataObj->object();
+ objects[i] = _CAST(SObject, sobj)->GetSObject();
+ count++;
+ }
+ objects->length( count );
+
+ // call engine function
+ engine()->copyOrMove( objects.in(), // what
+ _CAST(SObject, parentObj)->GetSObject(), // where
+ row, // row
+ action == Qt::CopyAction ); // isCopy
+
+ // update Object browser
+ getApp()->updateObjectBrowser( false );
+}
+
+/*!
+ \brief Module activation.
+
+ Overloaded from CAM_Module class.
+
+ This function is called each time the module is activated
+ by the user. It is usually used to perform any relevant actions,
+ like displaying menus and toolbars, connecting specific signals/slots, etc.
+
+ \param theStudy current study object
+ \return \c true if activation is completed correctly or \c false
+ if module activation fails
+
+ \sa deactivateModule()
+*/