Salome HOME
add the template command
[tools/sat.git] / data / templates / CppComponent / doc / index.doc
1 /*!
2
3 \mainpage Introduction to :sat:{CPPCMP} sample module
4
5 The purpose of the \b :sat:{CPPCMP} module is to describe briefly the different
6 steps in the development of a SALOME module in C++.
7
8 Contents:
9 - \subpage dev_steps
10 - \subpage tree_structure
11 - \subpage build_proc_files
12 - \subpage idl_dir
13 - \subpage src_dir
14 - \subpage bin_dir
15 - \subpage doc_dir
16 - \subpage build_procedure
17 - \subpage run_procedure
18 - \subpage load_module
19 - \subpage catalog_def
20 - \subpage load_lcc
21 - \subpage load_iapp
22
23 \ref dev_steps ">> Next"
24
25 \page dev_steps Steps in construction of the example module
26
27 The example module chosen to illustrate the process of SALOME module
28 development is very simple. The module contains a single
29 component and this component provides several services called \b
30 hello and \b goodbye.
31 Each of these functions accepts a reference to the SALOME study and
32 a character string as the arguments and returns the status of the operation.
33 The component also provides a simple GUI.
34
35 The steps in the development are as follows:
36 - create a module tree structure
37 - create a SALOME component that can be loaded by a C++ SALOME container
38 - configure the module so that the component is known to SALOME
39 - add a GUI
40
41 \ref index "<< Previous"<br>\ref tree_structure ">> Next"
42
43 \page tree_structure Create the module tree structure
44
45 The first step in the development process is the creation of the
46 module tree file hierarchy. The typical SALOME module usually includes
47 some set of the configuration files (used in the build procedure of a
48 module), Makefiles, IDL file that provides a definition of a CORBA
49 services implemented in a module and a set of source files which are
50 compiled by the build procedure to the module CORBA engine library and
51 (optionally) GUI library.
52
53 The following file structure is typical for the SALOME module:
54
55 <pre>
56 + :sat:{CPPCMP}1_SRC
57    + build_configure
58    + clean_configure
59    + configure.ac
60    + Makefile.am
61    + :sat:{CPPCMP}_version.h.in
62    + AUTHORS
63    + COPYING
64    + ChangeLog
65    + INSTALL
66    + NEWS
67    + README
68    + adm_local
69      + Makefile.am
70      + unix
71        + Makefile.am
72        + make_common_starter.am
73        + config_files
74          + Makefile.am
75          + check_GUI.m4
76          + check_:sat:{CPPCMP}.m4
77    + bin
78      + Makefile.am
79      + VERSION.in
80      + runAppli.in
81      + myrunSalome.py
82    + idl
83      + Makefile.am
84      + :sat:{CPPCMP}_Gen.idl
85    + src
86      + Makefile.am
87      + :sat:{CPPCMP}
88        + Makefile.am
89        + :sat:{CPPCMP}.hxx
90        + :sat:{CPPCMP}.cxx
91      + :sat:{CPPCMP}GUI
92        + Makefile.am
93        + :sat:{CPPCMP}GUI.h
94        + :sat:{CPPCMP}GUI.cxx
95        + :sat:{CPPCMP}_msg_en.ts
96        + :sat:{CPPCMP}_icons.ts
97    + resources
98      + Makefile.am
99      + :sat:{CPPCMP}.png
100      + goodbye.png
101      + handshake.png
102      + testme.png
103      + :sat:{CPPCMP}Catalog.xml.in
104      + SalomeApp.xml.in
105    + doc
106      + Makefile.am
107      + doxyfile.in
108      + index.doc
109      + images
110        + head.png
111      + static
112        + doxygen.css
113        + footer.html
114        + header.html.in
115 </pre>
116
117 Note that other files can be optionally present.
118
119 The usual way of the sources directory tree structure initial creation
120 is to copy it from the existing SALOME module.
121
122 \warning The files of the platform base module (KERNEL) must not be
123 copied to initialise a module tree structure. It is usually preferable
124 to copy files from another module such as GEOM or MED.
125
126 The module name is :sat:{CPPCMP}, the component name is :sat:{CPPCMP} and all the
127 files are put in a directory named :sat:{CPPCMP}1_SRC.
128 Below is a short description of these files. Note, that files with .in
129 suffix are the autoconf templates from which the actual files are
130 generated during the build procedure.
131
132 - \c build_configure
133 - \c configure.ac
134 - \c Makefile.am
135 - \c make_common_starter.am
136 - \c clean_configure
137
138 These files are a part of the build system based on GNU
139 automake/autoconf auto-tools. These files define the build procedure,
140 namely, compilation and installation rules like compiler and linker
141 options, installation destination folder, package version etc.
142
143 - \c AUTHORS
144 - \c COPYING
145 - \c ChangeLog
146 - \c INSTALL
147 - \c NEWS
148 - \c README
149
150 These files are also a usual part of the GNU auto-tools based build
151 procedure. These files are used by developers to provide an additional
152 information on a product, like license, authors and distribution
153 information, change log between versions of a product, installation
154 hints, etc.
155
156 - \c :sat:{CPPCMP}_version.h.in
157
158 This is an optional C++ header file, specifying the version
159 macro-definitions which can be used, for example, in other modules to
160 check the version of the SALOME module (:sat:{CPPCMP} module in this
161 case).
162
163 - \c adm_local
164
165 This directory contains additional administrative files used by the
166 build procedure.
167
168 - \c adm_local/unix/config_files/check_GUI.m4
169 - \c adm_local/unix/config_files/check_:sat:{CPPCMP}.m4
170
171 These files are another part of the GNU auto-tools based build
172 procedure. The scripts written in m4 language are usually used to test
173 an availability of some 3rd-party pre-requisite product, compiler
174 feature, different configuration options. For example, check_GUI.m4
175 file provides a procedure to test availability of SALOME GUI
176 module and thus specify if GUI library of :sat:{CPPCMP} module should be built
177 or no.
178
179 - \c bin
180
181 This directory usually contains different scripts.
182
183 - \c bin/VERSION.in
184
185 This file is used to document the module, it must give its version (at
186 least) and (optionally) compatibilities or incompatibilities with
187 other modules. This file is strongly recommended but is not essential
188 for operation of the module.
189
190 - \c bin/runAppli.in
191 - \c bin/myrunSalome.py
192
193 These files are not essential but make the example easier to
194 use. These are scripts that can be used to run SALOME session with
195 :sat:{CPPCMP} module.
196
197 - \c idl
198
199 This directory contains IDL files that specify the CORBA services
200 supplied by SALOME module.
201
202 - \c idl/:sat:{CPPCMP}_Gen.idl
203
204 This is the CORBA IDL definition of the services implemented by SALOME
205 :sat:{CPPCMP} module.
206
207 - \c src
208
209 This is a root directory of the module source codes. Usually it contains
210 one or more sub-directories that provide an implementation of module
211 libraries, executables, Python API modules, etc. The hierarchy of the
212 sources tree is arbitrary; it follows the specific module needs.
213
214 - \c src/:sat:{CPPCMP}
215
216 This directory provides implementation of engine library.
217
218 - \c src/:sat:{CPPCMP}/:sat:{CPPCMP}.hxx
219 - \c src/:sat:{CPPCMP}/:sat:{CPPCMP}.cxx
220
221 These files provide the implementation of a CORBA engine library of
222 the :sat:{CPPCMP} module. In particular, this is an implementation of the
223 services defined in the \c :sat:{CPPCMP}_Gen.idl file.
224
225 - \c :sat:{CPPCMP}GUI
226
227 It is an optional directory that provides an implementation of :sat:{CPPCMP}
228 module's GUI library.
229
230 Strictly speaking, the GUI library is optional for each SALOME module.
231 In some cases it's enough to implement CORBA engine only. Then,
232 the services of the module will be avaiable in a CORBA environment.
233 The module can be loaded to the SALOME container and its services
234 can be used in the SALOME supervision computation schemas, in Python
235 scripts or/and in C++ implementation of other modules.
236
237 A GUI library is necessary only if it is planned to access the module
238 functionality from the SALOME GUI session via menu actions, dialog boxes
239 and so on.
240
241 - \c src/:sat:{CPPCMP}GUI/:sat:{CPPCMP}GUI.h
242 - \c src/:sat:{CPPCMP}GUI/:sat:{CPPCMP}GUI.cxx
243
244 These files provide the implementation of a GUI library of
245 the :sat:{CPPCMP} module. In particular, these files specify menus, toolbars,
246 dialog boxes and other such staff.
247
248 - \c src/:sat:{CPPCMP}GUI/:sat:{CPPCMP}_msg_en.ts
249 - \c src/:sat:{CPPCMP}GUI/:sat:{CPPCMP}_icons.ts
250
251 These files provide a description (internationalization) of GUI
252 resources of the :sat:{CPPCMP} module. \c :sat:{CPPCMP}_msg_en.ts provides an English
253 translation of the string resources used in a module (there can be also
254 translation files for other languages, for instance French; these files
255 are distinguished by the language suffix). \c :sat:{CPPCMP}_icons.ts
256 defines images and icons resources used within the GUI library of
257 :sat:{CPPCMP} module. Please refer to Qt linguist documentation for more
258 details.
259
260 - \c resources
261
262 This optional directory usually contains different resources files
263 required for the correct operation of SALOME module.
264
265 - \c resources/:sat:{CPPCMP}.png
266 - \c resources/handshake.png
267 - \c resources/goodbye.png
268 - \c resources/testme.png
269
270 These are different module icon files. \c :sat:{CPPCMP}.png file provides main icon
271 of :sat:{CPPCMP} module to be shown in the SALOME GUI desktop. Other files are
272 the icons for the functions implemented by the module; they are used
273 in the menus and toolbars.
274
275 - \c resources/:sat:{CPPCMP}Catalog.xml.in
276
277 The XML description of the CORBA services provided by the :sat:{CPPCMP}
278 module. This file is parsed by SALOME supervision module (YACS) to generate
279 the list of service nodes to be used in the calculation schemas. The
280 simplest way to create this file is to use Catalog Generator utility
281 provided by the SALOME KERNEL module, that can automatically generate
282 XML description file from the IDL file. In GUI, this utility is available
283 via the Tools main menu.
284
285 - \c resources/SalomeApp.xml.in
286
287 This file is essential for each SALOME module. It provides some parameters of
288 the module which define its behavior in SALOME. In particular it
289 should provide a section with the name corresponding to the name of a
290 module (":sat:{CPPCMP}" in our case) with the following parameters:
291 \code
292   <section name=":sat:{CPPCMP}">
293     <parameter name="name"          value=":sat:{CPPCMP}"/>
294     <parameter name="icon"          value=":sat:{CPPCMP}.png"/>
295     <parameter name="version"       value="@VERSION@"/>
296     <parameter name="documentation" value=":sat:{CPPCMP}_help"/>
297   </section>
298 \endcode
299
300 The \a "name" parameter defines GUI name of a module. The \a "icon"
301 parameter defines a GUI icon of a module. Optional \a "version" parameter
302 defines the version fo the module. The \a "documentation" parameter
303 provides a name for the help-related resource section (see below).
304
305 The section \a "resources" of a file specifies the directory that contains
306 resources of a module (icons, translation files, etc).
307
308 \code
309   <section name="resources">
310     <parameter name=":sat:{CPPCMP}" value="%:sat:{CPPCMP}_ROOT_DIR%/share/salome/resources/:sat:{CPPCMP}"/>
311   </section>
312 \endcode
313
314 The section \a ":sat:{CPPCMP}_help" provides information on the location of
315 the help page(s) and the eventual sub-menu in the Help menu. The name of this section
316 can be arbitrary, in such a case it should be specified in the main module's resources
317 section (see above). Alternatively, this section's name can have syntax
318 \a "<module_name>_documentation", where \a module_name is a name of the module.
319 If such section is present in the resource file, it is not necessary to specify it
320 in the module's main section.
321
322 Parameter \a "sub_menu" of the documentation section allows sepecifying the name of the
323 sub-menu in the Help main menu where the documentation materials of a module should be
324 put.
325
326 \code
327   <section name=":sat:{CPPCMP}_help" >
328     <parameter name="sub_menu"        value="Samples"/>
329     <parameter name="%1 User's Guide" value="%:sat:{CPPCMP}_ROOT_DIR%/share/doc/salome/gui/:sat:{CPPCMP}/index.html"/>
330   </section>
331 \endcode
332
333 - \c doc
334
335 This directory containes the files related to the module's documentation.
336
337 - \c doc/doxyfile.in
338
339 The \b Doxygen configuration file. The Doxygen is used to build this
340 documentation. The file \c doxyfile.in provides a rules for the
341 generation of module documentation.
342
343 - \c doc/index.doc
344
345 An input file for the Doxygen, which provides a source of this documentation.
346
347 - \c doc/images
348
349 This sub-folder contains images used in the documentation.
350
351 - \c doc/static
352
353 This sub-folder contains auxiliary files used when generating documentation
354 by Doxygen, like header (\c header.html.in) and footer (\c footer.html)
355 of the HTML pages, style sheet (\c doxygen.css) etc.
356
357 \ref dev_steps "<< Previous"<br>\ref build_proc_files ">> Next"
358
359 \page build_proc_files Build procedure input files
360
361 In most cases SALOME uses \b autoconf, \b automake and other GNU auto-tools
362 to build the modules. The \c configure script is used for the build procedure
363 to test the system configuration and to pre-configure the module construction
364 \c Makefile files.
365
366 The \c build_configure script provides a procedure that uses
367 \c configure.ac and set of \c Makefile.am files as input and uses \b autoconf
368 to generate the \c configure script and \b automake to generate \c Makefile.in
369 files.
370
371 The files with an \c .in extension are the skeletons that are the input
372 of the \c configure script (to be more precise, these files should be
373 listed in the end of the \c configure.ac file in the \c AC_OUTPUT()
374 autoconf macro) and are transformed to the resulting files during the
375 configuration process.
376
377 Almost all files used for this process are located in SALOME
378 base module KERNEL that is referenced by the \c KERNEL_ROOT_DIR
379 environment variable, namely in its \c salome_adm sub-folder.
380 Similarly, the \c GUI_ROOT_DIR environment variable is used for the
381 graphical user interface (GUI) module of SALOME; this module also
382 provides a set of configuration utilities (m4 files) in its
383 \c adm_local folder. However, some files must be modified as a
384 function of the target module. This is the case for \c build_configure
385 and \c configure.ac files which usually need to be adapted to the module needs.
386
387 The file \c make_common_starter.am file in the \c adm_local directory of
388 the :sat:{CPPCMP} module provides basic build rules to be used in other
389 \c Makefile.am files. To refer to this file in any \c Makefile.am it is
390 necessary to use \a "include" clause:
391
392 \code
393 include $(top_srcdir)/adm_local/unix/make_common_starter.am
394 \endcode
395
396 The \c adm_local/unix/config_files is a directory in which the m4 files
397 that are used to test the configuration of the system in the configuration
398 process can be placed. If the \c salome_adm files are not sufficient,
399 additional configuration files can be put to the \c adm_local directory.
400
401 \ref tree_structure "<< Previous"<br>\ref idl_dir ">> Next"
402
403 \page idl_dir The idl directory
404
405 The \c idl directory requires a \c Makefile.am that must make the
406 compilation of the CORBA IDL \c :sat:{CPPCMP}_Gen.idl file and install all the
407 generated files into the correct module installation directories. The
408 \a BASEIDL_FILES target has to be modified to reach this goal.
409
410 The IDL file itself must define a CORBA component for which the name must
411 be different from the module name to avoid name conflicts and define a
412 CORBA interface that is derived at least from the \a EngineComponent interface
413 of the \a Engines module. In case of :sat:{CPPCMP} module, the name of the CORBA
414 component is \b :sat:{CPPCMP}_ORB and the name of the interface is \b :sat:{CPPCMP}_Gen.
415
416 \ref build_proc_files "<< Previous"<br>\ref src_dir ">> Next"
417
418 \page src_dir The src directory
419
420 The \c src directory contains all source files required to build CORBA engine and
421 (optionally) GUI libraries of the module. Each of these entities usually
422 has (but this is not actually obligatory) its own directory.
423
424 The \c Makefile.am simply triggers the path of sub-directories described
425 by the \a SUBDIRS target.
426
427 - \c src/:sat:{CPPCMP} sub-directory
428
429 This sub-directory contains the C++ source files that implement the engine
430 library of the module. The \c Makefile.am defines the rules used to build
431 the engine library from these source files. The name of the module
432 engine library is predefined and should be set as \c lib\<MODULE\>Engine.so
433 where \c MODULE is a name of the module. In the case of the :sat:{CPPCMP}
434 module, the name of the engine library should be \c lib:sat:{CPPCMP}Engine.so.
435
436 The \c :sat:{CPPCMP}.h, \c :sat:{CPPCMP}.cxx files implement \a :sat:{CPPCMP} class that is derived
437 from the \a :sat:{CPPCMP}_Gen interface of the \a POA_:sat:{CPPCMP}_ORB CORBA module and the
438 \a SALOME_Component_i class (base implementation of SALOME module engine
439 exported by the KERNEL module).
440
441 In particular, \a :sat:{CPPCMP} class implements \a hello() and \a goodbye() functions
442 that are defined in the IDL interface \a :sat:{CPPCMP}_ORB:::sat:{CPPCMP}_Gen.
443
444 \code
445 :sat:{CPPCMP}_ORB::status :sat:{CPPCMP}::hello( SALOMEDS::Study_ptr study, const char* name )
446 {
447 ...
448 }
449 :sat:{CPPCMP}_ORB::status :sat:{CPPCMP}::goodbye( SALOMEDS::Study_ptr study, const char* name )
450 {
451 ...
452 }
453 \endcode
454
455 In addition, \c :sat:{CPPCMP}.cxx implements a factory function which is used by
456 the SALOME container to create an instance of the :sat:{CPPCMP} CORBA engine
457 by demand:
458
459 \code
460 extern "C"
461 {
462   PortableServer::ObjectId* :sat:{CPPCMP}Engine_factory(
463     CORBA::ORB_ptr orb,
464     PortableServer::POA_ptr poa,
465     PortableServer::ObjectId* contId,
466     const char* instanceName,
467     const char* interfaceName)
468   {
469     :sat:{CPPCMP}* my:sat:{CPPCMP} = new :sat:{CPPCMP}(orb, poa, contId, instanceName, interfaceName);
470     return my:sat:{CPPCMP}->getId();
471   }
472 }
473 \endcode
474
475 - \c src/:sat:{CPPCMP}GUI sub-directory
476
477 This directory contains the C++ source files that implement the GUI
478 library of :sat:{CPPCMP} module. By default, the name of the module
479 GUI library is predefined and should be set as \c lib\<MODULE\>.so
480 where \c MODULE is a name of the module. In the case of the :sat:{CPPCMP}
481 module, the name of the GUI library should be \c lib:sat:{CPPCMP}.so. It is
482 also possible to use custom name of the GUI library of a module, but
483 in this case, in order to be possible to use this module in SALOME GUI
484 desktop, the name of the GUI library should be defined in the
485 \c SalomeApp.xml file, in the module's main section, using \a "library"
486 parameter, for example:
487
488 \code
489   <section name=":sat:{CPPCMP}">
490     <parameter name="name" value=":sat:{CPPCMP}"/>
491     <parameter name="icon" value=":sat:{CPPCMP}.png"/>
492     <parameter name="library" value="libMy:sat:{CPPCMP}GUIlibrary.so"/>
493   </section>
494 \endcode
495
496 The implementation of GUI library of the :sat:{CPPCMP} module should be done
497 according to the architecture and rules specified by the SALOME GUI
498 module. The main GUI module class (a\ :sat:{CPPCMP}GUI in our case) should be
499 derived from the \a SalomeApp_Module class.
500
501 The developer has to redefine a set of methods which define the
502 module behavior in GUI, for example, create menus, toolbars, define
503 context popup menus, objects selection behavior, implement dialog
504 boxes etc.
505
506 Here below is a short description of these methods. For more details
507 please refer to the SALOME GUI module documentation.
508
509 - \a initialize() - module initialization; usually used to create
510   GUI actions, menus, toolbars and so on;
511 - \a activateModule() - module activation; perform actions which should
512   be done when the module is activated by the user, for example, show
513   related menus and toolbars;
514 - \a deactivateModule() - module deactivation; perform actions which should
515   be done when the module is deactivated by the user, for example,
516   hide related menus and toolbars;
517 - \a windows() - get a list and a position of the dockable windows to be
518   associated with the module; these windows will be automatically
519   opened and positioned according to the settings defined by the value
520   returned by this function;
521 - \a viewManagers() - get a list of the compatible viewers; these viewers
522   will be automatically opened/raised on the module activation;
523 - \a contextMenuPopup() - create and return context popup menu according
524   to the current selection;
525 - \a createPreferences() - initialize module's preferences;
526 - \a preferencesChanged() - callback function that is called when some
527   module's preference is changed by the user; allows to perform the
528   corresponding actions;
529 - \a createSelection() - create and return menu selection object; this is
530   a part of the context popup menu definition API;
531 - \a engineIOR() - get the reference to the module CORBA engine;
532 - \a moduleIcon() and \a iconName() - these methods can be used to customize
533   the module's main icon;
534 - \a displayer() - get the reference to the module's \a Displayer class; this
535   is the part of common Show/Hide functionality mechanism;
536 - \a storeVisualParameters() and \a restoreVisualParameters() - these methods
537   can be redefined to store/restore different visualization attributes of the
538   presentable data if it is supported by the module, for example transparency,
539   colors, display mode and other presentable parameters;
540 - \a canCopy(), \a copy(), \a canPaste(), \a paste() - these methods are the
541   part of the common Copy/Paste functionality;
542 - \a isDraggable(), \a isDropAccepted(), \a dropObjects() - these methods
543   are the part of the common Drag-n-Drop functionality;
544 - \a createOperation() - this function can be used as a part of the
545   transaction-based operations mechanism.
546 - \a renameAllowed(), \a renameObject() - can be used for in-place (Object
547   browser) renaming of the data entities, if it is supported by the module.
548
549 Note, that all of these methods are optional and need not be
550 obligatory implemented because \a SalomeApp_Module class provides a
551 base implementation of these functions. It's sometimes enough to
552 implement only some of them, depending on the module needs.
553
554 In the case of :sat:{CPPCMP} module, only the following methods are
555 implemented (other ones are just stubs, added for sample reasons):
556
557 - \a engineIOR() that initializes :sat:{CPPCMP} module's engine:
558
559 \code
560 QString :sat:{CPPCMP}GUI::engineIOR() const
561 {
562   init(); // initialize engine, if necessary
563   CORBA::String_var anIOR = getApp()->orb()->object_to_string( myEngine.in() );
564   return QString( anIOR.in() );
565 }
566 \endcode
567
568 - \a initialize() that creates actions, menus and toolbars for module's services
569   service:
570
571 \code
572 void :sat:{CPPCMP}GUI::initialize( CAM_Application* app )
573 {
574   // call the parent implementation
575   SalomeApp_Module::initialize( app );
576
577   // get reference to the desktop (used as a parent for actions)
578   QWidget* dsk = app->desktop();
579   // get resources manager
580   SUIT_ResourceMgr* resMgr = app->resourceMgr();
581
582   // create actions
583   // ... Test me operation
584   createAction( OpTestMe,                                               // operation id
585                 tr( "TLT_OP_TESTME" ),                                  // tooltip
586                 resMgr->loadPixmap( ":sat:{CPPCMP}",tr( "ICON_OP_TESTME" ) ),   // icon
587                 tr( "MEN_OP_TESTME" ),                                  // menu title
588                 tr( "STS_OP_TESTME" ),                                  // status tip
589                 0,                                                      // accelerator (not set)
590                 dsk,                                                    // parent
591                 false,                                                  // togglable flag (no)
592                 this,                                                   // action receiver
593                 SLOT( testMe() ) );                                     // action slot
594   // create other actions ............
595
596   // create menus
597   int menuId;
598   menuId = createMenu( tr( "MEN_FILE" ), -1, -1 );                      // File menu
599   createMenu( separator(), menuId, -1, 10 );                            // add separator to File menu
600   menuId = createMenu( tr( "MEN_FILE_:sat:{CPPCMP}" ), menuId, -1, 10 );        // File - :sat:{CPPCMP} submenu
601   createMenu( OpTestMe, menuId );                                       // File - :sat:{CPPCMP} - Test me
602   // create other menus ............
603
604   // create toolbars
605   int aToolId;
606   aToolId = createTool ( tr( "TOOL_TEST" ) );                           // Test toolbar
607   createTool( OpTestMe, aToolId );                                      // Test - Test me
608   // create other toolbars ............
609
610   // set-up popup menu
611   QtxPopupMgr* mgr = popupMgr();
612   mgr->insert( action( Op:sat:{CPPCMP} ),   -1, -1 );                           // :sat:{CPPCMP}
613   mgr->setRule( action( Op:sat:{CPPCMP} ),   baseRule + " and isComponent",  QtxPopupMgr::VisibleRule );
614   // create other popup menu commands ............
615 }
616 \endcode
617
618 - \a activateModule() that activates menus and toolbars
619
620 \code
621 bool :sat:{CPPCMP}GUI::activateModule( SUIT_Study* theStudy )
622 {
623   // call parent implementation
624   bool bOk = SalomeApp_Module::activateModule( theStudy );
625
626   // show own menus
627   setMenuShown( true );
628   // show own toolbars
629   setToolShown( true );
630
631   // return the activation status
632   return bOk;
633 }
634 \endcode
635
636 - \a deactivateModule() that deactivates menus and toolbars
637
638 \code
639 bool :sat:{CPPCMP}GUI::deactivateModule( SUIT_Study* theStudy )
640 {
641   // hide own menus
642   setMenuShown( false );
643   // hide own toolbars
644   setToolShown( false );
645
646   // call parent implementation and return the activation status
647   return SalomeApp_Module::deactivateModule( theStudy );
648 }
649 \endcode
650
651 - \a windows() that set-ups dockable windows requested by the module
652
653 \code
654 void :sat:{CPPCMP}GUI::windows( QMap<int, int>& theMap ) const
655 {
656   // want Object browser, in the left area
657   theMap.insert( SalomeApp_Application::WT_ObjectBrowser,
658                  Qt::LeftDockWidgetArea );
659   // want Python console, in the bottom area
660   theMap.insert( SalomeApp_Application::WT_PyConsole,
661                  Qt::BottomDockWidgetArea );
662 }
663 \endcode
664
665 - \a isDragable(), \a isDropAccepted() and \a dropObjects() methods that handle
666 the Drag-n-Drop operation
667
668 \code
669 bool :sat:{CPPCMP}GUI::isDragable( const SUIT_DataObject* what ) const
670 {
671   // we allow dragging any :sat:{CPPCMP} object, except the top-level component
672   const SalomeApp_ModuleObject* aModObj = dynamic_cast<const SalomeApp_ModuleObject*>( what );
673   return ( aModObj == 0 );
674 }
675
676 bool :sat:{CPPCMP}GUI::isDropAccepted( const SUIT_DataObject* where ) const
677 {
678   // we allow dropping of all objects
679   return true;
680 }
681
682 void :sat:{CPPCMP}GUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
683                             const int row, Qt::DropAction action )
684 {
685   if (action != Qt::CopyAction && action != Qt::MoveAction)
686     return; // unsupported action
687
688   // get parent object
689   SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
690   if ( !dataObj ) return; // wrong parent
691   _PTR(SObject) parentObj = dataObj->object();
692
693   // collect objects being dropped
694   :sat:{CPPCMP}_ORB::object_list_var objects = new :sat:{CPPCMP}_ORB::object_list();
695   objects->length( what.count() );
696   int count = 0;
697   for ( int i = 0; i < what.count(); i++ ) {
698     dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
699     if ( !dataObj ) continue;  // skip wrong objects
700     _PTR(SObject) sobj = dataObj->object();
701     objects[i] = _CAST(SObject, sobj)->GetSObject();
702     count++;
703   }
704   objects->length( count );
705
706   // call engine function
707   engine()->copyOrMove( objects.in(),                              // what
708                         _CAST(SObject, parentObj)->GetSObject(),   // where
709                         row,                                       // row
710                         action == Qt::CopyAction );                // isCopy
711
712   // update Object browser
713   getApp()->updateObjectBrowser( false );
714 }
715 \endcode
716
717 An implemention of the \a hello() and \a goodbye() methods is quite simple.
718 These operations show the dialog box proposing the user to enter the name and
719 pass the name entered by the user to the engine side, using the corresponding
720 CORBA service.
721
722 \code
723 void :sat:{CPPCMP}GUI::hello()
724 {
725   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
726   _PTR(Study) studyDS = study->studyDS();
727
728   // request user name
729   bool ok;
730   QString name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_:sat:{CPPCMP}_TITLE" ), tr( "QUE_ENTER_NAME" ),
731                                         QLineEdit::Normal, QString::null, &ok );
732
733   if ( ok && !name.trimmed().isEmpty() ) {
734     // say :sat:{CPPCMP} to SALOME
735     :sat:{CPPCMP}_ORB::status status = engine()->:sat:{CPPCMP}( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
736
737     // update Object browser
738     getApp()->updateObjectBrowser(true);
739
740     // process operation status
741     switch( status ) {
742     case :sat:{CPPCMP}_ORB::OP_OK:
743       // everything's OK
744       SUIT_MessageBox::information( getApp()->desktop(),
745                                     tr( "INF_:sat:{CPPCMP}_TITLE" ),
746                                     tr( "INF_:sat:{CPPCMP}_MSG" ).arg( name ),
747                                     tr( "BUT_OK" ) );
748       break;
749     case :sat:{CPPCMP}_ORB::OP_ERR_ALREADY_MET:
750       // error: already said :sat:{CPPCMP}
751       SUIT_MessageBox::warning( getApp()->desktop(),
752                                 tr( "INF_:sat:{CPPCMP}_TITLE" ),
753                                 tr( "ERR_:sat:{CPPCMP}_ALREADY_MET" ).arg( name ),
754                                 tr( "BUT_OK" ) );
755       break;
756     case :sat:{CPPCMP}_ORB::OP_ERR_UNKNOWN:
757     default:
758       // other errors
759       SUIT_MessageBox::critical( getApp()->desktop(),
760                                  tr( "INF_:sat:{CPPCMP}_TITLE" ),
761                                  tr( "ERR_ERROR" ),
762                                  tr( "BUT_OK" ) );
763       break;
764     }
765   }
766 }
767
768 void :sat:{CPPCMP}GUI::goodbye()
769 {
770   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
771   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
772   _PTR(Study) studyDS = study->studyDS();
773   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
774
775   QString name;
776
777   // get selection
778   SALOME_ListIO selected;
779   aSelMgr->selectedObjects( selected );
780   if ( selected.Extent() == 1 ) {
781     Handle(SALOME_InteractiveObject) io = selected.First();
782     _PTR(SObject) so = studyDS->FindObjectID( io->getEntry() );
783     if ( so ) {
784       _PTR(SComponent) comp = so->GetFatherComponent();
785       if ( comp && comp->ComponentDataType() == ":sat:{CPPCMP}" && io->getEntry() != comp->GetID() ) {
786         name = so->GetName().c_str();
787       }
788     }
789   }
790
791   // request user name if not specified
792   if ( name.isEmpty() ) {
793     bool ok;
794     name = QInputDialog::getText( getApp()->desktop(), tr( "QUE_GOODBYE_TITLE" ), tr( "QUE_ENTER_NAME" ),
795                                   QLineEdit::Normal, QString::null, &ok );
796   }
797
798   if ( !name.trimmed().isEmpty() ) {
799     // say goodby to SALOME
800     :sat:{CPPCMP}_ORB::status status = engine()->goodbye( _CAST(Study, studyDS)->GetStudy(), (const char*)name.toLatin1() );
801
802     // update Object browser
803     getApp()->updateObjectBrowser(true);
804
805     // process operation status
806     switch( status ) {
807     case :sat:{CPPCMP}_ORB::OP_OK:
808       // everything's OK
809       SUIT_MessageBox::information( getApp()->desktop(),
810                                     tr( "INF_GOODBYE_TITLE" ),
811                                     tr( "INF_GOODBYE_MSG" ).arg( name ),
812                                     tr( "BUT_OK" ) );
813       break;
814     case :sat:{CPPCMP}_ORB::OP_ERR_DID_NOT_MEET:
815       // error: did not say :sat:{CPPCMP} yet
816       SUIT_MessageBox::warning( getApp()->desktop(),
817                                 tr( "INF_GOODBYE_TITLE" ),
818                                 tr( "ERR_GOODBYE_DID_NOT_MEET" ).arg( name ),
819                                 tr( "BUT_OK" ) );
820       break;
821     case :sat:{CPPCMP}_ORB::OP_ERR_UNKNOWN:
822     default:
823       // other errors
824       SUIT_MessageBox::critical( getApp()->desktop(),
825                                  tr( "INF_GOODBYE_TITLE" ),
826                                  tr( "ERR_ERROR" ),
827                                  tr( "BUT_OK" ) );
828       break;
829     }
830   }
831 }
832 \endcode
833
834 Also, \c :sat:{CPPCMP}GUI.cxx provide an implementation of a factory function that is used
835 by the SALOME GUI to create an instance of the :sat:{CPPCMP} GUI class by demand.
836 It implements also another factory function to retrieve the
837 version number of the module (in the About dialog box for example):
838
839 \code
840 extern "C" {
841   CAM_Module* createModule()
842   {
843     return new :sat:{CPPCMP}GUI();
844   }
845
846   char* getModuleVersion()
847   {
848     return (char*):sat:{CPPCMP}_VERSION_STR;
849   }
850 }
851 \endcode
852
853 \ref idl_dir "<< Previous"<br>\ref bin_dir ">> Next"
854
855 \page bin_dir The bin directory
856
857 The file \c VERSION.in is used to document the module, it must define its
858 version and (optionally) its compatibilities or incompatibilities with
859 other modules. Therefore, it is strongly recommended but is not
860 essential for correct operation of the module.
861
862 The \c runAppli.in file is the equivalent of the \c runSalome script
863 distributed by the KERNEL module but configured to start SALOME
864 session with :sat:{CPPCMP} module only.
865
866 The \c myrunSalome.py file reuses part of functionality provided by the
867 KERNEL's \c runSalome.py script. It is used to run SALOME session and
868 start :sat:{CPPCMP} module in this session.
869
870 \ref src_dir "<< Previous"<br>\ref doc_dir ">> Next"
871
872 \page doc_dir The doc directory
873
874 This directory provides documentation files of the module. The
875 documentation of the module can be implemented in the arbitrary
876 way. But if you want your documentation to appear in the SALOME GUI
877 desktop's Help menu, some specific actions should be done as follows.
878
879 The documentation should be generated in the HTML format. For example,
880 the documentation of the :sat:{CPPCMP} module is generated using Doxygen
881 tool. It allows to generate structured set of HTML pages from the set
882 of input plain text files. Input source files should include Doxygen
883 tags and optionally direct HTML tags. For more details please refer to
884 the Doxygen documentation.
885
886 The resulting documentation of a module should include at least one
887 file \c index.html. All the HTML and image files should be exported by
888 the build procedure to the following directory:
889 \c \<module_installation_dir\>/share/doc/salome/gui/\<MODULE\>
890 where \c module_installation_dir is a module installation folder and
891 \c MODULE is its name. For example, for :sat:{CPPCMP} module, at least one file
892 should exist:
893 \c \<:sat:{CPPCMP}_module_installation_dir\>/share/doc/salome/gui/:sat:{CPPCMP}/index.html.
894
895 The SALOME GUI automatically searches for the index.html file in the
896 mentioned module directory. If the file is found, the corresponding
897 menu command is automatically added to the Help menu of the SALOME GUI
898 desktop.
899
900 \ref bin_dir "<< Previous"<br>\ref build_procedure ">> Next"
901
902 \page build_procedure Construction, installation
903
904 Before building :sat:{CPPCMP} module, please ensure that SALOME environment is
905 set properly. Assume that SALOME environment is set in env_products.sh
906 script. In order to build and install :sat:{CPPCMP} module, you have to
907 perform several steps:
908
909 <pre>
910 [bash% ] source env_products.sh
911 [bash% ] mkdir :sat:{CPPCMP}_BUILD
912 [bash% ] cd :sat:{CPPCMP}_BUILD
913 [bash% ] ../:sat:{CPPCMP}1_SRC/build_configure
914 [bash% ] ../:sat:{CPPCMP}1_SRC/configure --prefix=\<:sat:{CPPCMP}_module_installation_dir\>
915 [bash% ] make
916 [bash% ] make install
917 </pre>
918
919 The first command creates a build directory for the :sat:{CPPCMP} module. Then
920 next step is to cd to this build directory. From this directory you
921 sequentially invoke \c build_configure, \c configure, \c make and \c make install
922 commands. On each step, you have to ensure that the operation is
923 finished correctly (no errors raised).
924
925 The \c \<:sat:{CPPCMP}_module_installation_dir\> variable above defines the
926 destination directory to which the :sat:{CPPCMP} module should be
927 installed. After the last step is finished, the :sat:{CPPCMP} module is built
928 and installed to the \c \<:sat:{CPPCMP}_module_installation_dir\> directory.
929
930 \ref doc_dir "<< Previous"<br>\ref run_procedure ">> Next"
931
932 \page run_procedure Running SALOME
933
934 Go to the the \c \<:sat:{CPPCMP}_module_installation_dir\> directory and type:
935
936 <pre>
937 [bash% ] ./bin/salome/runAppli
938 </pre>
939
940 This command runs SALOME session configured for KERNEL and the :sat:{CPPCMP}
941 module. At the end of running, the user will be prompted by the
942 Python interpreter command line configured for SALOME that provides
943 access to SALOME Python API (including CORBA interfaces).
944
945 The \c runAppli file is a shell script that executes a Python commands
946 running SALOME session by passing arguments to it in a command line:
947
948 <pre>
949 ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python -i $:sat:{CPPCMP}_ROOT_DIR/bin/salome/myrunSalome.py --modules=:sat:{CPPCMP} --killall
950 </pre>
951
952 These arguments state that the \c myrunSalome.py script located in the
953 :sat:{CPPCMP} module will be used, that the :sat:{CPPCMP} component will be
954 activated and all previously running SALOME sessions should be
955 shutdowned.
956
957 This command will not function unless the following environment
958 variables have previously been set:
959
960 <pre>
961 export KERNEL_ROOT_DIR=\<KERNEL_module_installation_dir\>
962 export :sat:{CPPCMP}_ROOT_DIR=\<:sat:{CPPCMP}_module_installation_dir\>
963 </pre>
964
965 \warning It is possible that the SALOME run will not reach the end.
966 In some circumstances, the time to start CORBA servers may be long and
967 could exceed the timeout. If the reasons is that the time to
968 load dynamic libraries is long, it is possible that a second run
969 immediately afterwards will be successful.
970
971 \ref build_procedure "<< Previous"<br>\ref load_module ">> Next"
972
973 \page load_module Loading :sat:{CPPCMP} component
974
975 The \a :sat:{CPPCMP}_ORB module has to be imported before making a request to
976 load the component into the container, to obtain access to methods of
977 the component.  This container is made accessible in the \c myrunSalome.py
978 by means of the \a container variable:
979
980 <pre>
981 >> import salome
982 >> salome.salome_init()
983 >> import :sat:{CPPCMP}_ORB
984 >> c = container.load_impl(":sat:{CPPCMP}", ":sat:{CPPCMP}")
985 >> c.:sat:{CPPCMP}(salome.myStudy, "Christian")
986 </pre>
987
988 The last instruction invokes :sat:{CPPCMP} module's service \a :sat:{CPPCMP}(). Proceed as
989 follows to see the CORBA objects created by these actions:
990
991 <pre>
992 >> clt.showNS()
993 </pre>
994
995 \ref run_procedure "<< Previous"<br>\ref catalog_def ">> Next"
996
997 \page catalog_def :sat:{CPPCMP} module catalog definition
998
999 In the example from the previous chapter, the :sat:{CPPCMP} component was
1000 loaded by making a direct request to the SALOME container. This is not
1001 the standard method for loading of a component. The normal way uses
1002 the SALOME LifeCycle service that invokes SALOME Module Catalog
1003 services to identify the component and its properties and then calls
1004 the requested container to load the component.
1005
1006 Before this method can be used, the component must be declared in a
1007 catalog in the XML format, for which the name must be
1008 \c \<MODULE\>Catalog.xml. In our case, it will be \c :sat:{CPPCMP}Catalog.xml.
1009 Usually this catalog is put to the resources sub-directory of the
1010 directory tree. The simplest way to create this file is to use Catalog
1011 Generator utility provided by the SALOME KERNEL module, that can
1012 automatically generate XML description file from the IDL file.
1013
1014 \ref load_module "<< Previous"<br>\ref load_lcc ">> Next"
1015
1016 \page load_lcc Loading :sat:{CPPCMP} component via LifeCycle service
1017
1018 The method of loading the component is not very different from that
1019 is described above. The services of the LifeCycle module are used in
1020 this case instead of calling the container directly. The call sequence
1021 is contained in the \c myrunSalome.py \a test() function.
1022
1023 <pre>
1024     import salome
1025     salome.salome_init()
1026     c = test(clt)
1027     c.:sat:{CPPCMP}(salome.myStudy, "Christian")
1028 </pre>
1029
1030 The test function creates the LifeCycle object. It then asks for the
1031 :sat:{CPPCMP} component to be loaded in the \a FactoryServer container:
1032
1033 \code
1034 def test(clt):
1035     """
1036     Test function that creates an instance of :sat:{CPPCMP} component
1037     usage : :sat:{CPPCMP}=test(clt)
1038     """
1039     import LifeCycleCORBA
1040     lcc = LifeCycleCORBA.LifeCycleCORBA(clt.orb)
1041     import :sat:{CPPCMP}_ORB
1042     :sat:{CPPCMP} = lcc.FindOrLoadComponent("FactoryServer", ":sat:{CPPCMP}")
1043     return :sat:{CPPCMP}
1044 \endcode
1045
1046 \ref catalog_def "<< Previous"<br>\ref load_iapp ">> Next"
1047
1048 \page load_iapp Loading from the GUI (IAPP)
1049
1050 In order to activate :sat:{CPPCMP} module in the SALOME GUI desktop, the user
1051 should press the :sat:{CPPCMP} module's button on the \a Modules toolbar or
1052 select the name of the module in the combo box on this toolbar.
1053
1054 The image file to be used as an icon of a module should be exported by
1055 the module build procedure. The icon file name is defined in \c SalomeApp.xml:
1056 \code
1057   <section name=":sat:{CPPCMP}">
1058     <parameter name="name" value=":sat:{CPPCMP}"/>
1059     <parameter name="icon" value=":sat:{CPPCMP}.png"/>
1060   </section>
1061 \endcode
1062
1063 \ref load_lcc "<< Previous"
1064
1065 */