Salome HOME
1c291b784d75f46ebfcfc8d00164b5897a2660ec
[samples/light.git] / src / LIGHTGUI / LIGHTGUI.cxx
1 // Copyright (C) 2005-2022  OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File   : LIGHTGUI.cxx
20 // Author : Julia DOROVSKIKH
21
22 #include "LIGHTGUI.h"
23 #include "LIGHTGUI_DataModel.h"
24 #include "LIGHTGUI_Selection.h"
25 #include "LIGHTGUI_TextPrs.h"
26 #include "LIGHT_version.h"
27
28 #include <LightApp_Application.h>
29 #include <LightApp_DataOwner.h>
30 #include <LightApp_SelectionMgr.h>
31 #include <OCCViewer_ViewManager.h>
32 #include <SUIT_Desktop.h>
33 #include <SUIT_MessageBox.h>
34 #include <SOCC_Prs.h>
35 #include <SOCC_ViewModel.h>
36
37 #include <QIcon>
38 #include <QInputDialog>
39 #include <QStringList>
40
41 /*!
42   \class LIGHTGUI
43   \brief Implementation of the sample light (no-CORBA-engine) SALOME module.
44
45   This class represents a GUI module itself; the instance of the class is
46   created and exported by the static function, which is automatically invoked
47   from SALOME GUI; SALOME GUI application loads the module when user activates
48   it via the "Components" toolbar.
49   
50   The LIGHTGUI class is responsible for the creation of the data model.
51   It dispatches user actions to the corresponding slots.
52
53   Method engineIOR() of this class returns empty string which means that this 
54   module uses default persistence mechanism provided by the SALOME GUI via
55   the SalomeApp embedded engine (SalomeAppEngine class).
56 */
57
58 /*!
59   \brief Constructor. Sets the default name for the module.
60 */
61 LIGHTGUI::LIGHTGUI()
62   : LightApp_Module( "LIGHTGUI" )
63 {
64 }
65
66 /*!
67   \brief Destructor.
68 */
69 LIGHTGUI::~LIGHTGUI()
70 {
71 }
72
73 /*!
74   \brief Initialize module. Creates menus, prepares context menu, etc.
75   \param app application instance
76 */
77 void LIGHTGUI::initialize( CAM_Application* app )
78 {
79   LightApp_Module::initialize( app );
80
81   SUIT_Desktop* desk = application()->desktop();
82
83   createAction( lgLoadFile, tr( "TOP_LOAD_FILE" ), QIcon(), tr( "MEN_LOAD_FILE" ),
84                 tr( "STB_LOAD_FILE" ), 0, desk, false, this, SLOT( onLoadFile() ) );
85   createAction( lgDisplayLine, tr( "TOP_DISPLAY_LINE" ), QIcon(), tr( "MEN_DISPLAY_LINE" ),
86                 tr( "STB_DISPLAY_LINE" ), 0, desk, false, this, SLOT( onDisplayLine() ) );
87   createAction( lgEraseLine, tr( "TOP_ERASE_LINE" ), QIcon(), tr( "MEN_ERASE_LINE" ),
88                 tr( "STB_ERASE_LINE" ), 0, desk, false, this, SLOT( onEraseLine() ) );
89   createAction( lgSaveFile, tr( "TOP_SAVE_FILE" ), QIcon(), tr( "MEN_SAVE_FILE" ),
90                 tr( "STB_SAVE_FILE" ), 0, desk, false, this, SLOT( onSaveFile() ) );
91   createAction( lgEditLine, tr( "TOP_EDIT_LINE" ), QIcon(), tr( "MEN_EDIT_LINE" ),
92                 tr( "STB_EDIT_LINE" ), 0, desk, false, this, SLOT( onEditLine() ) );
93   createAction( lgAddLine,  tr( "TOP_ADD_LINE" ),  QIcon(), tr( "MEN_ADD_LINE" ),
94                 tr( "STB_ADD_LINE" ),  0, desk, false, this, SLOT( onAddLine() ) );
95   createAction( lgDelLine,  tr( "TOP_DEL_LINE" ),  QIcon(), tr( "MEN_DEL_LINE" ),
96                 tr( "STB_DEL_LINE" ),  0, desk, false, this, SLOT( onDelLine() ) );
97   createAction( lgClear,    tr( "TOP_CLEAR_ALL" ), QIcon(), tr( "MEN_CLEAR_ALL" ),
98                 tr( "STB_CLEAR_ALL" ), 0, desk, false, this, SLOT( onClear() ) );
99
100   int aFileMnu = createMenu( tr( "MEN_FILE" ), -1, -1 );
101   createMenu( separator(), aFileMnu, -1, 10 );
102   createMenu( lgLoadFile,  aFileMnu, 10 );
103   createMenu( lgSaveFile,  aFileMnu, 10 );
104
105   int aLightMnu = createMenu( tr( "MEN_LIGHT" ), -1, -1, 50 );
106   createMenu( lgAddLine,      aLightMnu, 10 );
107   createMenu( lgEditLine,     aLightMnu, 10 );
108   createMenu( lgDelLine,      aLightMnu, 10 );
109   createMenu( separator(),    aLightMnu, -1, 10 );
110   createMenu( lgClear,        aLightMnu, 10 );
111
112   QString rule = "(client='ObjectBrowser' or client='OCCViewer') and selcount=1 and type='TextLine' and !empty";
113
114   popupMgr()->insert ( action( lgDisplayLine ), -1, 0 );
115   popupMgr()->setRule( action( lgDisplayLine ), rule + " and !visible"  );
116
117   popupMgr()->insert ( action( lgEraseLine ), -1, 0 );
118   popupMgr()->setRule( action( lgEraseLine ), rule + " and activeView='OCCViewer' and visible"  );
119
120   rule = "client='ObjectBrowser' and selcount=1 and type='TextLine'";
121
122   popupMgr()->insert ( action( lgEditLine ), -1, 0 );
123   popupMgr()->setRule( action( lgEditLine ), rule  );
124
125   popupMgr()->insert ( action( lgAddLine ),  -1, 0 );
126   popupMgr()->setRule( action( lgAddLine ),  rule );
127
128   popupMgr()->insert ( separator(),          -1, 0 );
129
130   popupMgr()->insert ( action( lgDelLine ),  -1, 0 );
131   popupMgr()->setRule( action( lgDelLine ),  rule );
132
133   rule = "client='ObjectBrowser'";
134
135   popupMgr()->insert ( action( lgClear ),    -1, 0 );
136   popupMgr()->setRule( action( lgClear ),    rule );
137 }
138
139 /*!
140   \brief Get list of compliant dockable GUI elements
141   \param m map to be filled in ("type":"default_position")
142 */
143 void LIGHTGUI::windows( QMap<int, int>& m ) const
144 {
145   m.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
146 #ifndef DISABLE_PYCONSOLE
147   m.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
148 #endif
149 }
150
151 /*!
152   \brief Create custom popup menu selection object.
153   \return new selected object
154 */
155 LightApp_Selection* LIGHTGUI::createSelection() const
156 {
157   return new LIGHTGUI_Selection();
158 }
159
160 /*!
161   \brief Create data model.
162   \return module specific data model
163 */
164 CAM_DataModel* LIGHTGUI::createDataModel()
165 {
166   return new LIGHTGUI_DataModel( this );
167 }
168
169 /*!
170   \brief Get the identifier of the currently selected object.
171   \return ID of the currently selected line or -1 if not appropriate
172   object (or multiple objects) is selected.
173 */
174 int LIGHTGUI::selectedLine()
175 {
176   int id = -1; // bad value
177   
178   // Look for selected lines
179   LightApp_Application* app = getApp();
180   LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : 0;
181   if ( mgr ) {
182     SUIT_DataOwnerPtrList anOwnersList;
183     mgr->selected( anOwnersList );
184     
185     // Get index of the single selected line
186     if ( anOwnersList.size() == 1 ) {
187       const LightApp_DataOwner* owner =
188         dynamic_cast<const LightApp_DataOwner*>( anOwnersList[0].get() );
189       QString anEntry = owner->entry();
190       id = LIGHTGUI_DataModel::id( anEntry );
191     }
192   }
193   return id;
194 }
195
196 /*!
197   \brief Display the object with the specified identifier.
198   \param id object ID
199   \param allViewers if \c true the object is displayed in all existing viewers
200   (OCC viewers are supported only)
201   \param upd if \c true, update the viewer(s)
202 */
203 void LIGHTGUI::displayLine( const int id, const bool allViewers, const bool upd )
204 {
205   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
206   if ( dm && id > 0 ) {
207     ViewManagerList viewers;
208     if ( allViewers )
209       getApp()->viewManagers( "OCCViewer", viewers );
210     else
211       viewers.append( getApp()->getViewManager( "OCCViewer", true ) );
212     
213     for ( ViewManagerList::iterator it = viewers.begin(); it != viewers.end(); ++it ) {
214       OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( *it );
215       if ( !aMgr ) continue;
216       SOCC_Viewer* aViewer = (SOCC_Viewer*)aMgr->getViewModel();  
217       if ( !aViewer ) continue;
218       QString aLine = dm->getLineText( id );
219       QString entry = LIGHTGUI_DataModel::entry( id );
220       SOCC_Prs* prs = dynamic_cast<SOCC_Prs*>( aViewer->CreatePrs( entry.toLatin1() ) );
221       if ( prs ) {
222         double aX = 0, aY = dm->lineNb( id ) * LIGHTGUI_TextPrs::TextSize(), aZ = 0;
223         aViewer->Erase( prs, true );
224         Handle(LIGHTGUI_TextPrs) aPrs = new LIGHTGUI_TextPrs( aLine.toLatin1(), gp_Pnt( aX, aY, aZ ) );
225         aPrs->SetOwner( new SALOME_InteractiveObject( entry.toLatin1(), "" ) );
226         prs->Clear();
227         prs->AddObject( aPrs );
228         aViewer->Display( prs );
229         if ( upd )
230           aViewer->Repaint();
231       }
232     }
233   }
234 }
235
236 /*!
237   \brief Erase the object with the specified identifier.
238   \param id object ID
239   \param allViewers if \c true the object is erased in all existing viewers
240   (OCC viewers are supported only)
241   \param upd if \c true, update the viewer(s)
242 */
243 void LIGHTGUI::eraseLine( const int id, const bool allViewers, const bool upd )
244 {
245   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
246   if ( dm && id > 0 ) {
247     ViewManagerList viewers;
248     if ( allViewers )
249       getApp()->viewManagers( "OCCViewer", viewers );
250     else
251       viewers.append( getApp()->getViewManager( "OCCViewer", true ) );
252     
253     for ( ViewManagerList::iterator it = viewers.begin(); it != viewers.end(); ++it ) {
254       OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( *it );
255       if ( !aMgr ) continue;
256       SOCC_Viewer* aViewer = (SOCC_Viewer*)aMgr->getViewModel();  
257       if ( !aViewer ) continue;
258       QString entry = LIGHTGUI_DataModel::entry( id );
259       SOCC_Prs* prs = dynamic_cast<SOCC_Prs*>( aViewer->CreatePrs( entry.toLatin1() ) );
260       if ( prs ) {
261         aViewer->Erase( prs, false );
262         if ( upd )
263           aViewer->Repaint();
264       }
265     }
266   }
267 }
268
269 /*!
270   \brief Update the object presentation.
271   \param id object ID
272   \param allViewers if \c true the object is updated in all existing viewers
273   (OCC viewers are supported only)
274   \param upd if \c true, update the viewer(s)
275 */
276 void LIGHTGUI::updateLine( const int id, const bool allViewers, const bool upd )
277 {
278   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
279   if ( dm && id > 0 ) {
280     ViewManagerList viewers;
281     if ( allViewers )
282       getApp()->viewManagers( "OCCViewer", viewers );
283     else
284       viewers.append( getApp()->getViewManager( "OCCViewer", true ) );
285     
286     for ( ViewManagerList::iterator it = viewers.begin(); it != viewers.end(); ++it ) {
287       OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( *it );
288       if ( !aMgr ) continue;
289       SOCC_Viewer* aViewer = (SOCC_Viewer*)aMgr->getViewModel();  
290       if ( !aViewer ) continue;
291       QString aLine = dm->getLineText( id );
292       QString entry = LIGHTGUI_DataModel::entry( id );
293       if ( aViewer->isVisible( new SALOME_InteractiveObject( entry.toLatin1(), "" ) ) ) {
294         SOCC_Prs* prs = dynamic_cast<SOCC_Prs*>( aViewer->CreatePrs( entry.toLatin1() ) );
295         if ( prs ) {
296           if ( aLine.isEmpty() ) {
297             aViewer->Erase( prs, false );
298           }
299           else {
300             double aX = 0, aY = dm->lineNb( id ) * LIGHTGUI_TextPrs::TextSize(), aZ = 0;
301             aViewer->Erase( prs, true );
302             Handle(LIGHTGUI_TextPrs) aPrs = new LIGHTGUI_TextPrs( aLine.toLatin1(), gp_Pnt( aX, aY, aZ ) );
303             aPrs->SetOwner( new SALOME_InteractiveObject( entry.toLatin1(), "" ) );
304             prs->Clear();
305             prs->AddObject( aPrs );
306             aViewer->Display( prs );
307           }
308           if ( upd )
309             aViewer->Repaint();
310         }
311       }
312     }
313   }
314 }
315
316 /*!
317   \brief Erase objects.
318   \param l objects IDs list
319   \param allViewers if \c true the objects are erased in all existing viewers
320   (OCC viewers are supported only)
321 */
322 void LIGHTGUI::eraseLines( const QList<int>& l, const bool allViewers )
323 {
324   for ( QList<int>::const_iterator it = l.begin(); it != l.end(); ++it )
325     eraseLine( *it, allViewers );
326 }
327
328 /*!
329   \brief Update objects presentations.
330   \param l objects IDs list
331   \param allViewers if \c true the objects are updated in all existing viewers
332   (OCC viewers are supported only)
333 */
334 void LIGHTGUI::updateLines( const QList<int>& l, const bool allViewers )
335 {
336   for ( QList<int>::const_iterator it = l.begin(); it != l.end(); ++it )
337     updateLine( *it, allViewers );
338 }
339
340 /*!
341   \brief Activate module.
342   \param study current study
343   \return \c true if activaion is done successfully or 0 to prevent
344   activation on error
345 */
346 bool LIGHTGUI::activateModule( SUIT_Study* study )
347 {
348   bool isDone = LightApp_Module::activateModule( study );
349   if ( !isDone ) return false;
350
351   setMenuShown( true );
352
353   return isDone;
354 }
355
356 /*!
357   \brief Deactivate module.
358   \param study current study
359   \return \c true if deactivaion is done successfully or 0 to prevent
360   deactivation on error
361 */
362 bool LIGHTGUI::deactivateModule( SUIT_Study* study )
363 {
364   // hide menus
365   setMenuShown( false );
366
367   return LightApp_Module::deactivateModule( study );
368 }
369
370 /*!
371   \brief Called when "load text file" action is activated.
372 */
373 void LIGHTGUI::onLoadFile()
374 {
375   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
376   if ( !dm ) return;
377
378   QStringList filtersList;
379   filtersList.append( tr( "LIGHTGUI_MEN_TXT_FILES" ) );
380   filtersList.append( tr( "LIGHTGUI_MEN_ALL_FILES" ) );
381
382   // Select a file to be loaded
383   QString aFileName = getApp()->getFileName( true, QString(), filtersList.join( ";;" ), tr( "LIGHTGUI_MEN_LOAD" ), 0 );
384   if ( !aFileName.isEmpty() ) {
385     // Load the file
386     QList<int> l = dm->getIds();
387     if ( dm->loadFile( aFileName ) ) {
388       eraseLines( l, true );
389       updateObjBrowser( true );
390     } 
391     else {
392       SUIT_MessageBox::warning ( application()->desktop(),
393                                  tr( "WRN_WARNING" ),
394                                  tr( "WRN_LOAD_FAILED" ) );
395       }
396   }
397 }
398
399 /*!
400   \brief Called when "save text file" action is activated.
401 */
402 void LIGHTGUI::onSaveFile()
403 {
404   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
405   if ( !dm ) return;
406
407   QStringList filtersList;
408   filtersList.append( tr( "LIGHTGUI_MEN_TXT_FILES" ) );
409   filtersList.append( tr( "LIGHTGUI_MEN_ALL_FILES" ) );
410
411   // Select a file name to dump the lines into
412   QString aFileName = getApp()->getFileName( false, dm->fileName(), filtersList.join( ";;" ), tr( "LIGHTGUI_MEN_DUMP" ), 0 );
413   if ( !aFileName.isEmpty() ) {
414     // Dump the file
415     if ( !dm->dumpFile( aFileName ) ) {
416       SUIT_MessageBox::warning ( application()->desktop(),
417                                  tr( "WRN_WARNING" ),
418                                  tr( "WRN_DUMP_FAILED" ) );
419       }
420   }
421 }
422
423 /*!
424   \brief Called when "display selected line" action is activated.
425 */
426 void LIGHTGUI::onDisplayLine()
427 {
428   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
429   if ( !dm ) return;
430
431   // Define position
432   int id = selectedLine();
433   QString aLine = dm->getLineText( id );
434   
435   // Check, that position is defined
436   if ( id == -1 || aLine.isEmpty() ) {
437     SUIT_MessageBox::warning ( application()->desktop(),
438                                tr( "WRN_WARNING" ),
439                                tr( "WRN_SELECT_LINE" ) );
440     return;
441   }
442   displayLine( id );
443 }
444
445 /*!
446   \brief Called when "erase selected line" action is activated.
447 */
448 void LIGHTGUI::onEraseLine()
449 {
450   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
451   if ( !dm ) return;
452
453   // Define position
454   int id = selectedLine();
455   QString aLine = dm->getLineText( id );
456   
457   // Check, that position is defined
458   if ( id == -1 || aLine.isEmpty() ) {
459     SUIT_MessageBox::warning ( application()->desktop(),
460                                tr( "WRN_WARNING" ),
461                                tr( "WRN_SELECT_LINE" ) );
462     return;
463   }
464   eraseLine( id );
465 }
466
467 /*!
468   \brief Called when "edit selected line" action is activated.
469 */
470 void LIGHTGUI::onEditLine()
471 {
472   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
473   if ( !dm ) return;
474
475   // Define position
476   int id = selectedLine();
477   
478   // Check, that position is defined
479   if ( id == -1 ) {
480     SUIT_MessageBox::warning ( application()->desktop(),
481                                tr( "WRN_WARNING" ),
482                                tr( "WRN_SELECT_LINE" ) );
483     return;
484   }
485
486   // Get new text
487   bool isOk;
488   QString aText = QInputDialog::getText( application()->desktop(),
489                                          tr( "LIGHTGUI_EDIT_LINE" ),
490                                          QString(),
491                                          QLineEdit::Normal,
492                                          dm->getLineText( id ),
493                                          &isOk );
494   if ( !isOk ) return;
495   
496   // try to change a text of the selected line
497   
498   isOk = dm->setLineText( id, aText );
499
500   if ( isOk ) {
501     updateLine( id, true );
502     updateObjBrowser( true );
503   } 
504   else {
505     SUIT_MessageBox::warning ( application()->desktop(),
506                                tr( "WRN_WARNING" ),
507                                tr( "WRN_EDIT_FAILED" ) );
508   }
509 }
510
511 /*!
512   \brief Called when "insert new line" action is activated.
513 */
514 void LIGHTGUI::onAddLine()
515 {
516   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
517   if ( !dm ) return;
518
519   // Define position
520   int id = selectedLine();
521   
522   // Get new text
523   bool isOk;
524   QString aText = QInputDialog::getText( getApp()->desktop(),
525                                          tr( "LIGHTGUI_ADD_LINE" ),
526                                          QString(),
527                                          QLineEdit::Normal,
528                                          QString(),
529                                          &isOk );
530   if ( !isOk ) return;
531
532   QList<int> l = dm->getIds();
533
534   // try to insert/add text line
535   isOk = dm->insertLineBefore( id, aText );
536
537   if ( isOk ) {
538     updateLines( l, true );
539     updateObjBrowser( true );
540   } 
541   else {
542     SUIT_MessageBox::warning ( application()->desktop(),
543                                tr( "WRN_WARNING" ),
544                                tr( "WRN_ADD_FAILED" ) );
545   }
546 }
547
548 /*!
549   \brief Called when "delete selected line" action is activated.
550 */
551 void LIGHTGUI::onDelLine()
552 {
553   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
554   if ( !dm ) return;
555
556   // Define position
557   int id = selectedLine();
558   
559   // Check, that position is defined
560   if ( id == -1 ) {
561     SUIT_MessageBox::warning ( application()->desktop(),
562                                tr( "WRN_WARNING" ),
563                                tr( "WRN_SELECT_LINE" ) );
564     return;
565   }
566
567   QList<int> l = dm->getIds();
568
569   // try to delete line
570   bool isOk = dm->deleteTextLine( id );
571   if ( isOk ) {
572     updateLines( l, true );
573     updateObjBrowser( true );
574   } 
575   else {
576     SUIT_MessageBox::warning ( application()->desktop(),
577                                tr( "WRN_WARNING" ),
578                                tr( "WRN_DELETE_FAILED" ) );
579   }
580 }
581
582 /*!
583   \brief Called when "clear all contents" action is activated.
584 */
585 void LIGHTGUI::onClear()
586 {
587   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
588   if ( !dm ) return;
589
590   QList<int> l = dm->getIds();
591   eraseLines( l, true );
592
593   dm->clearAll();
594
595   updateObjBrowser( true );
596 }
597
598 /*!
599   \brief Check if this object is can't be renamed in place
600
601   This method can be re-implemented in the subclasses.
602   Return true in case if object isn't reference or component (module root).
603
604   \param entry column id
605   \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
606 */
607 bool LIGHTGUI::renameAllowed( const QString& entry ) const
608 {
609   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
610   return dm && dm->lineNb( entry ) >= 0;
611 }
612
613 /*!
614   Rename object by entry.
615   \param entry entry of the object
616   \param name new name of the object
617   \brief Return \c true if rename operation finished successfully, \c false otherwise.
618 */
619 bool LIGHTGUI::renameObject( const QString& entry, const QString& name )
620 {
621   bool result = false;
622
623   LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
624   if ( dm && dm->lineNb( entry ) ) {
625     int id = LIGHTGUI_DataModel::id( entry );
626     result = dm->setLineText( id, name );
627     if ( result ) {
628       updateLine( id, true );
629       updateObjBrowser( true );
630     }
631   }
632   return result;
633 }
634
635 /*!
636   \fn CAM_Module* createModule();
637   \brief Export module instance (factory function).
638   \return new created instance of the module
639 */
640
641 /*!
642   \fn char* getModuleVersion();
643   \brief Get version of this module.
644   \return version information
645 */
646
647 extern "C" {
648   LIGHT_EXPORT CAM_Module* createModule() {
649     return new LIGHTGUI();
650   }
651   
652   LIGHT_EXPORT char* getModuleVersion() {
653     return (char*)LIGHT_VERSION_STR;
654   }
655 }