+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAF_H
-#define CAF_H
-
-#if defined CAF_EXPORTS
-#if defined WNT
-#define CAF_EXPORT __declspec( dllexport )
-#else
-#define CAF_EXPORT
-#endif
-#else
-#if defined WNT
-#define CAF_EXPORT __declspec( dllimport )
-#else
-#define CAF_EXPORT
-#endif
-#endif
-
-#if defined SOLARIS
-#define bool int
-#define false 0
-#define true 1
-#endif
-
-#if defined WNT
-#pragma warning ( disable: 4251 )
-#endif
-
-#if defined ( _DEBUG ) || defined ( DEBUG )
-#include <assert.h>
-#define CAF_VERIFY(x) assert(x);
-#define CAF_ASSERT(x) assert(x);
-#else
-#define CAF_VERIFY(x) x
-#define CAF_ASSERT(x)
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAF_Application.h"
-
-#include "CAF_Tools.h"
-#include "CAF_Study.h"
-
-#include <SUIT_Desktop.h>
-#include <SUIT_Session.h>
-#include <SUIT_ViewModel.h>
-#include <SUIT_Operation.h>
-#include <SUIT_MessageBox.h>
-#include <SUIT_ResourceMgr.h>
-
-#include <QtxListAction.h>
-
-#include <qtoolbar.h>
-#include <qmenubar.h>
-#include <qpopupmenu.h>
-#include <qstatusbar.h>
-#include <qapplication.h>
-
-#include <Resource_Manager.hxx>
-
-#include <TColStd_SequenceOfExtendedString.hxx>
-
-extern "C" CAF_EXPORT SUIT_Application* createApplication()
-{
- return new CAF_Application();
-}
-
-/*!
- Default constructor
-*/
-CAF_Application::CAF_Application()
-: STD_Application()
-{
-}
-
-/*!
- Constructor with OCAF application
- \param app - OCAF application
-*/
-CAF_Application::CAF_Application( const Handle( TDocStd_Application )& app )
-: STD_Application(),
-myStdApp( app )
-{
-}
-
-/*!
- Destructor
-*/
-CAF_Application::~CAF_Application()
-{
-}
-
-/*!
- \return application name
-*/
-QString CAF_Application::applicationName() const
-{
- return QString( "CAFApplication" );
-}
-
-/*!
- \return OCAF application
-*/
-Handle( TDocStd_Application ) CAF_Application::stdApp() const
-{
- return myStdApp;
-}
-
-/*!
- \return file filters for open/save document
-*/
-QString CAF_Application::getFileFilter() const
-{
- if ( stdApp().IsNull() )
- return QString::null;
-
- TColStd_SequenceOfExtendedString formats;
- stdApp()->Formats( formats );
-
- QStringList allWC;
- QMap<QString, QStringList> wildCards;
- Handle(Resource_Manager) resMgr = new Resource_Manager( stdApp()->ResourcesName() );
- for ( int i = 1; i <= formats.Length(); i++ )
- {
- QString extension;
- QString extResStr = CAF_Tools::toQString( formats.Value( i ) ) + QString( ".FileExtension" );
- if ( resMgr->Find( (char*)extResStr.latin1() ) )
- extension = QString( resMgr->Value( (char*)extResStr.latin1() ) );
-
- QString descr;
- QString descrResStr = CAF_Tools::toQString( formats.Value( i ) ) + QString( ".Description" );
- if ( resMgr->Find( (char*)descrResStr.latin1() ) )
- descr = QString( resMgr->Value( (char*)descrResStr.latin1() ) );
-
- if ( !descr.isEmpty() && !extension.isEmpty() )
- {
- if ( !wildCards.contains( descr ) )
- wildCards.insert( descr, QStringList() );
- wildCards[descr].append( QString( "*.%1" ).arg( extension ) );
- allWC.append( QString( "*.%1" ).arg( extension ) );
- }
- }
-
- if ( wildCards.isEmpty() )
- return QString::null;
-
- QStringList filters;
- for ( QMap<QString, QStringList>::ConstIterator it = wildCards.begin(); it != wildCards.end(); ++it )
- filters.append( QString( "%1 (%2)" ).arg( it.key() ).arg( it.data().join( "; " ) ) );
-
- if ( wildCards.count() > 1 )
- filters.prepend( QString( "%1 (%2)" ).arg( tr( "INF_ALL_DOCUMENTS_FILTER" ) ).arg( allWC.join( "; " ) ) );
-
- if ( !filters.isEmpty() )
- filters.append( tr( "INF_ALL_FILTER" ) );
-
- return filters.join( ";;" );
-}
-
-/*!
- Creates actions of application
-*/
-void CAF_Application::createActions()
-{
- STD_Application::createActions();
-
- SUIT_Desktop* desk = desktop();
- SUIT_ResourceMgr* resMgr = resourceMgr();
-
- QtxListAction* editUndo =
- new QtxListAction( tr( "TOT_APP_EDIT_UNDO" ), resMgr->loadPixmap( "CAF", tr( "ICON_APP_EDIT_UNDO" ) ),
- tr( "MEN_APP_EDIT_UNDO" ), CTRL+Key_Z, desk );
- registerAction( EditUndoId, editUndo );
-
- QtxListAction* editRedo =
- new QtxListAction( tr( "TOT_APP_EDIT_REDO" ), resMgr->loadPixmap( "CAF", tr( "ICON_APP_EDIT_REDO" ) ),
- tr( "MEN_APP_EDIT_REDO" ), CTRL+Key_Y, desk );
- registerAction( EditRedoId, editRedo );
-
- editUndo->setComment( tr( "INF_APP_UNDOACTIONS" ) );
- editRedo->setComment( tr( "INF_APP_REDOACTIONS" ) );
-
- connect( editUndo, SIGNAL( activated( int ) ), this, SLOT( onUndo( int ) ) );
- connect( editRedo, SIGNAL( activated( int ) ), this, SLOT( onRedo( int ) ) );
-
-
- int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 10 );
-
- createMenu( EditUndoId, editMenu, 0 );
- createMenu( EditRedoId, editMenu, 0 );
- createMenu( separator(), editMenu, -1, 0 );
-
- int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ) );
-
- createTool( separator(), stdTBar );
- createTool( EditUndoId, stdTBar );
- createTool( EditRedoId, stdTBar );
- createTool( separator(), stdTBar );
-}
-
-/*!
- Undo operation on the given document. [ virtual protected ]
-*/
-bool CAF_Application::undo( CAF_Study* doc )
-{
- bool success = false;
- if ( doc )
- {
- if ( success = doc->undo() )
- doc->update();
- }
- return success;
-}
-
-/*!
- Redo operation on the given document. [ virtual protected ]
-*/
-bool CAF_Application::redo(CAF_Study* doc)
-{
- bool success = false;
- if ( doc )
- {
- if ( success = doc->redo() )
- doc->update();
- }
- return success;
-}
-
-/*!
- Undo operation on the active document. [ virtual protected slot ]
-*/
-bool CAF_Application::onUndo( int numActions )
-{
- bool ok = true;
- while ( numActions > 0 )
- {
- CAF_Study* cafStudy = dynamic_cast<CAF_Study*>( activeStudy() );
- if ( cafStudy )
- {
- if ( !undo( cafStudy ) )
- {
- ok = false;
- break;
- }
- numActions--;
- }
- }
- updateCommandsStatus(); /* enable/disable undo/redo */
- return ok;
-}
-
-/*!
- Redo operation on the active document. [ virtual protected slot ]
-*/
-bool CAF_Application::onRedo( int numActions )
-{
- bool ok = true;
- while ( numActions > 0 )
- {
- CAF_Study* cafStudy = dynamic_cast<CAF_Study*>( activeStudy() );
- if ( cafStudy )
- {
- if ( !redo( cafStudy ) )
- {
- ok = false;
- break;
- }
- numActions--;
- }
- }
- updateCommandsStatus(); /* enable/disable undo/redo */
- return ok;
-}
-
-/*!
- Enables / disables the actions according to the application state. [ virtual protected ]
-*/
-void CAF_Application::updateCommandsStatus()
-{
- STD_Application::updateCommandsStatus();
-
- CAF_Study* cafStudy = 0;
- if ( activeStudy() && activeStudy()->inherits( "CAF_Study" ) )
- cafStudy = (CAF_Study*)activeStudy();
-
- QAction* undo = action( EditUndoId );
- if ( cafStudy && undo )
- undo->setProperty( "names", cafStudy->undoNames() );
-
- QAction* redo = action( EditRedoId );
- if ( cafStudy && redo )
- redo->setProperty( "names", cafStudy->redoNames() );
-
- if ( undo )
- undo->setEnabled( cafStudy && cafStudy->canUndo() );
- if ( redo )
- redo->setEnabled( cafStudy && cafStudy->canRedo() );
-}
-
-/*!
- SLOT: called by clicking on Help->About in main menu
-*/
-void CAF_Application::onHelpAbout()
-{
- SUIT_MessageBox::info1( desktop(), tr( "About" ), tr( "ABOUT_INFO" ), "&OK" );
-}
-
-/*!
- Creates new study
-*/
-SUIT_Study* CAF_Application::createNewStudy()
-{
- return new CAF_Study( this );
-}
-
-/*!
- Sets OCAF application
-*/
-void CAF_Application::setStdApp( const Handle(TDocStd_Application)& app )
-{
- myStdApp = app;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAF_APPLICATION_H
-#define CAF_APPLICATION_H
-
-#include "CAF.h"
-
-#include "STD_Application.h"
-
-#include <qmap.h>
-#include <qptrlist.h>
-
-#include <TDocStd_Application.hxx>
-
-class QtxAction;
-class CAF_Study;
-
-#if defined WIN32
-#pragma warning ( disable: 4251 )
-#endif
-
-/*!
- \class CAF_Application
- Defines application configuration and behaviour for application with
- link to standard OCC OCAF data model. Allows to use OCC OCAF serives
- (for example, undo/redo)
-*/
-class CAF_EXPORT CAF_Application : public STD_Application
-{
- Q_OBJECT
-
-public:
- CAF_Application();
- CAF_Application( const Handle(TDocStd_Application)& );
- virtual ~CAF_Application();
-
- virtual QString applicationName() const;
-
- Handle(TDocStd_Application) stdApp() const;
-
- virtual QString getFileFilter() const;
-
-public slots:
- virtual void onHelpAbout();
-
-protected slots:
- virtual bool onUndo( int );
- virtual bool onRedo( int );
-
-protected:
- enum { EditUndoId = STD_Application::UserID, EditRedoId, UserID };
-
-protected:
- virtual void createActions();
- virtual void updateCommandsStatus();
-
- virtual SUIT_Study* createNewStudy();
-
- bool undo( CAF_Study* doc );
- bool redo( CAF_Study* doc );
-
- virtual void setStdApp( const Handle(TDocStd_Application)& );
-
-private:
- Handle(TDocStd_Application) myStdApp;
-};
-
-#if defined WIN32
-#pragma warning ( default: 4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAF_Operation.h"
-
-#include "CAF_Study.h"
-#include "CAF_Application.h"
-
-#include <TDocStd_Document.hxx>
-
-/*!
- Default constructor
-*/
-CAF_Operation::CAF_Operation(SUIT_Application* theApp)
-:SUIT_Operation(theApp)
-{
-}
-
-/*!
- Destructor
-*/
-CAF_Operation::~CAF_Operation()
-{
-}
-
-/*!
- \return OCAF document
-*/
-Handle(TDocStd_Document) CAF_Operation::stdDoc() const
-{
- Handle(TDocStd_Document) doc;
- CAF_Study* s = ::qt_cast<CAF_Study*>( study() );
- if ( s )
- doc = s->stdDoc();
- return doc;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAF_OPERATION_H
-#define CAF_OPERATION_H
-
-#include "CAF.h"
-
-#include "SUIT_Operation.h"
-
-#include <qobject.h>
-#include <qstring.h>
-
-#include <Standard.hxx>
-
-class CAF_Study;
-//! OCC OCAF Std document
-class Handle(TDocStd_Document);
-
-/*!
- \class CAF_Operation
- Base operation for all operations used in CAF package
- Operation has link to OCC OCAF std document
-*/
-class CAF_EXPORT CAF_Operation : public SUIT_Operation
-{
- Q_OBJECT
-
-public:
- CAF_Operation( SUIT_Application* );
- virtual ~CAF_Operation();
-
-protected:
- Handle(TDocStd_Document) stdDoc() const;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAF_Study.h"
-
-#include "CAF_Tools.h"
-#include "CAF_Operation.h"
-#include "CAF_Application.h"
-
-#include <SUIT_Desktop.h>
-#include <SUIT_MessageBox.h>
-#include <SUIT_Application.h>
-
-#include <qdir.h>
-
-#include <TDF_Delta.hxx>
-#include <TDF_ListIteratorOfDeltaList.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
-
-/*!
- Constructor
-*/
-CAF_Study::CAF_Study(SUIT_Application* theApp)
-: SUIT_Study( theApp ),
-myModifiedCnt( 0 )
-{
-}
-
-/*!
- Constructor
-*/
-CAF_Study::CAF_Study(SUIT_Application* theApp, Handle (TDocStd_Document)& aStdDoc)
-: SUIT_Study( theApp ),
-myStdDoc( aStdDoc ),
-myModifiedCnt( 0 )
-{
-}
-
-/*!
- Destructor
-*/
-CAF_Study::~CAF_Study()
-{
-}
-
-/*!
- \return OCAF document
-*/
-Handle(TDocStd_Document) CAF_Study::stdDoc() const
-{
- return myStdDoc;
-}
-
-/*!
- Sets new OCAF document
- \param aStdDoc - new OCAF document
-*/
-void CAF_Study::setStdDoc( Handle(TDocStd_Document)& aStdDoc )
-{
- myStdDoc = aStdDoc;
-}
-
-/*!
- Custom document initialization
-*/
-void CAF_Study::createDocument()
-{
- SUIT_Study::createDocument();
-
- CAF_Application* app = cafApplication();
- if ( app && !app->stdApp().IsNull() )
- {
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- TColStd_SequenceOfExtendedString formats;
- app->stdApp()->Formats( formats );
- if ( !formats.IsEmpty() )
- app->stdApp()->NewDocument( formats.First(), myStdDoc );
- }
- catch ( Standard_Failure ) {
- }
- }
-}
-
-/*!
- Close document
-*/
-void CAF_Study::closeDocument( bool permanent )
-{
- Handle(TDocStd_Application) app = stdApp();
- if ( !app.IsNull() && !stdDoc().IsNull() )
- app->Close( stdDoc() );
-
- SUIT_Study::closeDocument( permanent );
-}
-
-/*!
- Open document
- \param fname - name of file
-*/
-bool CAF_Study::openDocument( const QString& fname )
-{
- Handle(TDocStd_Application) app = stdApp();
- if ( app.IsNull() )
- return false;
-
- bool status = false;
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- status = app->Open( CAF_Tools::toExtString( fname ), myStdDoc ) == CDF_RS_OK;
- }
- catch ( Standard_Failure ) {
- status = false;
- }
-
- return status && SUIT_Study::openDocument( fname );
-}
-
-/*!
- Save document with other name
- \param fname - name of file
-*/
-bool CAF_Study::saveDocumentAs( const QString& fname )
-{
- Handle(TDocStd_Application) app = stdApp();
- if ( app.IsNull() )
- return false;
-
- bool save = false;
- if ( !stdDoc().IsNull() && stdDoc()->IsSaved() )
- {
- QString path = QDir::convertSeparators( CAF_Tools::toQString( stdDoc()->GetPath() ) );
- save = path == QDir::convertSeparators( fname );
- }
-
- bool status = false;
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- if ( save )
- status = app->Save( stdDoc() ) == CDF_SS_OK;
- else
- {
- TCollection_ExtendedString format, path( CAF_Tools::toExtString( fname ) );
- app->Format( path, format );
-
- if ( format.Length() )
- stdDoc()->ChangeStorageFormat( format );
-
- status = app->SaveAs( stdDoc(), path ) == CDF_SS_OK;
- }
- }
- catch ( Standard_Failure ) {
- status = false;
- }
-
- if ( status )
- status = SUIT_Study::saveDocumentAs( fname );
-
- if ( status )
- myModifiedCnt = 0;
-
- return status;
-}
-
-/*!
- Open OCAF transaction
-*/
-bool CAF_Study::openTransaction()
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- bool res = true;
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- if ( myStdDoc->HasOpenCommand() )
- myStdDoc->AbortCommand();
-
- myStdDoc->OpenCommand();
- }
- catch ( Standard_Failure ) {
- res = false;
- }
-
- return res;
-}
-
-/*!
- Abort OCAF transaction
-*/
-bool CAF_Study::abortTransaction()
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- bool res = true;
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- myStdDoc->AbortCommand();
- update();
- }
- catch ( Standard_Failure ) {
- res = false;
- }
- return res;
-}
-
-/*!
- Commit OCAF transaction
-*/
-bool CAF_Study::commitTransaction( const QString& name )
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- bool res = true;
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- myStdDoc->CommitCommand();
-
- if ( canUndo() )
- {
- Handle(TDF_Delta) d = myStdDoc->GetUndos().Last();
- if ( !d.IsNull() )
- d->SetName( CAF_Tools::toExtString( name ) );
- }
- }
- catch ( Standard_Failure ) {
- res = false;
- }
- return res;
-}
-
-/*!
- \return true, if there is opened OCAF transaction
-*/
-bool CAF_Study::hasTransaction() const
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- return myStdDoc->HasOpenCommand();
-}
-
-/*!
- \return whether the document was saved in file. [ public ]
-*/
-bool CAF_Study::isSaved() const
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- return myStdDoc->IsSaved();
-}
-
-/*!
- \return whether the document is modified. [ public ]
-*/
-bool CAF_Study::isModified() const
-{
- if ( myStdDoc.IsNull() )
- return false;
-
-// return myStdDoc->IsModified();
- return myModifiedCnt;
-}
-
-/*!
- Increments modification count. If 'undoable' is 'true', this modification
- can be rolled back by 'undoModified' otherwise the document will be marked
- as 'modiifed' until saved. [ protected ]
-*/
-void CAF_Study::doModified( bool undoable )
-{
- if ( myStdDoc.IsNull() )
- return;
-
- myModifiedCnt++;
-
- /* Assumed that number of available undos / redos is NOT changed dynamically */
- if ( !undoable )
- myModifiedCnt += myStdDoc->GetAvailableUndos();
-}
-
-/*!
- Decrements modification count. [ protected ]
-*/
-void CAF_Study::undoModified()
-{
- myModifiedCnt--;
-}
-
-/*!
- Clears modification count. [ public ]
-*/
-void CAF_Study::clearModified()
-{
- myModifiedCnt = 0;
-}
-
-/*!
- Undoes the last command. [ public ]
-*/
-bool CAF_Study::undo()
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- myStdDoc->Undo();
- undoModified(); /* decrement modification counter */
- }
- catch ( Standard_Failure ) {
- SUIT_MessageBox::error1(application()->desktop(), tr( "ERR_ERROR" ),
- tr( "ERR_DOC_UNDO" ), tr ( "BUT_OK" ));
- return false;
- }
- return true;
-}
-
-/*!
- Redoes the last undo. [ public ]
-*/
-bool CAF_Study::redo()
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- myStdDoc->Redo();
- doModified(); /* increment modification counter */
- }
- catch ( Standard_Failure ) {
- SUIT_MessageBox::error1( application()->desktop(), tr( "ERR_ERROR" ),
- tr( "ERR_DOC_REDO" ), tr ( "BUT_OK" ) );
- return false;
- }
- return true;
-}
-
-/*!
- \return true if possible to perform 'undo' command. [ public ]
-*/
-bool CAF_Study::canUndo() const
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- return myStdDoc->GetAvailableUndos() > 0;
-}
-
-/*!
- \return true if possible to perform 'redo' command. [ public ]
-*/
-bool CAF_Study::canRedo() const
-{
- if ( myStdDoc.IsNull() )
- return false;
-
- return myStdDoc->GetAvailableRedos() > 0;
-}
-
-/*!
- \return the list of names of 'undo' actions available. [ public ]
-*/
-QStringList CAF_Study::undoNames() const
-{
- QStringList names;
- if ( !myStdDoc.IsNull() )
- {
- for ( TDF_ListIteratorOfDeltaList it( myStdDoc->GetUndos() ); it.More(); it.Next() )
- names.prepend( CAF_Tools::toQString( it.Value()->Name() ) );
- }
- return names;
-}
-
-/*!
- \return the list of names of 'redo' actions available. [ public ]
-*/
-QStringList CAF_Study::redoNames() const
-{
- QStringList names;
- if ( !myStdDoc.IsNull() )
- {
- for ( TDF_ListIteratorOfDeltaList it( myStdDoc->GetRedos() ); it.More(); it.Next() )
- names.append( CAF_Tools::toQString( it.Value()->Name() ) );
- }
- return names;
-}
-
-/*!
- \return the standard OCAF application from owner application. [ protected ]
-*/
-Handle(TDocStd_Application) CAF_Study::stdApp() const
-{
- Handle(TDocStd_Application) stdApp;
- CAF_Application* app = cafApplication();
- if ( app )
- stdApp = app->stdApp();
- return stdApp;
-}
-
-/*!
- \return the application casted to type CAF_Application. [ protected ]
-*/
-CAF_Application* CAF_Study::cafApplication() const
-{
- return ::qt_cast<CAF_Application*>( application() );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAF_STUDY_H
-#define CAF_STUDY_H
-
-#include "CAF.h"
-
-#include "SUIT_Study.h"
-
-#include <qobject.h>
-
-#include <TDocStd_Document.hxx>
-#include <TDocStd_Application.hxx>
-
-class CAF_Application;
-
-#if defined WNT
-#pragma warning ( disable: 4251 )
-#endif
-
-/*!
- \class CAF_Study
- Represents study for using in CAF, contains reference
- to OCAF std document and allows to use OCAF services.
- Provides necessary functionality for OCC transactions management.
-*/
-class CAF_EXPORT CAF_Study : public SUIT_Study
-{
- Q_OBJECT
-
-public:
- CAF_Study( SUIT_Application* theApp );
- CAF_Study( SUIT_Application* theApp, Handle(TDocStd_Document)& aStdDoc );
- virtual ~CAF_Study();
-
- virtual void createDocument();
- virtual void closeDocument( bool = true );
- virtual bool openDocument( const QString& );
-
- virtual bool saveDocumentAs( const QString& );
-
- bool isSaved() const;
- bool isModified() const;
- void doModified( bool = true );
- void undoModified();
- void clearModified();
-
- bool undo();
- bool redo();
- bool canUndo() const;
- bool canRedo() const;
- QStringList undoNames() const;
- QStringList redoNames() const;
-
- Handle(TDocStd_Document) stdDoc() const;
-
-protected:
- Handle(TDocStd_Application) stdApp() const;
- CAF_Application* cafApplication() const;
-
- virtual bool openTransaction();
- virtual bool abortTransaction();
- virtual bool hasTransaction() const;
- virtual bool commitTransaction( const QString& = QString::null );
-
- virtual void setStdDoc( Handle(TDocStd_Document)& );
-
-private:
- Handle(TDocStd_Document) myStdDoc;
- int myModifiedCnt;
-
- friend class CAF_Operation;
-};
-
-#if defined WNT
-#pragma warning ( default: 4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : CAF_Tools.cxx
-// Author : UI team
-
-#include "CAF_Tools.h"
-
-#include <string.h>
-#include <TCollection_ExtendedString.hxx>
-
-/*!
- Converts TCollection_ExtendedString 'src' to Qt string. [ static ]
-*/
-QString CAF_Tools::toQString ( const TCollection_ExtendedString& src )
-{
- return QString( (const QChar*)src.ToExtString(), src.Length() );
-}
-
-/*!
- Converts TCollection_AsciiString'src' to Qt string. [ static ]
-*/
-QString CAF_Tools::toQString( const TCollection_AsciiString& src )
-{
- return QString( src.ToCString() );
-}
-
-/*!
- Converts Qt string to TCollection_AsciiString. [ static ]
-*/
-TCollection_AsciiString CAF_Tools::toAsciiString( const QString& src )
-{
- TCollection_AsciiString res;
- if ( !src.isEmpty() )
- res = TCollection_AsciiString( (char*)src.latin1() );
- return res;
-}
-
-/*!
- Converts Qt string to TCollection_ExtendedString. [ static ]
-*/
-TCollection_ExtendedString CAF_Tools::toExtString ( const QString& src )
-{
- TCollection_ExtendedString result;
- for ( int i = 0; i < (int)src.length(); i++ )
- result.Insert( i + 1, src[ i ].unicode() );
- return result;
-}
-
-/*!
- Converts Qt color to OCC color
-*/
-Quantity_Color CAF_Tools::color( const QColor& c )
-{
- Quantity_Color aColor;
- if ( c.isValid() )
- aColor = Quantity_Color( c.red() / 255., c.green() / 255.,
- c.blue() / 255., Quantity_TOC_RGB );
- return aColor;
-}
-
-/*!
- Converts OCC color to Qt color
-*/
-QColor CAF_Tools::color( const Quantity_Color& c )
-{
- return QColor ( int( c.Red() * 255 ),
- int( c.Green() * 255 ),
- int( c.Blue() * 255 ) );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : CAF_Tools.h
-// Author : UI team
-
-#ifndef CAF_TOOLS_H
-#define CAF_TOOLS_H
-
-#include <CAF.h>
-
-#include <SUIT_Tools.h>
-
-#include <qcolor.h>
-
-#include <Quantity_Color.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-
-/*!
- \class CAF_Tools
- Prodives set of auxiliary static methods
-*/
-class CAF_EXPORT CAF_Tools : public SUIT_Tools
-{
-public:
- static QString toQString( const TCollection_AsciiString& );
- static QString toQString( const TCollection_ExtendedString& );
-
- static TCollection_ExtendedString toExtString( const QString& );
- static TCollection_AsciiString toAsciiString( const QString& );
-
- static Quantity_Color color( const QColor& );
- static QColor color( const Quantity_Color& );
-};
-
-#endif
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# File : Makefile.in
-# Author : Vladimir Klyachin (OCN)
-# Module : caf
-# $Header$
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@srcdir@/resources
-
-
-@COMMENCE@
-
-# header files
-EXPORT_HEADERS= CAF.h \
- CAF_Application.h \
- CAF_Operation.h \
- CAF_Study.h \
- CAF_Tools.h
-
-# .po files to transform in .qm
-PO_FILES = CAF_images.po \
- CAF_msg_en.po
-
-# Libraries targets
-LIB = libcaf.la
-
-LIB_SRC= CAF_Application.cxx \
- CAF_Operation.cxx \
- CAF_Study.cxx \
- CAF_Tools.cxx
-
-LIB_MOC = \
- CAF_Application.h \
- CAF_Operation.h \
- CAF_Study.h
-
-RESOURCES_FILES = \
-redo.png \
-undo.png
-
-
-CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) -I${QTDIR}/src/kernel -I$(QTDIR)/mkspecs/linux-g++
-
-LDFLAGS+=$(QT_MT_LIBS) $(CAS_OCAF) $(CAS_OCAFVIS)
-LIBS+= -lstd -lsuit
-
-@CONCLUDE@
-
-
-
-
-
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
-# would be translated to "Pub", not "Foo::Pub".
-msgid ""
-msgstr ""
-"Project-Id-Version: example-Qt-message-extraction\n"
-"POT-Creation-Date: 1999-02-23 15:38+0200\n"
-"PO-Revision-Date: 1999-02-23 15:38+0200\n"
-"Last-Translator: \n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-msgid "ICON_APP_EDIT_UNDO"
-msgstr "undo.png"
-
-msgid "ICON_APP_EDIT_REDO"
-msgstr "redo.png"
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
-# would be translated to "Pub", not "Foo::Pub".
-msgid ""
-msgstr ""
-"Project-Id-Version: example-Qt-message-extraction\n"
-"POT-Creation-Date: 1999-02-23 15:38+0200\n"
-"PO-Revision-Date: 1999-02-23 15:38+0200\n"
-"Last-Translator: \n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-msgid "CAF_Application::ABOUT_INFO"
-msgstr "SUIT Caf application"
-
-msgid "CAF_Application::MEN_APP_EDIT"
-msgstr "&Edit"
-
-msgid "CAF_Application::MEN_DESK_EDIT"
-msgstr "&Edit"
-
-msgid "CAF_Application::MEN_APP_EDIT_REDO"
-msgstr "&Redo"
-
-msgid "CAF_Application::MEN_APP_EDIT_UNDO"
-msgstr "&Undo"
-
-msgid "CAF_Application::PRP_APP_EDIT_REDO"
-msgstr "Redoes the last operation"
-
-msgid "CAF_Application::PRP_APP_EDIT_UNDO"
-msgstr "Undoes the last operation"
-
-msgid "CAF_Application::TOT_APP_EDIT_REDO"
-msgstr "Redo"
-
-msgid "CAF_Application::TOT_APP_EDIT_UNDO"
-msgstr "Undo"
-
-msgid "CAF_Application::INF_APP_UNDOACTIONS"
-msgstr " Undoes %1 action(s) "
-
-msgid "CAF_Application::INF_APP_REDOACTIONS"
-msgstr " Redoes %1 action(s) "
-
-msgid "CAF_Application::INF_ALL_DOCUMENTS_FILTER"
-msgstr "All Readable Documents"
-
-msgid "CAF_Application::INF_ALL_FILTER"
-msgstr "All Files (*.*)"
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_H
-#define CAM_H
-
-#if defined CAM_EXPORTS
-#if defined WNT
-#define CAM_EXPORT __declspec( dllexport )
-#else
-#define CAM_EXPORT
-#endif
-#else
-#if defined WNT
-#define CAM_EXPORT __declspec( dllimport )
-#else
-#define CAM_EXPORT
-#endif
-#endif
-
-#if defined SOLARIS
-#define bool int
-#define false 0
-#define true 1
-#endif
-
-#if defined WNT
-#pragma warning ( disable: 4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAM_Application.h"
-
-#include "CAM_Study.h"
-#include "CAM_Module.h"
-
-#include <SUIT_Tools.h>
-#include <SUIT_Session.h>
-#include <SUIT_MessageBox.h>
-
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qtextstream.h>
-#include <qlabel.h>
-#include <qfont.h>
-#include <qapplication.h>
-#include <qregexp.h>
-
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <dlfcn.h>
-#endif
-
-/*!Create new instance of CAM_Application*/
-extern "C" CAM_EXPORT SUIT_Application* createApplication()
-{
- return new CAM_Application();
-}
-
-/*!Constructor. read module list.
- * \param autoLoad - auto load flag.
- */
-CAM_Application::CAM_Application( const bool autoLoad )
-: STD_Application(),
-myModule( 0 ),
-myAutoLoad( autoLoad )
-{
- readModuleList();
-}
-
-/*!Destructor. Do nothing.*/
-CAM_Application::~CAM_Application()
-{
-}
-
-/*! Load modules, if \a myAutoLoad flag is true.\n
- * Start application - call start() method from parent class.
- */
-void CAM_Application::start()
-{
- if ( myAutoLoad )
- loadModules();
-
- STD_Application::start();
-}
-
-/*!Get active module.
- * \retval CAM_Module - active module.
- */
-CAM_Module* CAM_Application::activeModule() const
-{
- return myModule;
-}
-
-/*!Get module with name \a modName from modules list.
- * \retval CAM_Module pointer - module.
- */
-CAM_Module* CAM_Application::module( const QString& modName ) const
-{
- CAM_Module* mod = 0;
- for ( ModuleListIterator it( myModules ); it.current() && !mod; ++it )
- if ( it.current()->moduleName() == modName )
- mod = it.current();
- return mod;
-}
-
-/*!Gets modules iterator.*/
-CAM_Application::ModuleListIterator CAM_Application::modules() const
-{
- return ModuleListIterator( myModules );
-}
-
-/*!Gets modules list.
- * \param out - output list of modules.
- */
-void CAM_Application::modules( CAM_Application::ModuleList& out ) const
-{
- out.setAutoDelete( false );
- out.clear();
-
- for ( ModuleListIterator it( myModules ); it.current(); ++it )
- out.append( it.current() );
-}
-
-/*!Gets list of names for modules.\n
- * Get loaded modules names, if \a loaded is true, else \n
- * get names from information list.
- * \param lst - output list of names.
- * \param loaded - boolean flag.
- */
-void CAM_Application::modules( QStringList& lst, const bool loaded ) const
-{
- lst.clear();
-
- if ( loaded )
- for ( ModuleListIterator it( myModules ); it.current(); ++it )
- lst.append( it.current()->moduleName() );
- else
- for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it )
- lst.append( (*it).title );
-}
-
-/*!Adding module \a mod to list.
- *\param mod - module.
- */
-void CAM_Application::addModule( CAM_Module* mod )
-{
- if ( !mod || myModules.contains( mod ) )
- return;
-
- mod->initialize( this );
-
- QMap<CAM_Module*, int> map;
-
- ModuleList newList;
- for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it )
- {
- if ( (*it).title == mod->moduleName() )
- newList.append( mod );
- else
- {
- CAM_Module* curMod = module( (*it).title );
- if ( curMod )
- newList.append( curMod );
- }
- if ( !newList.isEmpty() )
- map.insert( newList.getLast(), 0 );
- }
-
- for ( ModuleListIterator itr( myModules ); itr.current(); ++itr )
- {
- if ( !map.contains( itr.current() ) )
- newList.append( itr.current() );
- }
-
- if ( !map.contains( mod ) )
- newList.append( mod );
-
- myModules = newList;
-
- moduleAdded( mod );
-}
-
-/*!Load modules from information list.
- * \warning If some of modules not loaded, error message appear on desktop.
- */
-void CAM_Application::loadModules()
-{
- for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it )
- {
- CAM_Module* mod = loadModule( (*it).title );
- if ( mod )
- addModule( mod );
- else {
- if ( desktop() && desktop()->isShown() )
- SUIT_MessageBox::error1( desktop(), tr( "Loading modules" ),
- tr( "Can not load module %1" ).arg( (*it).title ), tr( "Ok" ) );
- else
- qWarning( tr( "Can not load module %1" ).arg( (*it).title ).latin1() );
- }
- }
-}
-
-/*!Load module with name \a modName.
- *\param modName - module name for loading.
- *\warning If information list is empty.
- *\warning If module library (for module with \a modName) is empty.
- *\warning If module library is not loaded.
- */
-CAM_Module* CAM_Application::loadModule( const QString& modName )
-{
- if ( myInfoList.isEmpty() )
- {
- qWarning( tr( "Modules configuration is not defined." ) );
- return 0;
- }
-
- QString libName = moduleLibrary( modName );
- if ( libName.isEmpty() )
- {
- qWarning( tr( "Information about module \"%1\" doesn't exist." ).arg( modName ) );
- return 0;
- }
-
- QString err;
- GET_MODULE_FUNC crtInst = 0;
-
-#ifdef WIN32
- HINSTANCE modLib = ::LoadLibrary( libName );
- if ( !modLib )
- {
- LPVOID lpMsgBuf;
- ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS, 0, ::GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, 0 );
- err = QString( "Failed to load %1. %2" ).arg( libName ).arg( (LPTSTR)lpMsgBuf );
- ::LocalFree( lpMsgBuf );
- }
- else
- {
- crtInst = (GET_MODULE_FUNC)::GetProcAddress( modLib, GET_MODULE_NAME );
- if ( !crtInst )
- {
- LPVOID lpMsgBuf;
- ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS, 0, ::GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, 0 );
- err = QString( "Failed to find %1 function. %2" ).arg( GET_MODULE_NAME ).arg( (LPTSTR)lpMsgBuf );
- ::LocalFree( lpMsgBuf );
- }
- }
-#else
- void* modLib = dlopen( (char*)libName.latin1(), RTLD_LAZY );
- if ( !modLib )
- err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
- else
- {
- crtInst = (GET_MODULE_FUNC)dlsym( modLib, GET_MODULE_NAME );
- if ( !crtInst )
- err = QString( "Failed to find function %1. %2" ).arg( GET_MODULE_NAME ).arg( dlerror() );
- }
-#endif
-
- CAM_Module* module = crtInst ? crtInst() : 0;
- if ( module )
- {
- module->setModuleName( modName );
- module->setName( moduleName( modName ) );
- }
-
- if ( !err.isEmpty() ) {
- if ( desktop() && desktop()->isShown() )
- SUIT_MessageBox::warn1( desktop(), tr( "Error" ), err, tr( "Ok" ) );
- else
- qWarning( err.latin1() );
- }
-
- return module;
-}
-
-/*! @name Activate module group. */
-//@{
-/*!Activate module with name \a modName.
- *\param modName - module name.
- *\ratval true, if module loaded and activated successful, else false.
- */
-bool CAM_Application::activateModule( const QString& modName )
-{
- if ( !modName.isEmpty() && !activeStudy() )
- return false;
-
- bool res = false;
- if ( !modName.isEmpty() )
- {
- CAM_Module* mod = module( modName );
- if ( !mod && !moduleLibrary( modName ).isEmpty() )
- {
- mod = loadModule( modName );
- addModule( mod );
- }
-
- if ( mod )
- res = activateModule( mod );
- }
- else
- res = activateModule( 0 );
-
- return res;
-}
-
-/*!Activate module \a mod
- *\param mod - module for activation.
- *\retval true - if all sucessful.
- *\warning Error message if module not activated in active study.
- */
-bool CAM_Application::activateModule( CAM_Module* mod )
-{
- if ( mod && !activeStudy() )
- return false;
-
- if ( myModule == mod )
- return true;
-
- if ( myModule )
- {
- if ( !myModule->deactivateModule( activeStudy() ) )
- {
- // ....
- }
- }
- myModule = mod;
-
- if ( myModule ){
- // Connect the module to the active study
- myModule->connectToStudy( dynamic_cast<CAM_Study*>( activeStudy() ) );
- if ( !myModule->activateModule( activeStudy() ) )
- {
- myModule->setMenuShown( false );
- myModule->setToolShown( false );
- if ( desktop() && desktop()->isShown() )
- SUIT_MessageBox::error1( desktop(), tr( "ERROR_TLT" ), tr( "ERROR_ACTIVATE_MODULE_MSG" ).arg( myModule->moduleName() ), tr( "BUT_OK" ) );
- else
- qWarning( tr( "ERROR_ACTIVATE_MODULE_MSG" ).arg( myModule->moduleName() ).latin1() );
- myModule = 0;
- return false;
- }
- }
-
- updateCommandsStatus();
-
- return true;
-}
-//@}
-
-/*!Create new study for current application.
- *\retval study pointer.
- */
-SUIT_Study* CAM_Application::createNewStudy()
-{
- return new CAM_Study( this );
-}
-
-/*!Update commands status for parent class and for current class(if module is active)*/
-void CAM_Application::updateCommandsStatus()
-{
- STD_Application::updateCommandsStatus();
-
- if ( activeModule() )
- activeModule()->updateCommandsStatus();
-}
-
-/*!Close all modules in study \a theDoc.
- *\param theDoc - study
- */
-void CAM_Application::beforeCloseDoc( SUIT_Study* theDoc )
-{
- for ( ModuleListIterator it( myModules ); it.current(); ++it )
- it.current()->studyClosed( theDoc );
-}
-
-/*!Sets active study for parent class.
- *\param study - study.
- */
-void CAM_Application::setActiveStudy( SUIT_Study* study )
-{
- STD_Application::setActiveStudy( study );
-}
-
-/*!Do nothing.*/
-void CAM_Application::moduleAdded( CAM_Module* mod )
-{
-// CAM_Study* study = dynamic_cast<CAM_Study*>( activeStudy() );
-// if ( !study )
-// return;
-
-// study->insertDataModel( mod->dataModel() );
-}
-
-/*!Gets module name by title \a title
- *\param title - title name
- *\retval QString module name.
- */
-QString CAM_Application::moduleName( const QString& title ) const
-{
- QString res;
- for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
- {
- if ( (*it).title == title )
- res = (*it).name;
- }
- return res;
-}
-
-/*!Gets module title by module name \a name
- *\param name - module name
- *\retval QString module title.
- */
-QString CAM_Application::moduleTitle( const QString& name ) const
-{
- QString res;
- for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
- {
- if ( (*it).name == name )
- res = (*it).title;
- }
- return res;
-}
-
-/*!Get library name for module with title \a title.
- *\param title - module title name.
- *\param full - boolean flag (if true - return full library name, else internal name)
- *\retval QString - library name.
- */
-QString CAM_Application::moduleLibrary( const QString& title, const bool full ) const
-{
- QString res;
- for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
- {
- if ( (*it).title == title )
- res = (*it).internal;
- }
- if ( !res.isEmpty() && full )
- res = SUIT_Tools::library( res );
- return res;
-}
-
-/*!Read modules list*/
-void CAM_Application::readModuleList()
-{
- if ( !myInfoList.isEmpty() )
- return;
-
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-
- QStringList modList;
-
- QStringList args;
- for (int i = 1; i < qApp->argc(); i++)
- args.append( qApp->argv()[i] );
-
- QRegExp rx("--modules\\s+\\(\\s*(.*)\\s*\\)");
- rx.setMinimal( true );
- if ( rx.search( args.join(" ") ) >= 0 && rx.capturedTexts().count() > 0 ) {
- QString modules = rx.capturedTexts()[1];
- QStringList mods = QStringList::split(":",modules,false);
- for ( uint i = 0; i < mods.count(); i++ ) {
- if ( !mods[i].stripWhiteSpace().isEmpty() )
- modList.append( mods[i].stripWhiteSpace() );
- }
- }
- if ( modList.isEmpty() ) {
- QString mods = resMgr->stringValue( "launch", "modules", QString::null );
- modList = QStringList::split( ",", mods );
- }
-
- for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
- {
- QString modName = (*it).stripWhiteSpace();
- if ( modName.isEmpty() )
- continue;
-
- QString modTitle = resMgr->stringValue( *it, QString( "name" ), QString::null );
- if ( modTitle.isEmpty() )
- {
- printf( "****************************************************************\n" );
- printf( "* Warning: %s not found in resources.\n", (*it).latin1() );
- printf( "* Module will not be available\n" );
- printf( "****************************************************************\n" );
- continue;
- }
-
- QString modLibrary = resMgr->stringValue( *it, QString( "library" ), QString::null ).stripWhiteSpace();
- if ( !modLibrary.isEmpty() )
- {
- QString libExt;
- modLibrary = SUIT_Tools::file( modLibrary.stripWhiteSpace() );
- libExt = QString( "so" );
- if ( SUIT_Tools::extension( modLibrary ).lower() == libExt )
- modLibrary = modLibrary.mid( 0, modLibrary.length() - libExt.length() - 1 );
- libExt = QString( "dll" );
- if ( SUIT_Tools::extension( modLibrary ).lower() == libExt )
- modLibrary = modLibrary.mid( 0, modLibrary.length() - libExt.length() - 1 );
-#ifndef WIN32
- if ( modLibrary.startsWith( "lib" ) )
- modLibrary = modLibrary.mid( 3 );
-#endif
- }
- else
- modLibrary = modName;
-
- ModuleInfo inf;
- inf.name = modName;
- inf.title = modTitle;
- inf.internal = modLibrary;
- myInfoList.append( inf );
- }
-
- if ( myInfoList.isEmpty() ) {
- if ( desktop() && desktop()->isShown() )
- SUIT_MessageBox::warn1( desktop(), tr( "Warning" ), tr( "Modules list is empty" ), tr( "&OK" ) );
- else
- {
- printf( "****************************************************************\n" );
- printf( "* Warning: modules list is empty.\n" );
- printf( "****************************************************************\n" );
- }
- }
-}
-
-/*!Add common items for popup menu ( if they are exist )
- *\param type - type of popup menu
- *\param thePopup - popup menu
- *\param title - title of popup menu
- */
-void CAM_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
-{
- // to do : add common items for popup menu ( if they are exist )
- if ( activeModule() )
- activeModule()->contextMenuPopup( type, thePopup, title );
-}
-
-/*!Create empty study.*/
-void CAM_Application::createEmptyStudy()
-{
- /*SUIT_Study* study = */activeStudy();
- STD_Application::createEmptyStudy();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_APPLICATION_H
-#define CAM_APPLICATION_H
-
-#include "STD_Application.h"
-
-#include "CAM_Module.h"
-
-#include <qptrlist.h>
-
-class QPopupMenu;
-
-#ifdef WIN32
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class CAM_Application
- Defines application configuration and behaviour for application with modules.
- Every module has own data model, necessary windows and viewers, etc.
- Application provides all necessary functionality for module management
- (loading of modules/activation/deactivation, etc)
-*/
-class CAM_EXPORT CAM_Application : public STD_Application
-{
- Q_OBJECT
-
-public:
- typedef QPtrList<CAM_Module> ModuleList;
- typedef QPtrListIterator<CAM_Module> ModuleListIterator;
-
-public:
- CAM_Application( const bool = true );
- virtual ~CAM_Application();
-
- virtual void start();
-
- CAM_Module* activeModule() const;
- CAM_Module* module( const QString& ) const;
-
- /** @name Modules lists.*/
- //@{
- ModuleListIterator modules() const;
- void modules( ModuleList& ) const;
- void modules( QStringList&, const bool loaded = true ) const;
- //@}
-
- virtual void addModule( CAM_Module* );
-
- virtual void loadModules();
- virtual CAM_Module* loadModule( const QString& );
-
- virtual bool activateModule( const QString& );
-
- virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
-
- QString moduleName( const QString& ) const;
- QString moduleTitle( const QString& ) const;
-
- virtual void createEmptyStudy();
-
-protected:
- virtual SUIT_Study* createNewStudy();
- virtual void updateCommandsStatus();
-
- virtual void moduleAdded( CAM_Module* );
- virtual void beforeCloseDoc( SUIT_Study* );
- virtual bool activateModule( CAM_Module* = 0 );
-
- virtual void setActiveStudy( SUIT_Study* );
-
- QString moduleLibrary( const QString&, const bool = true ) const;
-
-private:
- void readModuleList();
-
-private:
- typedef struct { QString name, title, internal; } ModuleInfo;
- typedef QValueList<ModuleInfo> ModuleInfoList;
-
-private:
- CAM_Module* myModule;
- ModuleList myModules;
- ModuleInfoList myInfoList;
- bool myAutoLoad;
-};
-
-#ifdef WIN32
-#pragma warning( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAM_DataModel.h"
-
-#include "CAM_Module.h"
-#include "CAM_RootObject.h"
-
-/*!Constructor. Initialise module by \a module.*/
-CAM_DataModel::CAM_DataModel( CAM_Module* module )
-: myRoot( 0 ),
-myModule( module )
-{
-}
-
-/*!Destructor. Do nothing.*/
-CAM_DataModel::~CAM_DataModel()
-{
-}
-
-/*!
- Default implementation, does nothing.
- Can be used for creation of root object.
-*/
-void CAM_DataModel::initialize()
-{
-}
-
-/*!Get root object.
- *\retval CAM_DataObject pointer - root object.
- */
-CAM_DataObject* CAM_DataModel::root() const
-{
- return myRoot;
-}
-
-/*!Sets root object to \a newRoot.\n
- *Emit root changed, if it was.
- *\param newRoot - new root object
- */
-void CAM_DataModel::setRoot( const CAM_DataObject* newRoot )
-{
- if ( myRoot == newRoot )
- return;
-
- if ( myRoot )
- myRoot->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
-
- myRoot = (CAM_DataObject*)newRoot;
-
- if ( myRoot )
- myRoot->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
-
- emit rootChanged( this );
-}
-
-/*!Gets module.
- *\retval CAM_Module pointer - module.
- */
-CAM_Module* CAM_DataModel::module() const
-{
- return myModule;
-}
-
-/*!Nullify root, if \a obj equal root.*/
-void CAM_DataModel::onDestroyed( SUIT_DataObject* obj )
-{
- if ( myRoot == obj )
- myRoot = 0;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_DATAMODEL_H
-#define CAM_DATAMODEL_H
-
-#include "CAM.h"
-
-#include <qobject.h>
-#include <qstringlist.h>
-
-class CAM_Module;
-class CAM_DataObject;
-class CAM_Study;
-class SUIT_DataObject;
-
-/*!
- \class CAM_DataModel
- Base class for all data models used in CAM-based applications.
- Represents data model of CAM module. Provides necessary interface (default implementation is empty)
-*/
-class CAM_EXPORT CAM_DataModel : public QObject
-{
- Q_OBJECT
-
-public:
- CAM_DataModel( CAM_Module* );
- virtual ~CAM_DataModel();
-
- virtual void initialize();
-
- CAM_DataObject* root() const;
- CAM_Module* module() const;
-
- /** @name These methods should be redefined in successors.*/
- //@{
- virtual bool open( const QString&, CAM_Study*, QStringList ) { return true; }//!< return true
- virtual bool save( QStringList& ) { return true; };
- virtual bool saveAs( const QString&, CAM_Study*, QStringList& ) { return true; };
- virtual bool close() { return true; };
- virtual bool create( CAM_Study* ) { return true; }
- //@}
-
-protected:
- /*! setRoot() should be used to specify custom root object instance.\n
- * Such an object can be created in several ways, depending on application or module needs:\n
- * \li by initialize()
- * \li while the model is being loaded
- * \li when the model is updated and becomes non-empty
- */
- virtual void setRoot( const CAM_DataObject* );
-
-private slots:
- void onDestroyed( SUIT_DataObject* );
-
-signals:
- void rootChanged( const CAM_DataModel* );
-
-private:
- CAM_DataObject* myRoot;
- CAM_Module* myModule;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAM_DataObject.h"
-
-#include "CAM_Module.h"
-#include "CAM_DataModel.h"
-
-/*!Constructor. Sets parent object.*/
-CAM_DataObject::CAM_DataObject( SUIT_DataObject* parent )
-: SUIT_DataObject( parent )
-{
-}
-
-/*!Destructor.Do nothing*/
-CAM_DataObject::~CAM_DataObject()
-{
-}
-
-/*!Get module.
- *\retval const CAM_Module pointer - module
- */
-CAM_Module* CAM_DataObject::module() const
-{
- CAM_Module* mod = 0;
-
- CAM_DataModel* data = dataModel();
- if ( data )
- mod = data->module();
-
- return mod;
-}
-
-/*!Get data model.
- *Return 0 - if no parent obbject.
- *\retval const CAM_DataModel pointer - data model
- */
-CAM_DataModel* CAM_DataObject::dataModel() const
-{
- CAM_DataObject* parentObj = dynamic_cast<CAM_DataObject*>( parent() );
-
- if ( !parentObj )
- return 0;
-
- return parentObj->dataModel();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_DATAOBJECT_H
-#define CAM_DATAOBJECT_H
-
-#include "CAM.h"
-
-#include <SUIT_DataObject.h>
-
-class CAM_Module;
-class CAM_DataModel;
-
-/*!
- \class CAM_DataObject
- Provides only additional link to CAM_DataModel
-*/
-class CAM_EXPORT CAM_DataObject : public SUIT_DataObject
-{
-public:
- CAM_DataObject( SUIT_DataObject* = 0 );
- virtual ~CAM_DataObject();
-
- CAM_Module* module() const;
- virtual CAM_DataModel* dataModel() const;
-};
-
-#endif
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAM_Module.h"
-
-#include "CAM_DataModel.h"
-#include "CAM_Application.h"
-#include "CAM_Study.h"
-
-#include <QtxAction.h>
-#include <QtxActionMenuMgr.h>
-#include <QtxActionToolMgr.h>
-
-#include <SUIT_Session.h>
-#include <SUIT_Application.h>
-
-/*!Icon.*/
-static const char* ModuleIcon[] = {
-"20 20 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" .................. ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" .................. ",
-" . . . ",
-" . . . ",
-" ... ... ... ",
-" .. .. .. .. .. .. ",
-" . . . . . . ",
-" .. .. .. .. .. .. ",
-" ... ... ... "};
-
-QPixmap MYPixmap( ModuleIcon );
-
-/*!Constructor.*/
-CAM_Module::CAM_Module()
-: QObject(),
-myApp( 0 ),
-myIcon( MYPixmap ),
-myDataModel( 0 )
-{
-}
-
-/*!Constructor. initialize \a name.*/
-CAM_Module::CAM_Module( const QString& name )
-: QObject(),
-myApp( 0 ),
-myName( name ),
-myIcon( MYPixmap ),
-myDataModel( 0 )
-{
-}
-
-/*!Destructor. Remove data model.*/
-CAM_Module::~CAM_Module()
-{
- delete myDataModel;
- myDataModel = 0;
-}
-
-/*!Initialize application.*/
-void CAM_Module::initialize( CAM_Application* app )
-{
- myApp = app;
- if ( myApp )
- {
- SUIT_Session* aSession = SUIT_Session::session();
- connect( aSession, SIGNAL( applicationClosed( SUIT_Application* ) ),
- this, SLOT( onApplicationClosed( SUIT_Application* ) ) );
-
- connect( myApp, SIGNAL( infoChanged( QString ) ), this, SLOT( onInfoChanged( QString ) ) );
- }
-}
-
-/*!\retval Module icon.*/
-QPixmap CAM_Module::moduleIcon() const
-{
- return myIcon;
-}
-
-/*!\retval Module icon name.*/
-QString CAM_Module::iconName() const
-{
- return "";
-}
-
-/*!\retval Module name.*/
-QString CAM_Module::moduleName() const
-{
- return myName;
-}
-
-/*! \brief Return data model.
- * Create data model, if it was't created before.
- */
-CAM_DataModel* CAM_Module::dataModel() const
-{
- if ( !myDataModel )
- {
- CAM_Module* that = (CAM_Module*)this;
- that->myDataModel = that->createDataModel();
- that->myDataModel->initialize();
- }
- return myDataModel;
-}
-
-/*!\retval CAM_Application pointer - application.*/
-CAM_Application* CAM_Module::application() const
-{
- return myApp;
-}
-
-/*!Public slot
- * \retval true.
- */
-bool CAM_Module::activateModule( SUIT_Study* study )
-{
- return true;
-}
-
-/*!Public slot
- * \retval true.
- */
-bool CAM_Module::deactivateModule( SUIT_Study* )
-{
- return true;
-}
-
-/*!Public slot, remove data model from \a study.*/
-void CAM_Module::studyClosed( SUIT_Study* study )
-{
- CAM_Study* camDoc = dynamic_cast<CAM_Study*>( study );
- if ( !camDoc )
- return;
-
- CAM_DataModel* dm = dataModel();
- if ( dm && camDoc->containsDataModel( dm ) ) {
- dm->close();
- camDoc->removeDataModel( dm );
- }
-}
-
-/*!Public slot, do nothing.*/
-void CAM_Module::studyChanged( SUIT_Study* , SUIT_Study* )
-{
-}
-
-/*!Return true if module is active.*/
-bool CAM_Module::isActiveModule() const
-{
- return application() ? application()->activeModule() == this : false;
-}
-
-/*!
- Put the message into the status bar of the desktop. Message will be displayed
- during specified \amscec milliseconds. If parameter \amsec is negative then
- message will be persistently displayed when module is active.
-*/
-void CAM_Module::putInfo( const QString& msg, const int msec )
-{
- if ( application() )
- application()->putInfo( msg, msec );
-
- if ( msec < 0 )
- myInfo = msg;
-}
-
-/*!
- Restore persistently displayed info string when previos information status string erasing
- if module is active.
-*/
-void CAM_Module::onInfoChanged( QString txt )
-{
- if ( txt.isEmpty() && isActiveModule() && !myInfo.isEmpty() && application() )
- application()->putInfo( myInfo );
-}
-
-/*!Public slot, nullify application pointer if the application was closed.*/
-void CAM_Module::onApplicationClosed( SUIT_Application* theApp )
-{
- if ( myApp == theApp )
- myApp = NULL;
-}
-
-/*!Create and return new instance of CAM_DataModel.*/
-CAM_DataModel* CAM_Module::createDataModel()
-{
- return new CAM_DataModel( this );
-}
-
-/*!Sets module name to \a name.
- * \param name - new name for module.
- */
-void CAM_Module::setModuleName( const QString& name )
-{
- myName = name;
-}
-
-/*!Sets module icon to \a icon.
- * \param icon - new icon for module.
- */
-void CAM_Module::setModuleIcon( const QPixmap& icon )
-{
- myIcon = icon;
-}
-
-/*! Return menu manager pointer.
- * \retval QtxActionMenuMgr pointer - menu manager.
- */
-QtxActionMenuMgr* CAM_Module::menuMgr() const
-{
- QtxActionMenuMgr* mgr = 0;
- if ( application() && application()->desktop() )
- mgr = application()->desktop()->menuMgr();
- return mgr;
-}
-
-/*! Return tool manager pointer.
- * \retval QtxActionToolMgr pointer - tool manager.
- */
-QtxActionToolMgr* CAM_Module::toolMgr() const
-{
- QtxActionToolMgr* mgr = 0;
- if ( application() && application()->desktop() )
- mgr = application()->desktop()->toolMgr();
- return mgr;
-}
-
-/*! Create tool bar with name \a name, if it was't created before.
- * \retval -1 - if tool manager was't be created.
- */
-int CAM_Module::createTool( const QString& name )
-{
- if ( !toolMgr() )
- return -1;
-
- return toolMgr()->createToolBar( name );
-}
-
-/*! Create tool. Register action \a a with id \a id.
- * Insert QAction to tool manager.
- *\param a - QAction
- *\param tBar - integer
- *\param id - integer
- *\param idx - integer
- *\retval integer id of new action in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int idx )
-{
- if ( !toolMgr() )
- return -1;
-
- int regId = registerAction( id, a );
- int intId = toolMgr()->insert( a, tBar, idx );
- return intId != -1 ? regId : -1;
-}
-
-/*! Create tool. Register action \a a with id \a id.
- * Insert QAction to tool manager.
- *\param a - QAction
- *\param tBar - QString&
- *\param id - integer
- *\param idx - integer
- *\retval integer id of new action in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const int idx )
-{
- if ( !toolMgr() )
- return -1;
-
- int regId = registerAction( id, a );
- int intId = toolMgr()->insert( a, tBar, idx );
- return intId != -1 ? regId : -1;
-}
-
-/*! Create tool.
- * Insert QAction with id \a id from action map(myActionMap) to tool manager.
- *\param id - integer
- *\param tBar - integer
- *\param idx - integer
- *\retval integer id of new action in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createTool( const int id, const int tBar, const int idx )
-{
- if ( !toolMgr() )
- return -1;
-
- int intId = toolMgr()->insert( action( id ), tBar, idx );
- return intId != -1 ? id : -1;
-}
-
-/*! Create tool.
- * Insert QAction with id \a id from action map(myActionMap) to tool manager.
- *\param id - integer
- *\param tBar - QString&
- *\param idx - integer
- *\retval integer id of new action in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createTool( const int id, const QString& tBar, const int idx )
-{
- if ( !toolMgr() )
- return -1;
-
- int intId = toolMgr()->insert( action( id ), tBar, idx );
- return intId != -1 ? id : -1;
-}
-
-/*! Create menu.
- * Insert submenu \a subMenu to menu manager.
- *\param subMenu - QString&
- *\param menu - integer
- *\param id - integer
- *\param group - integer
- *\param index - integer
- *\retval integer id of new menu in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createMenu( const QString& subMenu, const int menu,
- const int id, const int group, const int index,
- const bool enableEmpty )
-{
- if ( !menuMgr() )
- return -1;
-
- return menuMgr()->insert( subMenu, menu, group, id, index, enableEmpty );
-}
-
-/*! Create menu.
- * Insert submenu \a subMenu to menu manager.
- *\param subMenu - QString&
- *\param menu - QString&
- *\param id - integer
- *\param group - integer
- *\param index - integer
- *\retval integer id of new menu in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createMenu( const QString& subMenu, const QString& menu,
- const int id, const int group, const int index,
- const bool enableEmpty )
-{
- if ( !menuMgr() )
- return -1;
-
- return menuMgr()->insert( subMenu, menu, group, id, index, enableEmpty );
-}
-
-
-/*! Create menu. Register action \a a with id \a id.
- * Insert QAction to menu manager.
- *\param a - Qaction
- *\param menu - integer
- *\param id - integer
- *\param group - integer
- *\param index - integer
- *\retval integer id of new menu in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int group, const int index )
-{
- if ( !a || !menuMgr() )
- return -1;
-
- int regId = registerAction( id, a );
- int intId = menuMgr()->insert( a, menu, group, index );
- return intId != -1 ? regId : -1;
-}
-
-/*! Create menu. Register action \a a with id \a id.
- * Insert QAction to menu manager.
- *\param a - Qaction
- *\param menu - QString&
- *\param id - integer
- *\param group - integer
- *\param index - integer
- *\retval integer id of new menu in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const int group, const int index )
-{
- if ( !a || !menuMgr() )
- return -1;
-
- int regId = registerAction( id, a );
- int intId = menuMgr()->insert( a, menu, group, index );
- return intId != -1 ? regId : -1;
-}
-
-/*! Create menu.
- * Insert QAction with id \a id from action map(myActionMap) to menu manager.
- *\param menu - integer
- *\param id - integer
- *\param group - integer
- *\param index - integer
- *\retval integer id of new menu in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createMenu( const int id, const int menu, const int group, const int index )
-{
- if ( !menuMgr() )
- return -1;
-
- int intId = menuMgr()->insert( action( id ), menu, group, index );
- return intId != -1 ? id : -1;
-}
-
-/*! Create menu.
- * Insert QAction with id \a id from action map(myActionMap) to menu manager.
- *\param menu - QString&
- *\param id - integer
- *\param group - integer
- *\param index - integer
- *\retval integer id of new menu in tool manager.
- *\retval Return -1 if something wrong.
- */
-int CAM_Module::createMenu( const int id, const QString& menu, const int group, const int index )
-{
- if ( !menuMgr() )
- return -1;
-
- int intId = menuMgr()->insert( action( id ), menu, group, index );
- return intId != -1 ? id : -1;
-}
-
-/*!Sets menus shown to \a on floag.
- *\param on - flag.
- */
-void CAM_Module::setMenuShown( const bool on )
-{
- QtxActionMenuMgr* mMgr = menuMgr();
- if ( !mMgr )
- return;
-
- bool upd = mMgr->isUpdatesEnabled();
- mMgr->setUpdatesEnabled( false );
-
- QAction* sep = separator();
- for ( QMap<int, QAction*>::Iterator it = myActionMap.begin(); it != myActionMap.end(); ++it )
- {
- if ( it.data() != sep )
- mMgr->setShown( mMgr->actionId( it.data() ), on );
- }
-
- mMgr->setUpdatesEnabled( upd );
- if ( upd )
- mMgr->update();
-}
-
-/*!Sets menu shown for QAction \a a to \a on flag.
- * \param a - QAction
- * \param on - flag
- */
-void CAM_Module::setMenuShown( QAction* a, const bool on )
-{
- if ( menuMgr() )
- menuMgr()->setShown( menuMgr()->actionId( a ), on );
-}
-
-/*!Sets menu shown for action with id=\a id to \a on flag.
- * \param id - id of action
- * \param on - flag
- */
-void CAM_Module::setMenuShown( const int id, const bool on )
-{
- setMenuShown( action( id ), on );
-}
-
-/*!Set tools shown to \a on flag.
- *\param on - boolean flag.
- */
-void CAM_Module::setToolShown( const bool on )
-{
- QtxActionToolMgr* tMgr = toolMgr();
- if ( !tMgr )
- return;
-
- bool upd = tMgr->isUpdatesEnabled();
- tMgr->setUpdatesEnabled( false );
-
- QAction* sep = separator();
- for ( QMap<int, QAction*>::Iterator it = myActionMap.begin(); it != myActionMap.end(); ++it )
- {
- if ( it.data() != sep )
- tMgr->setShown( tMgr->actionId( it.data() ), on );
- }
-
- tMgr->setUpdatesEnabled( upd );
- if ( upd )
- tMgr->update();
-}
-
-/*!Set tools shown for QAction \a a to \a on flag.
- * \param a - QAction
- * \param on - boolean flag
- */
-void CAM_Module::setToolShown( QAction* a, const bool on )
-{
- if ( toolMgr() )
- toolMgr()->setShown( toolMgr()->actionId( a ), on );
-}
-
-/*!Set tools shown for action with id=\a id to \a on flag.
- * \param id - integer action id
- * \param on - boolean flag
- */
-void CAM_Module::setToolShown( const int id, const bool on )
-{
- setToolShown( action( id ), on );
-}
-
-/*! Return action by id.
- * \param id - id of action.
- * \retval QAction.
- */
-QAction* CAM_Module::action( const int id ) const
-{
- QAction* a = 0;
- if ( myActionMap.contains( id ) )
- a = myActionMap[id];
- return a;
-}
-
-/*! Return id by action.
- * \param a - QAction.
- * \retval id of action.
- */
-int CAM_Module::actionId( const QAction* a ) const
-{
- int id = -1;
- for ( QMap<int, QAction*>::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && id == -1; ++it )
- {
- if ( it.data() == a )
- id = it.key();
- }
- return id;
-}
-
-/*! Create new instance of QtxAction and register action with \a id.
- * \param id - id for new action.
- * \param text - parameter for creation QtxAction
- * \param icon - parameter for creation QtxAction
- * \param menu - parameter for creation QtxAction
- * \param tip - tip status for QtxAction action.
- * \param key - parameter for creation QtxAction
- * \param parent - parent for action
- * \param toggle - parameter for creation QtxAction
- * \param reciever -
- * \param member -
- */
-QAction* CAM_Module::createAction( const int id, const QString& text, const QIconSet& icon,
- const QString& menu, const QString& tip, const int key,
- QObject* parent, const bool toggle, QObject* reciever, const char* member )
-{
- QtxAction* a = new QtxAction( text, icon, menu, key, parent, 0, toggle );
- a->setStatusTip( tip );
-
- if ( reciever && member )
- connect( a, SIGNAL( activated() ), reciever, member );
-
- registerAction( id, a );
-
- return a;
-}
-
-/*! Register action in action map.
- * \param id - id for action.
- * \param a - action
- * \retval new id for action.
- */
-int CAM_Module::registerAction( const int id, QAction* a )
-{
- int ident = -1;
- for ( QMap<int, QAction*>::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && ident == -1; ++it )
- if ( it.data() == a )
- ident = it.key();
-
- if ( ident != -1 )
- return ident;
-
- static int generatedId = -1;
- ident = id < 0 ? --generatedId : id;
-
- myActionMap.insert( ident, a );
-
- if ( menuMgr() )
- menuMgr()->registerAction( a );
-
- if ( toolMgr() )
- toolMgr()->registerAction( a );
-
- return ident;
-}
-
-/*! Unregister an action.
- * \param id - id for action.
- * \retval true if succeded, false if action is used
- */
-bool CAM_Module::unregisterAction( const int id )
-{
- return unregisterAction( action( id ) );
-}
-
-/*! Unregister an action.
- * \param a - action
- * \retval true if succeded, false if action is used
- */
-bool CAM_Module::unregisterAction( QAction* a )
-{
- if ( !a )
- return false;
- if ( menuMgr() ) {
- int id = menuMgr()->actionId( a );
- if ( id != -1 && menuMgr()->containsMenu( id, -1 ) )
- return false;
- }
- if ( toolMgr() ) {
- int id = toolMgr()->actionId( a );
- if ( id != -1 && toolMgr()->containsAction( id ) )
- return false;
- }
- if ( menuMgr() )
- menuMgr()->unRegisterAction( menuMgr()->actionId( a ) );
- if ( toolMgr() )
- toolMgr()->unRegisterAction( toolMgr()->actionId( a ) );
- return true;
-}
-
-/*! Return qt action manager separator.*/
-QAction* CAM_Module::separator()
-{
- return QtxActionMgr::separator();
-}
-
-/*! Connect data model of module with active study */
-void CAM_Module::connectToStudy( CAM_Study* camStudy )
-{
- CAM_Application* app = camStudy ? dynamic_cast<CAM_Application*>( camStudy->application() ) : 0;
- if( !app )
- return;
-
- CAM_DataModel* prev = 0;
- for( CAM_Application::ModuleListIterator it = app->modules(); it.current(); ++it )
- {
- CAM_DataModel* dm = it.current()->dataModel();
- if( it.current() == this && !camStudy->containsDataModel( dm ) )
- {
- if ( prev )
- camStudy->insertDataModel( it.current()->dataModel(), prev );
- else
- camStudy->insertDataModel( it.current()->dataModel(), 0 );
- }
- prev = dm;
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_MODULE_H
-#define CAM_MODULE_H
-
-#include "CAM.h"
-
-#include <qpixmap.h>
-#include <qobject.h>
-#include <qpopupmenu.h>
-#include <qstring.h>
-
-class QAction;
-class SUIT_Study;
-class SUIT_Application;
-class CAM_Study;
-class CAM_DataModel;
-class CAM_Application;
-class QtxActionMenuMgr;
-class QtxActionToolMgr;
-
-#ifdef WIN32
-#pragma warning( disable: 4251 )
-#endif
-
-/*!
- * Class provide support of tool and menu managers.
- */
-class CAM_EXPORT CAM_Module : public QObject
-{
- Q_OBJECT
-
-public:
- CAM_Module();
- CAM_Module( const QString& );
- virtual ~CAM_Module();
-
- virtual void initialize( CAM_Application* );
-
- QString moduleName() const;
- QPixmap moduleIcon() const;
-
- CAM_DataModel* dataModel() const;
- CAM_Application* application() const;
-
- virtual QString iconName() const;
-
- virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
- virtual void updateCommandsStatus() {};
-
- virtual void putInfo( const QString&, const int = -1 );
-
- bool isActiveModule() const;
-
- /** @name Set Menu Shown*/
- //@{
- virtual void setMenuShown( const bool );
- void setMenuShown( QAction*, const bool );
- void setMenuShown( const int, const bool );
- //@}
-
- /** @name Set Tool Shown*/
- //@{
- virtual void setToolShown( const bool );
- void setToolShown( QAction*, const bool );
- void setToolShown( const int, const bool );
- //@}
-
-public slots:
- virtual bool activateModule( SUIT_Study* );
- virtual bool deactivateModule( SUIT_Study* );
-
- virtual void connectToStudy( CAM_Study* );
-
- virtual void studyClosed( SUIT_Study* );
- virtual void studyChanged( SUIT_Study*, SUIT_Study* );
-
- virtual void onApplicationClosed( SUIT_Application* );
-
-private slots:
- void onInfoChanged( QString );
-
-protected:
- virtual CAM_DataModel* createDataModel();
-
- virtual void setModuleName( const QString& );
- virtual void setModuleIcon( const QPixmap& );
-
- QtxActionMenuMgr* menuMgr() const;
- QtxActionToolMgr* toolMgr() const;
-
- /** @name Create tool methods.*/
- //@{
- int createTool( const QString& );
- int createTool( const int, const int, const int = -1 );
- int createTool( const int, const QString&, const int = -1 );
- int createTool( QAction*, const int, const int = -1, const int = -1 );
- int createTool( QAction*, const QString&, const int = -1, const int = -1 );
- //@}
-
- /** @name Create menu methods.*/
- //@{
- int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false );
- int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
- int createMenu( const int, const int, const int = -1, const int = -1 );
- int createMenu( const int, const QString&, const int = -1, const int = -1 );
- int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
- int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
- //@}
-
- static QAction* separator();
-
- /**Action ids methods.*/
- //@{
- QAction* action( const int ) const;
- int actionId( const QAction* ) const;
- //@}
-
- int registerAction( const int, QAction* );
- bool unregisterAction( const int );
- bool unregisterAction( QAction* );
- QAction* createAction( const int, const QString&, const QIconSet&, const QString&,
- const QString&, const int, QObject* = 0,
- const bool = false, QObject* = 0, const char* = 0 );
-
-private:
- CAM_Application* myApp;
- QString myName;
- QPixmap myIcon;
- QString myInfo;
- CAM_DataModel* myDataModel;
- QMap<int, QAction*> myActionMap;
-
- friend class CAM_Application;
-};
-
-#ifdef WIN32
-#pragma warning( default: 4251 )
-#endif
-
-extern "C"
-{
- typedef CAM_Module* (*GET_MODULE_FUNC)();
-}
-
-#define GET_MODULE_NAME "createModule"
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAM_RootObject.h"
-
-#include "CAM_DataModel.h"
-#include "CAM_Module.h"
-
-/*!Constructor. Initialize by \a parent.
- * Set data model to 0.
- */
-CAM_RootObject::CAM_RootObject( SUIT_DataObject* parent )
-: CAM_DataObject( parent ),
-myDataModel( 0 )
-{
-}
-
-/*!Constructor. Initialize by \a parent and \a data - data object
- *\param data - data object
- *\param parent - parent data object
- */
-CAM_RootObject::CAM_RootObject( CAM_DataModel* data, SUIT_DataObject* parent )
-: CAM_DataObject( parent ),
-myDataModel( data )
-{
-}
-
-/*!Destructor. Do nothing.*/
-CAM_RootObject::~CAM_RootObject()
-{
-}
-
-/*!
- Returns module name
-*/
-QString CAM_RootObject::name() const
-{
- QString aName = "";
- if (myDataModel)
- aName = myDataModel->module()->moduleName();
- return aName;
-}
-
-/*!Get data model
- *\retval const CAM_DataModel pointer to data model.
- */
-CAM_DataModel* CAM_RootObject::dataModel() const
-{
- return myDataModel;
-}
-
-/*!Set data model.
- *\param dm - data model to set.
- */
-void CAM_RootObject::setDataModel( CAM_DataModel* dm )
-{
- myDataModel = dm;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_ROOTOBJECT_H
-#define CAM_ROOTOBJECT_H
-
-#include "CAM_DataObject.h"
-
-/*!
- CAM_RootObject - class intended for optimized access to CAM_DataModel instance
- from CAM_DataObject instances.
-
- To take advantage of this class in a specific application,
- custom data model root object class should be derived from both CAM_RootObject
- and application-specific DataObject implementation using virtual inheritance.
- */
-class CAM_EXPORT CAM_RootObject : public virtual CAM_DataObject
-{
-public:
- CAM_RootObject( SUIT_DataObject* = 0 );
- CAM_RootObject( CAM_DataModel*, SUIT_DataObject* = 0 );
- virtual ~CAM_RootObject();
-
- virtual QString name() const;
-
- virtual CAM_DataModel* dataModel() const;
- virtual void setDataModel( CAM_DataModel* );
-
-private:
- CAM_DataModel* myDataModel;
-};
-
-#endif
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "CAM_Study.h"
-
-#include "CAM_DataModel.h"
-#include "CAM_DataObject.h"
-#include "CAM_RootObject.h"
-#include "CAM_Module.h"
-
-/*!Constructor.*/
-CAM_Study::CAM_Study( SUIT_Application* app )
-: SUIT_Study( app )
-{
-}
-
-/*!Destructor*/
-CAM_Study::~CAM_Study()
-{
-}
-
-/*!Closing all data models and close document permanently(if \a permanently = true.)
- * \param permanently - flag
- */
-void CAM_Study::closeDocument(bool permanently)
-{
- for ( ModelListIterator it( myDataModels ); it.current(); ++it )
- it.current()->close();
-
- SUIT_Study::closeDocument(permanently);
-}
-
-/*!Append data model to list.
- * \param dm - data model for adding
- */
-bool CAM_Study::appendDataModel( const CAM_DataModel* dm )
-{
- return insertDataModel( dm, myDataModels.count() );
-}
-
-/*!Insert data model \a dm after \a other
- * \param dm - data model for adding
- * \param other - previus data model for \a dm
- */
-bool CAM_Study::insertDataModel( const CAM_DataModel* dm, const CAM_DataModel* other )
-{
- int idx = myDataModels.findRef( other );
- return insertDataModel( dm, idx < 0 ? idx : idx + 1 );
-}
-
-/*!Insert data model with index \a idx. \n
- * \param dm - data model
- * \param idx - index for inserting(must be no less zero)
- * \retval true - if model added successful, else false.
- */
-bool CAM_Study::insertDataModel( const CAM_DataModel* dm, const int idx )
-{
- if ( !dm || myDataModels.findRef( dm ) != -1 )
- return false;
-
- int pos = idx < 0 ? myDataModels.count() : idx;
- myDataModels.insert( QMIN( pos, (int)myDataModels.count() ), dm );
-
- connect( dm, SIGNAL( rootChanged( const CAM_DataModel* ) ), SLOT( updateModelRoot( const CAM_DataModel* ) ) );
-
- dataModelInserted( dm );
-
- return true;
-}
-
-/*! Remove data model from list
- * \param dm data model
- * \retval true - if all ok, else false.
- */
-bool CAM_Study::removeDataModel( const CAM_DataModel* dm )
-{
- if ( !dm )
- return true;
-
- CAM_RootObject* aModelRoot = dynamic_cast<CAM_RootObject*>( dm->root() );
- if ( aModelRoot )
- aModelRoot->setDataModel( 0 );
-
- return myDataModels.remove( dm );
-}
-
-/*!Check data model contains in list.
- * \param dm - data model
- * \retval true - if data model in list, else false.
- */
-bool CAM_Study::containsDataModel( const CAM_DataModel* dm ) const
-{
- return myDataModels.contains( dm );
-}
-
-/*!Gets list of all data models.
- * \param lst - output data model list.
- */
-void CAM_Study::dataModels( ModelList& lst ) const
-{
- lst.clear();
- for ( ModelListIterator it( myDataModels ); it.current(); ++it )
- lst.append( it.current() );
-}
-
-/*! Open data model \a dModel, if it saved*/
-void CAM_Study::dataModelInserted( const CAM_DataModel* dModel )
-{
- CAM_DataModel* dm = (CAM_DataModel*)dModel;
-
- if ( isSaved() ) // need to load data model from an exisitng file?
- openDataModel( studyName(), dm );
- else // no, just need to update data model's connection to study tree
- //(some application may want to show model's root in a study tree even if a model is empty)
- dm->create( this );
- updateModelRoot( dm );
-}
-
-/*! \retval false*/
-bool CAM_Study::openDataModel( const QString&, CAM_DataModel* )
-{
- return false;
-}
-
-/*! \retval false*/
-bool CAM_Study::saveDataModel( const QString&, CAM_DataModel* )
-{
- return false;
-}
-
-/*! Public slot. Update model root.*/
-void CAM_Study::updateModelRoot( const CAM_DataModel* dm )
-{
- if ( !root() )
- return;
-
- DataObjectList childList;
- root()->children( childList );
- CAM_DataObject* curRoot = 0;
- QString aName = dm->root() ? dm->root()->name() : dm->module()->moduleName();
- int i = 0;
- for ( int n = childList.count(); i < n; i++ ) {
- if ( childList.at( i )->name() == aName ) {
- curRoot = dynamic_cast<CAM_DataObject*>( childList.at( i ) );
- break;
- }
- }
-
- if ( curRoot == dm->root() )
- return;
-
- // replacing old data model root with a new one - old root deleted here !
- if ( curRoot )
- root()->replaceChild( curRoot, dm->root(), true );
- else {
- int idx = myDataModels.findRef( dm );
- if ( idx != -1 )
- root()->insertChild( dm->root(), idx );
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef CAM_STUDY_H
-#define CAM_STUDY_H
-
-#include "CAM.h"
-
-#include "CAM_DataModel.h"
-
-#include <SUIT_Study.h>
-
-#include <qptrlist.h>
-
-#ifdef WIN32
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class CAM_Study
- Represents study for using in CAM, contains list of
- data model references from all modules. Provides
- necessary functionality for data models management.
-*/
-class CAM_EXPORT CAM_Study : public SUIT_Study
-{
- Q_OBJECT
-
-public:
- typedef QPtrList<CAM_DataModel> ModelList;
- typedef QPtrListIterator<CAM_DataModel> ModelListIterator;
-
-public:
- CAM_Study( SUIT_Application* );
- virtual ~CAM_Study();
-
- virtual void closeDocument(bool permanently = true);
-
- /** @name Insert data model methods.*/
- //@{
- bool appendDataModel( const CAM_DataModel* );
- virtual bool insertDataModel( const CAM_DataModel*, const int = -1 );
- bool insertDataModel( const CAM_DataModel*, const CAM_DataModel* );
- //@}
-
- virtual bool removeDataModel( const CAM_DataModel* );
-
- bool containsDataModel( const CAM_DataModel* ) const;
-
- void dataModels( ModelList& ) const;
-
-protected:
- virtual void dataModelInserted( const CAM_DataModel* );
- virtual bool openDataModel( const QString&, CAM_DataModel* );
- virtual bool saveDataModel( const QString&, CAM_DataModel* );
-
-protected slots:
- virtual void updateModelRoot( const CAM_DataModel* );
-
-private:
- //! Data model list
- ModelList myDataModels;
-};
-
-#ifdef WIN32
-#pragma warning( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# File : Makefile.in
-# Author : Vladimir Klyachin (OCN)
-# Module : CAM
-# $Header$
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@srcdir@/resources
-
-
-@COMMENCE@
-
-EXPORT_HEADERS= CAM_Application.h \
- CAM_DataModel.h \
- CAM_DataObject.h \
- CAM.h \
- CAM_Module.h \
- CAM_Study.h \
- CAM_RootObject.h
-
-PO_FILES = CAM_msg_en.po
-
-LIB = libCAM.la
-
-LIB_SRC= CAM_Application.cxx \
- CAM_DataModel.cxx \
- CAM_DataObject.cxx \
- CAM_Module.cxx \
- CAM_Study.cxx \
- CAM_RootObject.cxx
-
-LIB_MOC = CAM_Application.h \
- CAM_Module.h \
- CAM_Study.h \
- CAM_DataModel.h
-
-CPPFLAGS+=$(QT_INCLUDES)
-
-LDFLAGS+=$(QT_MT_LIBS)
-
-LIBS+= -lsuit -lstd
-LDFLAGSFORBIN= -lSUITApp
-
-@CONCLUDE@
-
-
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
-# would be translated to "Pub", not "Foo::Pub".
-msgid ""
-msgstr ""
-"Project-Id-Version: example-Qt-message-extraction\n"
-"POT-Creation-Date: 1999-02-23 15:38+0200\n"
-"PO-Revision-Date: 1999-02-23 15:38+0200\n"
-"Last-Translator: \n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-msgid "ERROR_TLT"
-msgstr "Error"
-
-msgid "ERROR_ACTIVATE_MODULE_MSG"
-msgstr "Failed to activate module %1"
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef DDS_H
-#define DDS_H
-
-#include <TCollection_AsciiString.hxx>
-
-#include <NCollection_DefineDataMap.hxx>
-#include <NCollection_DefineBaseCollection.hxx>
-
-#define UNIT_SYSTEM_SI "SI"
-
-typedef enum { DDS_MT_OK, DDS_MT_WARNING,
- DDS_MT_ERROR, DDS_MT_ALARM,
- DDS_MT_INFO, DDS_MT_NONE } DDS_MsgType;
-
-DEFINE_BASECOLLECTION(DDS_BaseColOfAsciiString,TCollection_AsciiString)
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "DDS_DicGroup.h"
-
-#include "DDS_Dictionary.h"
-
-#include <LDOMString.hxx>
-#include <LDOM_Element.hxx>
-
-#include <UnitsAPI.hxx>
-
-#include <TColStd_SequenceOfAsciiString.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
-
-IMPLEMENT_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
-IMPLEMENT_STANDARD_RTTIEXT(DDS_DicGroup, MMgt_TShared)
-
-/*!
- \class DDS_DicGroup
-
- This class to provide set of DDS_DicItem objects from one component.
-*/
-
-/*!
- Constructor. Create the group with name \aname.
-*/
-DDS_DicGroup::DDS_DicGroup( const TCollection_AsciiString& name )
-: MMgt_TShared(),
-myName( name ),
-myActiveSystem( UNIT_SYSTEM_SI )
-{
-}
-
-/*!
- Copy constructor.
-*/
-DDS_DicGroup::DDS_DicGroup( const DDS_DicGroup& )
-{
-}
-
-/*!
- Get the name of group (component).
-*/
-TCollection_AsciiString DDS_DicGroup::GetName() const
-{
- return myName;
-}
-
-/*!
- Returns the names list of defined unit systems.
- Parameter \atheSystems will contains the sequence of string names.
-*/
-void DDS_DicGroup::GetUnitSystems( TColStd_SequenceOfAsciiString& theSystemSeq ) const
-{
- theSystemSeq.Clear();
- for ( UnitSystemMap::Iterator it( myUnitSystem ); it.More(); it.Next() )
- {
- if ( it.Key() == TCollection_AsciiString( UNIT_SYSTEM_SI ) )
- theSystemSeq.Prepend( it.Key() );
- else
- theSystemSeq.Append( it.Key() );
- }
-}
-
-/*!
- Returns the label of unit system \aname. If unit system not found then empty string returned.
-*/
-TCollection_ExtendedString DDS_DicGroup::GetUnitSystemLabel( const TCollection_AsciiString& name ) const
-{
- TCollection_ExtendedString aLabel;
- if ( myUnitSystem.IsBound( name ) )
- aLabel = myUnitSystem.Find( name );
- return aLabel;
-}
-
-/*!
- Gets the name of active unit system.
-*/
-TCollection_AsciiString DDS_DicGroup::GetActiveUnitSystem() const
-{
- return myActiveSystem;
-}
-
-/*!
- Sets the name of active unit system.
-*/
-void DDS_DicGroup::SetActiveUnitSystem( const TCollection_AsciiString& theSystem )
-{
- if ( myUnitSystem.IsBound( theSystem ) )
- myActiveSystem = theSystem;
-}
-
-/*!
- Assignment operator.
-*/
-void DDS_DicGroup::operator=( const DDS_DicGroup& )
-{
-}
-
-/*!
- Fill the internal data structures from XML parsed structures. Internal.
-*/
-void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM_Element& theDocElement )
-{
- TCollection_AsciiString aCompName = theComponentData.getAttribute( DDS_Dictionary::KeyWord( "COMPONENT_NAME" ) );
-
- LDOM_Element systems = theComponentData.GetChildByTagName( DDS_Dictionary::KeyWord( "UNIT_SYSTEMS" ) );
- if ( !systems.isNull() )
- {
- LDOM_NodeList systemList = systems.getElementsByTagName( DDS_Dictionary::KeyWord( "UNIT_SYSTEM" ) );
- for ( Standard_Integer i = 0; i < systemList.getLength(); i++ )
- {
- //const LDOM_Element& aSystem = (const LDOM_Element &)systemList.item( i );
- LDOM_Node aNode = systemList.item( i );
- const LDOM_Element& anElem = (const LDOM_Element&) aNode;
- LDOM_Element aSystem(anElem);
- TCollection_AsciiString aName = aSystem.getAttribute( DDS_Dictionary::KeyWord( "UNIT_SYSTEM_NAME" ) );
- TCollection_ExtendedString aLabel = aSystem.getAttribute( DDS_Dictionary::KeyWord( "UNIT_SYSTEM_LABEL" ) );
-
- if ( aName.IsEmpty() )
- continue;
-
- if ( !myUnitSystem.IsBound( aName ) )
- myUnitSystem.Bind( aName, aLabel );
- }
- }
-
- if ( !myUnitSystem.IsBound( UNIT_SYSTEM_SI ) )
- {
- printf( "Warning: Mandatory unit system SI not defined in component: \"%s\". Added automaticaly", aCompName.ToCString() );
- myUnitSystem.Bind( UNIT_SYSTEM_SI, TCollection_ExtendedString( "System international" ) );
- }
-
- TColStd_SequenceOfAsciiString unitSystems;
- GetUnitSystems( unitSystems );
-
- LDOM_NodeList aData = theComponentData.getElementsByTagName( DDS_Dictionary::KeyWord( "DATUM" ) );
- if ( !aData.getLength() )
- return;
-
- for ( Standard_Integer i = 0; i < aData.getLength(); i++ )
- {
- //LDOM_Element aQuantity = (const LDOM_Element&)aData.item( i );
- LDOM_Node aNode = aData.item( i );
- const LDOM_Element& anElem = (const LDOM_Element&) aNode;
- LDOM_Element aQuantity(anElem);
-
- // 1. Attributes (id,label,units?,format?,required?)
- TCollection_AsciiString anID = aQuantity.getAttribute( DDS_Dictionary::KeyWord( "DATUM_ID" ) );
- Handle(DDS_DicItem) aDicItem = new DDS_DicItem();
-
- aDicItem->myComponent = this;
- aDicItem->FillDataMap( anID, aQuantity, theComponentData, theDocElement, unitSystems );
- myDataMap.Add( anID, aDicItem );
- }
-}
-
-/*!
- Gets dictionary item with specified identifier \atheID.
- If dictionary item not found then null handle returned.
-*/
-Handle(DDS_DicItem) DDS_DicGroup::GetDicItem( const TCollection_AsciiString& theID ) const
-{
- Handle(DDS_DicItem) aDicItem;
- // get dictionary item by id
- if ( myDataMap.Contains( theID ) )
- aDicItem = myDataMap.FindFromKey( theID );
-
- return aDicItem;
-}
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef DDS_DICGROUP_H
-#define DDS_DICGROUP_H
-
-#include "DDS.h"
-
-#include "DDS_DicItem.h"
-
-#include <MMgt_TShared.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-#include <NCollection_List.hxx>
-
-class LDOM_Element;
-class TColStd_SequenceOfAsciiString;
-
-DEFINE_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
-
-class DDS_DicGroup : public MMgt_TShared
-{
-public:
- DDS_DicGroup( const TCollection_AsciiString& );
-
- TCollection_AsciiString GetName() const;
-
- Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
-
- Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString& ) const;
- Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString& ) const;
-
- Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem() const;
- Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString& );
-
-private:
- DDS_DicGroup( const DDS_DicGroup& );
-
- void operator=( const DDS_DicGroup& );
-
- void FillDataMap( const LDOM_Element&, const LDOM_Element& );
-
-private:
- typedef NCollection_DataMap<TCollection_AsciiString,
- TCollection_ExtendedString> UnitSystemMap;
-
-private:
- TCollection_AsciiString myName;
- DDS_IndexedDataMapOfDicItems myDataMap;
- UnitSystemMap myUnitSystem;
- TCollection_AsciiString myActiveSystem;
-
- friend class DDS_Dictionary;
-
-public:
- DEFINE_STANDARD_RTTI(DDS_DicGroup)
-};
-
-DEFINE_BASECOLLECTION(DDS_BaseCollectionOfDicGroups, Handle(DDS_DicGroup))
-DEFINE_INDEXEDDATAMAP(DDS_IndexedDataMapOfDicGroups, DDS_BaseCollectionOfDicGroups,
- TCollection_AsciiString, Handle(DDS_DicGroup))
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "DDS_DicItem.h"
-#include "DDS_Dictionary.h"
-
-#include <TColStd_SequenceOfInteger.hxx>
-#include <TColStd_SequenceOfExtendedString.hxx>
-
-#include <LDOM_Text.hxx>
-#include <LDOMString.hxx>
-#include <LDOM_Element.hxx>
-
-#include <UnitsAPI.hxx>
-#include <Units_Dimensions.hxx>
-
-#include <TColStd_MapOfReal.hxx>
-#include <TColStd_SequenceOfAsciiString.hxx>
-
-IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
-IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared)
-
-/*!
- \class DDS_DicItem
-
- This class to provide information about datum (phisical characteristic parameter).
-*/
-
-/*!
- Constructor. Creates the instance of empty dictionary item.
-*/
-DDS_DicItem::DDS_DicItem()
-: myType( 0 ),
-myDefValue( 0 ),
-myMax( 0 ),
-myMin( 0 ),
-myMinZoom( 0.1 ),
-myMaxZoom( 10 ),
-myZoomOrder( 2 )
-{
-}
-
-/*!
- Copy constructor. Internal.
-*/
-DDS_DicItem::DDS_DicItem( const DDS_DicItem& )
-{
-}
-
-/*!
- Assignment operator. Internal.
-*/
-void DDS_DicItem::operator=( const DDS_DicItem& )
-{
-}
-
-/*!
- Gets the identifier of parameter.
-*/
-TCollection_AsciiString DDS_DicItem::GetId() const
-{
- return myId;
-}
-
-/*!
- Gets the type of parameter.
-*/
-DDS_DicItem::Type DDS_DicItem::GetType() const
-{
- return (DDS_DicItem::Type)myType;
-}
-
-/*!
- Gets the label of the parameter.
-*/
-TCollection_ExtendedString DDS_DicItem::GetLabel() const
-{
- return myLabel;
-}
-
-/*!
- Gets the filter (regular expression) for the parameter values.
-*/
-TCollection_ExtendedString DDS_DicItem::GetFilter() const
-{
- return myFilter;
-}
-
-/*!
- Gets the Required attribute of the parameter.
-*/
-TCollection_ExtendedString DDS_DicItem::GetRequired() const
-{
- return myRequired;
-}
-
-/*!
- Gets the wrong value warning level of the parameter.
-*/
-DDS_MsgType DDS_DicItem::GetWarningLevel() const
-{
- return (DDS_MsgType)myWarnLevel;
-}
-
-/*!
- Gets the long description of the parameter.
-*/
-TCollection_ExtendedString DDS_DicItem::GetLongDescription() const
-{
- return myLongDescr;
-}
-
-/*!
- Gets the short description of the parameter.
-*/
-TCollection_ExtendedString DDS_DicItem::GetShortDescription() const
-{
- return myShortDescr;
-}
-
-/*!
- Gets the name of component - owner of parameter.
-*/
-TCollection_AsciiString DDS_DicItem::GetComponent() const
-{
- TCollection_AsciiString aCompName;
- Handle(DDS_DicGroup) aComponent = Handle(DDS_DicGroup)::DownCast(myComponent);
- if ( !aComponent.IsNull() )
- aCompName = aComponent->GetName();
- return aCompName;
-}
-
-/*!
- Gets the parameter unit of measure for active unit system.
-*/
-TCollection_AsciiString DDS_DicItem::GetUnits() const
-{
- return GetUnits( GetActiveUnitSystem() );
-}
-
-/*!
- Gets the parameter unit of measure for specified unit system \atheSystem.
- If specified unit system doesn't exist then empty string returned.
-*/
-TCollection_AsciiString DDS_DicItem::GetUnits( const UnitSystem& theSystem ) const
-{
- TCollection_AsciiString anUnits;
- UnitData* unitData = GetUnitData( theSystem );
- if ( unitData )
- anUnits = unitData->myUnits;
- return anUnits;
-}
-
-/*!
- Gets the minimum value of parameter for active unit system.
- Returned value converted to SI.
-*/
-Standard_Real DDS_DicItem::GetMinValue() const
-{
- return GetMinValue( GetActiveUnitSystem() );
-}
-
-/*!
- Gets the minimum value of parameter for specified unit system \atheSystem.
- Returned value converted to SI.
-*/
-Standard_Real DDS_DicItem::GetMinValue( const UnitSystem& theUnitsSystem ) const
-{
- return FromSI( myMin, theUnitsSystem );
-}
-
-/*!
- Gets the maximum value of parameter for active unit system.
- Returned value converted to SI.
-*/
-Standard_Real DDS_DicItem::GetMaxValue() const
-{
- return GetMaxValue( GetActiveUnitSystem() );
-}
-
-/*!
- Gets the maximum value of parameter for specified unit system \atheSystem.
- Returned value converted to SI.
-*/
-Standard_Real DDS_DicItem::GetMaxValue( const UnitSystem& theUnitsSystem ) const
-{
- return FromSI( myMax, theUnitsSystem );
-}
-
-/*!
- Gets the precision (number of digit after decimal point) of parameter for active unit system.
-*/
-Standard_Integer DDS_DicItem::GetPrecision() const
-{
- return GetPrecision( GetActiveUnitSystem() );
-}
-
-/*!
- Gets the precision (number of digit after decimal point) of parameter for specified
- unit system \atheSystem. If specified unit system doesn't exist then zero returned.
-*/
-Standard_Integer DDS_DicItem::GetPrecision( const UnitSystem& theSystem ) const
-{
- Standard_Integer aRes = 0;
- UnitData* unitData = GetUnitData( theSystem );
- if ( unitData )
- aRes = unitData->myPrecision;
- return aRes;
-}
-
-/*!
- Gets the default value of parameter for active unit system. Default value returned as string.
- If type of value is numeric (Float or Integer) and default value defined then returned number
- converted to SI.
-*/
-TCollection_ExtendedString DDS_DicItem::GetDefaultValue() const
-{
- return GetDefaultValue( GetActiveUnitSystem() );
-}
-
-/*!
- Gets the default value of parameter for specified unit system \atheSystem. Default value returned
- as string. If type of value is numeric (Float or Integer) and default value defined then returned
- number converted to SI.
-*/
-TCollection_ExtendedString DDS_DicItem::GetDefaultValue( const UnitSystem& theSystem ) const
-{
- if ( !myDefString.Length() )
- return myDefString;
-
- TCollection_ExtendedString aStr;
-
- switch ( myType )
- {
- case Float:
- case Integer:
- aStr = FromSI( myDefValue, theSystem );
- break;
- case List:
- case String:
- aStr = myDefString;
- break;
- default:
- break;
- }
- return aStr;
-}
-
-/*!
- Gets the format string of parameter for active unit system. If argument \atheCanonical
- is true then format string will be reduced to sprintf() specification (without extra
- non standard qualifiers).
-*/
-TCollection_AsciiString DDS_DicItem::GetFormat( const Standard_Boolean theCanonical ) const
-{
- return GetFormat( GetActiveUnitSystem(), theCanonical );
-}
-
-/*!
- Gets the format string of parameter for specified unit system \atheSystem. If argument
- \atheCanonical is true then format string will be reduced to sprintf() specification
- (without extra non standard qualifiers).
-*/
-TCollection_AsciiString DDS_DicItem::GetFormat( const UnitSystem& theSystem,
- const Standard_Boolean theCanonical ) const
-{
- TCollection_AsciiString aFormat;
- UnitData* unitData = GetUnitData( theSystem );
- if ( unitData )
- aFormat = unitData->myFormat;
-
- if ( theCanonical && aFormat.Length() > 1 )
- {
- static TCollection_AsciiString f;
- f = aFormat;
- Standard_Boolean isRemoved = false;
- while ( !isRemoved )
- {
- char ch = f.Value( f.Length() - 1 );
- if ( ( ch != '%' && ch != '.' && !IsDigit( ch ) ) && f.Length() > 1 )
- f.Remove( f.Length() - 1 );
- else
- isRemoved = true;
- }
- aFormat = f;
- }
-
- return aFormat;
-}
-
-/*!
- Gets name of a list referenced by the parameter. This string is empty if the list
- refernce is not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
-*/
-TCollection_ExtendedString DDS_DicItem::GetNameOfValues() const
-{
- return myListName;
-}
-
-/*!
- Gets item names and item ids of a list referenced by the parameter. This sequences is empty if
- the list reference is not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
-*/
-Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings,
- Handle(TColStd_HArray1OfInteger)& theIntegers ) const
-{
- theStrings = myListRef;
- theIntegers = myListRefID;
- return !theIntegers.IsNull() && !theStrings.IsNull();
-}
-
-/*!
- Gets item names, item ids and item icons of a list referenced by the parameter. This sequences is empty
- if the list reference is not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
-*/
-Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings,
- Handle(TColStd_HArray1OfInteger)& theIntegers,
- Handle(TColStd_HArray1OfExtendedString)& theIcons ) const
-{
- theStrings = myListRef;
- theIntegers = myListRefID;
- theIcons = myListRefIcons;
- return !theIntegers.IsNull() && !theStrings.IsNull() && !theIcons.IsNull();
-}
-
-
-/*!
- Gets special values of the parameter.
-*/
-Standard_Boolean DDS_DicItem::GetSpecialValues( TColStd_MapOfReal& theMap ) const
-{
- theMap.Clear();
- if ( !myListRef.IsNull() )
- {
- for ( Standard_Integer i = myListRef->Lower(); i <= myListRef->Upper(); i++ )
- {
- if ( myListRef->Value( i ).IsAscii() )
- {
- TCollection_AsciiString aStr( myListRef->Value( i ) );
- if ( aStr.IsRealValue() )
- theMap.Add( aStr.RealValue() );
- }
- }
- }
-
- return theMap.Extent() > 0;
-}
-
-/*!
- Gets minimum value of lateral zooming
-*/
-Standard_Real DDS_DicItem::GetMinZoom() const
-{
- return myMinZoom;
-}
-
-/*!
- Gets maximum value of lateral zooming
-*/
-Standard_Real DDS_DicItem::GetMaxZoom() const
-{
- return myMaxZoom;
-}
-
-/*!
- Gets order of lateral zooming
-*/
-Standard_Real DDS_DicItem::GetZoomOrder() const
-{
- return myZoomOrder;
-}
-
-/*!
- Convert value \atheVal to default SI units according to active unit system.
-*/
-Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal ) const
-{
- return ToSI( theVal, GetActiveUnitSystem() );
-}
-
-/*!
- Convert value \atheVal from default SI units according to active unit system.
-*/
-Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal ) const
-{
- return FromSI( theVal, GetActiveUnitSystem() );
-}
-
-/*!
- Convert value to default SI units according to unit system \atheUnitsSystem.
-*/
-Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const
-{
- Standard_Real aRes = theVal;
- UnitData* anUnitData = GetUnitData( theUnitsSystem );
- if ( anUnitData )
- aRes = anUnitData->myZero + aRes * anUnitData->myScale;
- return aRes;
-}
-
-/*!
- Convert value from default SI units according to unit system \atheUnitsSystem.
-*/
-Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const
-{
- Standard_Real aRes = theVal;
- UnitData* anUnitData = GetUnitData( theUnitsSystem );
- if ( anUnitData )
- aRes = ( aRes - anUnitData->myZero ) / anUnitData->myScale;
- return aRes;
-}
-
-/*!
- Returns 'true' if data specified by \aflag exist.
-*/
-Standard_Boolean DDS_DicItem::HasData( const Standard_Integer flag ) const
-{
- return ( myData & flag ) == flag;
-}
-
-/*!
- Returns options for specified name \aname. If option not found then empty string returned.
-*/
-TCollection_ExtendedString DDS_DicItem::GetOption( const TCollection_AsciiString& name ) const
-{
- TCollection_ExtendedString res;
- if ( myOptions.IsBound( name ) )
- res = myOptions.Find( name );
- return res;
-}
-
-/*!
- Returns names list of existing options in the specified sequence \anames.
- If list not empty retunrs 'true' otherwise 'false'.
-*/
-Standard_Boolean DDS_DicItem::GetOptionNames( TColStd_SequenceOfAsciiString& names ) const
-{
- names.Clear();
-
- for ( OptionsMap::Iterator it( myOptions ); it.More(); it.Next() )
- names.Append( it.Key() );
-
- return !names.IsEmpty();
-}
-
-
-/*!
- Parse record in XML file and retrieve information relevant for this dictionary item
-*/
-void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element& theDatum,
- const LDOM_Element& theCompElement, const LDOM_Element& theDocElement,
- const TColStd_SequenceOfAsciiString& theSystems )
-{
- TCollection_AsciiString aLabel = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_LABEL" ) );
- TCollection_AsciiString aFormat = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_FORMAT" ) );
- TCollection_AsciiString aFilter = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_FILTER" ) );
- TCollection_AsciiString aRequired = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_REQUIRED" ) );
-
- TCollection_AsciiString aBaseKeyWord = DDS_Dictionary::KeyWord( "DATUM_UNITS" );
-
- for ( Standard_Integer j = 1; j <= theSystems.Length(); j++ )
- {
- UnitSystem anUnitSystem = theSystems.Value( j );
- if ( !anUnitSystem.Length() )
- continue;
-
- TCollection_AsciiString aUnitKeyword = anUnitSystem + aBaseKeyWord;
-
- if ( !myUnitData.IsBound( anUnitSystem ) )
- myUnitData.Bind( anUnitSystem, UnitData() );
-
- UnitData& anUnitData = myUnitData.ChangeFind( anUnitSystem );
- anUnitData.myUnits = theDatum.getAttribute( LDOMString( aUnitKeyword.ToCString() ) );
- }
-
- if ( theSystems.Length() && myUnitData.IsBound( theSystems.First() ) &&
- !myUnitData.Find( theSystems.First() ).myUnits.Length() )
- {
- TCollection_AsciiString units = theDatum.getAttribute( LDOMString( aBaseKeyWord.ToCString() ) );
- if ( units.Length() )
- myUnitData.ChangeFind( theSystems.First() ).myUnits = units;
- }
-
- TCollection_AsciiString units;
- for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator iter( myUnitData ); iter.More() && units.IsEmpty(); iter.Next() )
- units = iter.Value().myUnits;
-
- for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator itr( myUnitData ); itr.More(); itr.Next() )
- {
- UnitData& dataUnits = itr.ChangeValue();
- if ( dataUnits.myUnits.IsEmpty() )
- dataUnits.myUnits = units;
- }
-
- // 2. Elements ( domain, description )
- Standard_Real aRealMinV = 0;
- Standard_Real aRealMaxV = 0;
- Standard_Real aRealDefV = 0;
-
- TCollection_AsciiString aType;
-
- DDS_MsgType aWrongValue = DDS_MT_NONE;
- DDS_DicItem::Type aEnumType = DDS_DicItem::Unknown;
-
- TCollection_AsciiString aMinV;
- TCollection_AsciiString aMaxV;
- TCollection_AsciiString aDefV;
- TCollection_AsciiString aListName;
-
- TCollection_AsciiString aLongD;
- TCollection_AsciiString aShortD;
-
- TColStd_SequenceOfInteger aSeqOfValueID;
- TColStd_SequenceOfExtendedString aSeqOfValue;
- TColStd_SequenceOfExtendedString aSeqOfValueIconName;
-
- // Presentation
- Standard_Real aMinZoom = 0;
- Standard_Real aMaxZoom = 0;
- Standard_Real aZoomOrder = 0;
-
- // Datum::Reports tags (if any)
- LDOM_Element aWLev = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "WARNING_LEVEL" ) );
- if ( !aWLev.isNull() )
- {
- TCollection_AsciiString aWrongValWL = aWLev.getAttribute( DDS_Dictionary::KeyWord( "WRONG_VALUE" ) );
- if ( aWrongValWL.IsEqual( "Info" ) )
- aWrongValue = DDS_MT_INFO;
- else if ( aWrongValWL.IsEqual( "Warning" ) )
- aWrongValue = DDS_MT_WARNING;
- else if ( aWrongValWL.IsEqual( "Alarm" ) )
- aWrongValue = DDS_MT_ALARM;
- else if ( aWrongValWL.IsEqual( "Error" ) )
- aWrongValue = DDS_MT_ERROR;
- }
-
- // Datum::Presentation
- LDOM_Element aPrs = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "PRS" ) );
- if ( !aPrs.isNull() )
- {
- LDOM_Element aLateralZoom = aPrs.GetChildByTagName( DDS_Dictionary::KeyWord( "LATERAL_ZOOM" ) );
- if ( !aLateralZoom.isNull() )
- {
- TCollection_AsciiString aMinZoomStr = aLateralZoom.getAttribute( DDS_Dictionary::KeyWord( "LZ_MINV" ) );
- TCollection_AsciiString aMaxZoomStr = aLateralZoom.getAttribute( DDS_Dictionary::KeyWord( "LZ_MAXV" ) );
- TCollection_AsciiString aZoomOrderStr = aLateralZoom.getAttribute( DDS_Dictionary::KeyWord( "LZ_ORDER" ) );
-
- aMinZoomStr.RemoveAll( ' ' );
- if ( aMinZoomStr.IsRealValue() )
- aMinZoom = aMinZoomStr.RealValue();
-
- aMaxZoomStr.RemoveAll( ' ' );
- if ( aMaxZoomStr.IsRealValue() )
- aMaxZoom = aMaxZoomStr.RealValue();
-
- aZoomOrderStr.RemoveAll( ' ' );
- if ( aZoomOrderStr.IsRealValue() )
- aZoomOrder = aZoomOrderStr.RealValue();
- }
- }
-
- // Quantity::Domain record as the only child of that tag name
- LDOM_Element aDomain = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "DY_DOMAIN" ) );
- if ( !aDomain.isNull() )
- {
- LDOM_Element aValueDescr = aDomain.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_DESCR" ) );
- if ( !aValueDescr.isNull() )
- {
- // read: valueDescr? (type?,min?,max?,default?)
- aType = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_TYPE" ) );
- if ( aType.IsEqual( "String" ) )
- aEnumType = String;
- else if ( aType.IsEqual( "Float" ) )
- aEnumType = Float;
- else if ( aType.IsEqual( "Integer" ) )
- aEnumType = Integer;
-
- if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MINV" ) ).isNull() )
- myData |= MinValue;
- aMinV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MINV" ) );
- aMinV.RemoveAll( ' ' );
- if ( aMinV.IsRealValue() )
- aRealMinV = aMinV.RealValue();
- if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MAXV" ) ).isNull() )
- myData |= MaxValue;
- aMaxV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MAXV" ) );
- aMaxV.RemoveAll( ' ' );
- if ( aMaxV.IsRealValue() )
- aRealMaxV = aMaxV.RealValue();
- aDefV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) );
- if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_DEFV" ) ).isNull() )
- myData |= DefaultValue;
-
- aDefV.RemoveAll( ' ' );
- if ( aDefV.IsRealValue() )
- aRealDefV = aDefV.RealValue();
-
- TCollection_AsciiString aSpecVal = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_SPEC" ) );
- Split( aSpecVal, myListRef );
- }
- else
- {
- // read: listRef? (list?)
- LDOM_Element aListRef = aDomain.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_REF" ) );
- if ( !aListRef.isNull() )
- {
- aType = "List";
- aEnumType = List;
- LDOMString aListId = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VLR_LIST" ) );
- aDefV = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) );
- aDefV.RemoveAll( ' ' );
- LDOM_Element foundListItem;
- for ( LDOM_Element aListItem = theCompElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
- aListItem != NULL && foundListItem == NULL; aListItem = aListItem.GetSiblingByTagName() )
- {
- if ( aListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) )
- foundListItem = aListItem;
-
- }
- for ( LDOM_Element aLstItem = theDocElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
- aLstItem != NULL && foundListItem == NULL; aLstItem = aLstItem.GetSiblingByTagName() )
- {
- if ( aLstItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) )
- foundListItem = aLstItem;
- }
-
- if ( foundListItem != NULL )
- {
- // The appropriate list of values is found: store the list name
- aListName = foundListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_NAME" ) );
- // Iteration through the list of values
- LDOM_Element aListItemValue = foundListItem.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUE" ) );
- while ( aListItemValue != NULL )
- {
- // read value ID
- TCollection_AsciiString aListValueID = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEID" ) );
- if ( aListValueID.IsIntegerValue() )
- {
- // Read the text in the element "value"
- //LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild();
- LDOM_Node aNode = aListItemValue.getFirstChild();
- const LDOM_Text& aText = (const LDOM_Text&) aNode;
- LDOM_Text aListItemTxt(aText);
- if ( !aListItemTxt.isNull() )
- {
- // adding ID and text value to sequence
- aSeqOfValueID.Append( aListValueID.IntegerValue() );
- aSeqOfValue.Append( aListItemTxt.getData() );
- // adding icon file name (optional) to sequence
- TCollection_ExtendedString aListValueIcon = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEICON" ) );
- aSeqOfValueIconName.Append( aListValueIcon );
- }
- aListItemValue = aListItemValue.GetSiblingByTagName();
- }
- }
- }
- }
- }
- }
-
- // Quantity::Description record as the only child of that tag name
- LDOM_Element aDescr = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "DESCR" ) );
- if ( !aDescr.isNull() )
- {
- // short description (#PCDATA)*
- LDOM_Element aShDescr = aDescr.GetChildByTagName( DDS_Dictionary::KeyWord( "SHORT_D" ) );
- if ( !aShDescr.isNull() )
- {
- // text is always a sub-node of element, containing it
- //LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild();
- LDOM_Node aNode = aShDescr.getFirstChild();
- const LDOM_Text& aText = (const LDOM_Text&) aNode;
- LDOM_Text aShDescrTxt(aText);
- if ( !aShDescrTxt.isNull() )
- aShortD = aShDescrTxt.getData();
- }
-
- // long description (#PCDATA)*
- LDOM_Element aLDescr = aDescr.GetChildByTagName( DDS_Dictionary::KeyWord( "LONG_D" ) );
- if ( !aLDescr.isNull() )
- {
- // text is always a sub-node of element, containing it
- //LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild();
- LDOM_Node aNode = aLDescr.getFirstChild();
- const LDOM_Text& aText = (const LDOM_Text&) aNode;
- LDOM_Text aLDescrTxt(aText);
- if ( !aLDescrTxt.isNull() )
- aLongD = aLDescrTxt.getData();
- }
- }
-
- // Quantity::Options
- LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) );
- if ( !anOpt.isNull() )
- {
- LDOM_NodeList anOptions = anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
- for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ )
- {
- LDOM_Node node = anOptions.item( oi );
- if ( node.getNodeType() != LDOM_Node::ELEMENT_NODE )
- continue;
-
- LDOM_Element& elem = (LDOM_Element&)node;
- TCollection_AsciiString name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
-
- TCollection_ExtendedString value;
- const LDOM_Text& aText = (const LDOM_Text&)elem.getFirstChild();
- LDOM_Text anOptTxt( aText );
- if ( !anOptTxt.isNull() )
- value = anOptTxt.getData();
-
- if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) )
- myOptions.Bind( name, value );
- }
- }
-
- NCollection_DataMap<UnitSystem, Handle(Units_Dimensions)> aDimMap;
-
- for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
- {
- UnitData& anUnitData = it.ChangeValue();
-
- // check units
- anUnitData.myZero = 0.;
- anUnitData.myScale = 1.;
- try {
- Standard_CString aUnitDataStr;
- aUnitDataStr = (Standard_CString)anUnitData.myUnits.ToCString();
- if ( anUnitData.myUnits.ToCString()[0] && strcmp( anUnitData.myUnits.ToCString(), "%" ) )
- {
- Handle(Units_Dimensions) aDim;
- anUnitData.myZero = UnitsAPI::AnyToSI( 0.0, aUnitDataStr, aDim );
- anUnitData.myScale = UnitsAPI::AnyToSI( 1.0, aUnitDataStr, aDim ) - anUnitData.myZero;
- UnitsAPI::AnyFromSI( 1.0, aUnitDataStr );
- if ( !aDimMap.IsBound( it.Key() ) )
- aDimMap.Bind( it.Key(), aDim );
- }
- else if ( anUnitData.myUnits.ToCString()[0] ) // treat '%' as unit with scale 100
- anUnitData.myScale = 0.01;
- }
- catch( Standard_Failure ) {
- anUnitData.myUnits.Clear();
- }
-
- Handle(Units_Dimensions) aPrev;
- Standard_Boolean aStatus = Standard_True;
- for ( NCollection_DataMap<UnitSystem, Handle(Units_Dimensions)>::Iterator itr( aDimMap );
- itr.More() && aStatus; itr.Next() )
- {
- if ( itr.Value().IsNull() )
- continue;
-
- if ( aPrev.IsNull() )
- aPrev = itr.Value();
-
- aStatus = aPrev->IsEqual( itr.Value() );
- }
-
- if ( !aStatus )
- printf( "Error in DataDictionary: Different dimensions for %s item", theID.ToCString() );
- }
-
- myId = theID;
- myType = aEnumType;
- myWarnLevel = aWrongValue;
- myLabel = aLabel.ToCString();
- myFilter = aFilter.ToCString();
- myLongDescr = aLongD.ToCString();
- myShortDescr = aShortD.ToCString();
- myMin = aRealMinV;
- myMax = aRealMaxV;
- myDefValue = aRealDefV;
- myDefString = aDefV.ToCString();
- myRequired = aRequired.ToCString();
- myListName = aListName.ToCString();
- myMinZoom = aMinZoom;
- myMaxZoom = aMaxZoom;
- myZoomOrder = aZoomOrder;
-
- // prepare formats
- PrepareFormats( aFormat );
-
- const Standard_Integer aLength = aSeqOfValue.Length();
- if ( aLength > 0 )
- {
- myListRef = new TColStd_HArray1OfExtendedString( 1, aLength );
- myListRefID = new TColStd_HArray1OfInteger( 1, aLength );
- myListRefIcons = new TColStd_HArray1OfExtendedString( 1, aLength );
- for ( Standard_Integer i = aLength; i > 0; i-- )
- {
- myListRef->ChangeValue( i ) = aSeqOfValue.Value( i );
- myListRefID->ChangeValue( i ) = aSeqOfValueID.Value( i );
- myListRefIcons->ChangeValue( i ) = aSeqOfValueIconName.Value( i );
- }
- }
-
- if ( myType == List && myDefString == "" && !myListRef.IsNull() && myListRef->Length() > 0 )
- myDefString = myListRef->Value( myListRef->Lower() );
-}
-
-/*!
- Returns default formats for each unit systems
-*/
-void DDS_DicItem::GetDefaultFormat()
-{
- for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
- {
- UnitData& anUnitData = it.ChangeValue();
-
- switch ( myType )
- {
- case Integer:
- anUnitData.myFormat = "%d";
- break;
- case Float:
- anUnitData.myFormat = "%g";
- break;
- case String:
- default:
- anUnitData.myFormat.Clear();
- break;;
- }
- }
-}
-
-/*!
- Returns format for the string
-*/
-void DDS_DicItem::GetStringFormat( const TCollection_AsciiString& theFlags,
- const TCollection_AsciiString& theWidth,
- const TCollection_AsciiString& thePrecision,
- const TCollection_AsciiString& theTypePrefix,
- TCollection_AsciiString& theFormat )
-{
- theFormat = "%";
- theFormat += theFlags;
- theFormat += theWidth;
-
- if ( !thePrecision.IsEmpty() )
- {
- theFormat += ".";
- theFormat += thePrecision;
- }
-
- theFormat += theTypePrefix;
- theFormat += "s";
-}
-
-/*!
- Returns format for the integer
-*/
-void DDS_DicItem::GetIntegerFormat( const TCollection_AsciiString& theFlags,
- const TCollection_AsciiString& theWidth,
- const TCollection_AsciiString& thePrecision,
- const TCollection_AsciiString& theTypePrefix,
- const Standard_Character theType,
- TCollection_AsciiString& theFormat )
-{
- Standard_Integer aPrecision = 0;
- if ( !thePrecision.IsEmpty() )
- aPrecision = thePrecision.IntegerValue();
- Standard_Integer aWidth = 0;
-
- if ( !theWidth.IsEmpty() )
- aWidth = theWidth.IntegerValue();
-
- if ( !thePrecision.IsEmpty() && aPrecision < 0 )
- {
- // possible value 0.1 will be 10.0
- aWidth -= aPrecision;
- aPrecision = 0;
- }
-
- if ( !thePrecision.IsEmpty() && aPrecision > ( aWidth - 2 ) )
- aWidth = aPrecision + 2;
-
- theFormat = "%";
-
- theFormat += theFlags;
- if ( !theWidth.IsEmpty() )
- theFormat += aWidth;
-
- theFormat += theTypePrefix;
- theFormat += theType;
-}
-
-/*!
- Returns format for the float
-*/
-void DDS_DicItem::GetFloatFormat( const TCollection_AsciiString& theFlags,
- const TCollection_AsciiString& theWidth,
- const TCollection_AsciiString& thePrecision,
- const TCollection_AsciiString& theTypePrefix,
- const Standard_Character theType,
- TCollection_AsciiString& theFormat )
-{
- Standard_Integer aPrecision = 0;
- if ( !thePrecision.IsEmpty() )
- aPrecision = thePrecision.IntegerValue();
- Standard_Integer aWidth = 0;
-
- if (!theWidth.IsEmpty() )
- aWidth = theWidth.IntegerValue();
-
- if (!thePrecision.IsEmpty() && aPrecision < 0 )
- {
- // possible value 0.1 will be 10.0
- aWidth -= aPrecision;
- aPrecision = 0;
- }
-
- if ( !thePrecision.IsEmpty() && aPrecision > ( aWidth - 2 ) )
- {
- aWidth = aPrecision + 2;
- }
-
- theFormat = "%";
- theFormat += theFlags;
-
- if ( !theWidth.IsEmpty() )
- theFormat += aWidth;
-
- if ( !thePrecision.IsEmpty() )
- {
- theFormat += ".";
- theFormat += aPrecision;
- }
-
- theFormat += theTypePrefix;
- theFormat += theType;
-}
-
-/*!
- Prepares formats for each unit systems
-*/
-void DDS_DicItem::PrepareFormats( const TCollection_AsciiString& theFormat )
-{
- for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
- {
- UnitData& anUnitData = it.ChangeValue();
-
- anUnitData.myFormat = theFormat;
- anUnitData.myPrecision = 0;
- }
-
- TCollection_AsciiString aPrecisionStr;
- if ( theFormat.IsEmpty() && myType == List )
- return;
-
- // checking % presenting
- if ( *theFormat.ToCString() != '%' )
- {
- GetDefaultFormat();
- return;
- }
-
- TCollection_AsciiString aStr = ( theFormat.ToCString() + 1 );
- Standard_Character aType = aStr.Value( aStr.Length() );
-
- if ( ( aType != 's' && myType == String ) ||
- ( aType != 'd' && myType == Integer ) ||
- ( aType != 'f' && aType != 'g' && aType != 'e' && aType != 'G' && aType != 'E' && myType == Float ) )
- {
- GetDefaultFormat();
- return;
- }
-
- // removing type character
- aStr.Trunc( aStr.Length() - 1 );
-
- TCollection_AsciiString aFlags;
- while ( !aStr.IsEmpty() && aStr.Value( 1 ) != '.' && ( aStr.Value( 1 ) < '0' || aStr.Value( 1 ) > '9' ) )
- {
- aFlags = aFlags + aStr.Value( 1 );
- aStr.Remove( 1 );
- }
-
- Standard_Integer aPos = 1;
- while ( aPos <= aStr.Length() && ( aStr.Value( aPos ) == '.' ||
- ( aStr.Value( aPos ) >= '0' && aStr.Value( aPos ) <= '9' ) ) )
- aPos++;
-
- TCollection_AsciiString aTypePrefix;
- if ( aPos <= aStr.Length() )
- {
- aTypePrefix = aStr.SubString( aPos, aStr.Length() );
- aStr.Trunc( aPos - 1 );
- }
-
- Standard_Integer aBasePrecision = 0;
-
- // taking width and precision
- TCollection_AsciiString aPrecision;
-
- aPos = aStr.Search( "." );
- if ( aPos >= 0 )
- {
- // aPrecision is defined
- aPrecision = aStr.Split( aPos );
- aStr.Remove( aStr.Length() );
- if ( !aPrecision.IsEmpty() )
- {
- if ( !aPrecision.IsIntegerValue() )
- {
- GetDefaultFormat();
- return;
- }
- else
- {
- aPrecisionStr = aPrecision;
- aBasePrecision = aPrecision.IntegerValue();
- }
- }
- }
-
- if ( !aStr.IsEmpty() && !aStr.IsIntegerValue() )
- {
- GetDefaultFormat();
- return;
- }
-
- NCollection_DataMap<UnitSystem, UnitData>::Iterator itr;
-
- switch ( myType )
- {
- case String:
- for ( itr.Initialize( myUnitData ); itr.More(); itr.Next() )
- {
- if ( aType != 'f' && aType != 'g' && aType != 'e' && aType != 'G' && aType != 'E' )
- GetStringFormat( aFlags, aStr, aPrecisionStr, aTypePrefix, itr.ChangeValue().myFormat );
- }
- break;
- case Float:
- case Integer:
- for ( itr.Initialize( myUnitData ); itr.More(); itr.Next() )
- {
- UnitData& anUnitData = itr.ChangeValue();
- Standard_Integer aAmendment =
- (Standard_Integer)log10( 10.0 / DDS_Dictionary::FromSI( 10.0, anUnitData.myUnits.ToCString() ) );
- anUnitData.myPrecision = aBasePrecision + aAmendment;
- aPrecisionStr = TCollection_AsciiString( anUnitData.myPrecision );
-
- // create a formats
- if ( myType == Integer )
- GetIntegerFormat( aFlags, aStr, aPrecisionStr, aTypePrefix, aType, anUnitData.myFormat );
- else
- GetFloatFormat( aFlags, aStr, aPrecisionStr, aTypePrefix, aType, anUnitData.myFormat );
- }
- break;
- default:;
- GetDefaultFormat();
- break;
- }
-}
-
-/*!
- Split the string \atheStr by spaces and returns substrings in array \aaRes.
-*/
-void DDS_DicItem::Split( const TCollection_AsciiString& theStr, Handle(TColStd_HArray1OfExtendedString)& aRes )
-{
- aRes.Nullify();
-
- if ( theStr.Length() > 0 )
- {
- TCollection_AsciiString aStr = theStr;
- TColStd_SequenceOfAsciiString aSeq;
- Standard_Integer anIndex = aStr.SearchFromEnd( (Standard_CString)" " );
- while( anIndex > 1 )
- {
- TCollection_AsciiString tmpStr = aStr.Split( anIndex - 1 );
- tmpStr.RemoveAll( ( Standard_Character )' ' );
- if ( tmpStr.Length() > 0 )
- aSeq.Append( tmpStr );
- anIndex = aStr.SearchFromEnd( (Standard_CString)" " );
- }
-
- aStr.RemoveAll( ( Standard_Character )' ' );
- if ( aStr.Length() > 0 )
- aSeq.Append( aStr );
-
- if ( aSeq.Length() > 0 )
- {
- aRes = new TColStd_HArray1OfExtendedString( 1, aSeq.Length() );
- for ( int i = 1, n = aSeq.Length(); i <= n; i++ )
- aRes->ChangeValue( i ) = aSeq( i );
- }
- }
-}
-
-/*!
- Returns unit structure for given unit system \asys.
-*/
-DDS_DicItem::UnitData* DDS_DicItem::GetUnitData( const UnitSystem& sys ) const
-{
- UnitData* unit = 0;
-
- if ( myUnitData.IsBound( sys ) )
- unit = (UnitData*)&myUnitData.Find( sys );
-
- return unit;
-}
-
-/*!
- Gets the active unit system.
-*/
-DDS_DicItem::UnitSystem DDS_DicItem::GetActiveUnitSystem() const
-{
- UnitSystem aSystem;
- Handle(DDS_DicGroup) aComponent = Handle(DDS_DicGroup)::DownCast(myComponent);
- if ( !aComponent.IsNull() )
- aSystem = aComponent->GetActiveUnitSystem();
- return aSystem;
-}
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef DDS_DICITEM_H
-#define DDS_DICITEM_H
-
-#include "DDS.h"
-
-#include <MMgt_TShared.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-#include <TColStd_HArray1OfInteger.hxx>
-#include <TColStd_HArray1OfExtendedString.hxx>
-
-#include <NCollection_DataMap.hxx>
-#include <NCollection_DefineIndexedDataMap.hxx>
-
-class LDOM_Element;
-class DDS_Dictionary;
-class TColStd_MapOfReal;
-class TColStd_SequenceOfInteger;
-class TColStd_SequenceOfAsciiString;
-class TColStd_SequenceOfExtendedString;
-
-// Class, containing all information about one parameter:
-// unique : id
-// obligative: label, type, short description, required
-// optional : format, units,
-// min value, max value, default value.
-
-class DDS_DicItem : public MMgt_TShared
-{
-public:
- /*! Enum describes type of datum value */
- enum Type
- {
- String, //!< String type of value
- Float, //!< Real (double) numeric type of value
- Integer, //!< Integer (int) numeric type of value
- List, //!< List type of enumerable value
- Unknown //!< Unknown or undefined type of value
- };
-
- /*! Enum describes the flags for existance of domain data */
- enum Data
- {
- MinValue = 0x01, //!< Flag of minimum value definition existence
- MaxValue = 0x02, //!< Flag of maximum value definition existence
- DefaultValue = 0x04 //!< Flag of default value definition existence
- };
-
- // This struct is intended for map of Format, Units, Precision and Scale
- struct UnitData
- {
- Standard_Real myZero;
- Standard_Real myScale;
- TCollection_AsciiString myUnits;
- TCollection_AsciiString myFormat;
- Standard_Integer myPrecision;
- };
-
- typedef TCollection_AsciiString UnitSystem;
-
-public:
- DDS_DicItem();
-
- Standard_EXPORT TCollection_AsciiString GetId() const;
- Standard_EXPORT DDS_DicItem::Type GetType() const;
- Standard_EXPORT TCollection_ExtendedString GetLabel() const;
- Standard_EXPORT TCollection_ExtendedString GetFilter() const;
- Standard_EXPORT TCollection_ExtendedString GetRequired() const;
- Standard_EXPORT DDS_MsgType GetWarningLevel() const;
- Standard_EXPORT TCollection_ExtendedString GetLongDescription() const;
- Standard_EXPORT TCollection_ExtendedString GetShortDescription() const;
- Standard_EXPORT TCollection_AsciiString GetComponent() const;
-
- Standard_EXPORT TCollection_AsciiString GetUnits() const;
- Standard_EXPORT TCollection_AsciiString GetUnits( const UnitSystem& ) const;
-
- Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const;
- Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const;
-
- Standard_EXPORT Standard_Real GetMinValue() const;
- Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const;
-
- Standard_EXPORT Standard_Real GetMaxValue() const;
- Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const;
-
- Standard_EXPORT Standard_Integer GetPrecision() const;
- Standard_EXPORT Standard_Integer GetPrecision( const UnitSystem& ) const;
-
- Standard_EXPORT TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const;
- Standard_EXPORT TCollection_AsciiString GetFormat( const UnitSystem&,
- const Standard_Boolean = Standard_True ) const;
- Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const;
- Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
- Handle(TColStd_HArray1OfInteger)& ) const;
- Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
- Handle(TColStd_HArray1OfInteger)&,
- Handle(TColStd_HArray1OfExtendedString)& ) const;
- Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const;
-
- Standard_EXPORT Standard_Real GetMinZoom() const;
- Standard_EXPORT Standard_Real GetMaxZoom() const;
- Standard_EXPORT Standard_Real GetZoomOrder() const;
-
- Standard_EXPORT Standard_Real ToSI( const Standard_Real ) const;
- Standard_EXPORT Standard_Real FromSI( const Standard_Real ) const;
-
- Standard_EXPORT Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
- Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
-
- Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const;
-
- Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const;
- Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
-
-private:
- DDS_DicItem( const DDS_DicItem& );
- void operator=( const DDS_DicItem& );
- void FillDataMap( TCollection_AsciiString, const LDOM_Element&,
- const LDOM_Element&, const LDOM_Element&,
- const TColStd_SequenceOfAsciiString& );
- void PrepareFormats( const TCollection_AsciiString& );
- void GetDefaultFormat();
- UnitSystem GetActiveUnitSystem() const;
-
- void GetStringFormat( const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- TCollection_AsciiString& );
- void GetIntegerFormat( const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const Standard_Character,
- TCollection_AsciiString& );
- void GetFloatFormat( const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const Standard_Character,
- TCollection_AsciiString& );
- void Split( const TCollection_AsciiString&,
- Handle(TColStd_HArray1OfExtendedString)& );
-
- UnitData* GetUnitData( const UnitSystem& ) const;
-
-private:
- typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
-
-private:
- TCollection_AsciiString myId;
- TCollection_ExtendedString myLabel;
- TCollection_ExtendedString myFilter;
- TCollection_ExtendedString myRequired;
-
- Standard_Integer myType;
- Standard_Integer myWarnLevel;
-
- TCollection_ExtendedString myLongDescr;
- TCollection_ExtendedString myShortDescr;
-
- Standard_Real myMax;
- Standard_Real myMin;
- Standard_Real myDefValue;
- TCollection_ExtendedString myDefString;
-
- Standard_Integer myData;
-
- // valueList
- TCollection_ExtendedString myListName;
-
- Handle(TColStd_HArray1OfExtendedString) myListRef;
- Handle(TColStd_HArray1OfInteger) myListRefID;
- Handle(TColStd_HArray1OfExtendedString) myListRefIcons;
-
- // presentation
- Standard_Real myMinZoom;
- Standard_Real myMaxZoom;
- Standard_Real myZoomOrder;
-
- Handle(Standard_Transient) myComponent;
-
- OptionsMap myOptions;
- // unitData
- NCollection_DataMap<UnitSystem, UnitData> myUnitData;
-
- friend class DDS_DicGroup;
-
-public:
- // Declaration of CASCADE RTTI
- DEFINE_STANDARD_RTTI(DDS_DicItem)
-};
-
-DEFINE_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
-
-DEFINE_BASECOLLECTION(DDS_BaseCollectionOfDicItems, Handle(DDS_DicItem))
-DEFINE_INDEXEDDATAMAP(DDS_IndexedDataMapOfDicItems, DDS_BaseCollectionOfDicItems,
- TCollection_AsciiString, Handle(DDS_DicItem))
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "DDS_Dictionary.h"
-
-#include "DDS_KeyWords.h"
-
-#include <LDOMString.hxx>
-#include <LDOMParser.hxx>
-
-#include <UnitsAPI.hxx>
-
-#include <TColStd_SequenceOfInteger.hxx>
-#include <TColStd_SequenceOfAsciiString.hxx>
-#include <TColStd_SequenceOfExtendedString.hxx>
-
-#include <NCollection_Map.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
-
-IMPLEMENT_STANDARD_HANDLE(DDS_Dictionary, MMgt_TShared)
-IMPLEMENT_STANDARD_RTTIEXT(DDS_Dictionary, MMgt_TShared)
-
-/*!
- \class DDS_Dictionary
-
- This class to provide information about used datums, reading them from 'xml' file
-
- Datum is the set of parameters described a phisical characteristic. These parameters loaded from
- special XML which has following format:
-
- \hr
-
- <D_URI>
- <COMPONENT COMPONENT_NAME="component_name">
- <UNIT_SYSTEMS>
- <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
- <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
- ...
- <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
- </UNIT_SYSTEMS>
-
- <DATUM DATUM_UNITS="[base_system_internal_name]" DATUM_FORMAT="[sprintf_format_specification]"
- DATUM_ID="[datum_id]" DATUM_LABEL="[datum_label]" DATUM_REQUIRED="[requred_value]"
- DATUM_FILTER="[string_regular_expression]">
- <DY_DOMAIN>
- <VALUE_DESCR VD_DEFV="[default_value]" VD_MAXV="[max_value]" VD_MINV="[min_value]" VD_TYPE="[value_type]"/>
- <VALUE_LIST_REF VLR_LIST="[referenced_list_id]"/>
- </DY_DOMAIN>
- <DESCR>
- <SHORT_D>[brief_desription_text]</SHORT_D>
- <LONG_D>[full_description_text]</LONG_D>
- </DESCR>
- <OPTIONS>
- <OPTION OPTION_NAME="[option_name_1]">[option_value_1]</OPTION>
- <OPTION OPTION_NAME="[option_name_2]">[option_value_2]</OPTION>
- ...
- <OPTION OPTION_NAME="[option_name_n]">[option_value_n]</OPTION>
- </OPTIONS>
- </DATUM>
-
- ...
-
- <VALUE_LIST VALUE_LIST_ID="[list_id]" VALUE_LIST_NAME="[list_name]">
- <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
- <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
- ...
- <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
- </VALUE_LIST>
-
- ...
-
- </COMPONENT>
- </D_URI>
-
- \hr
-
- In description of datum file format used internal keys as XML tag and attributes names.
- Concrete XML keywords defined by DDS_KeyWords class.
-
- Describe datum file format more detailed. XML file should have one main tag named as "dictionary" (key "D_URI").
- This tag should contains one or several components. Component is a independent set of datums and unit systems.
- Components defined as XML tag named "component" (key "COMPONENT") with attribute "name" (key COMPONENT_NAME).
- Component name used as component identifier and should be unique. Component tag can contains:
-
- \li Tag "unit_systems" (key UNIT_SYSTEMS) defines set of used unit systems. Should exist at least one unit
- system named SI ("System International"). If this system not exist then it will be defined automatically.
- Each unit system defined by XML tag "unit system" (key UNIT_SYSTEM) under tag "unit_systems" with attributes
- "name" (key UNIT_SYSTEM_NAME) and "label" (key UNIT_SYSTEM_LABEL). Name is identifier of unit system. Label is
- human readable description.
-
- \li One or several tag "datum" (key DATUM). For this tag can be defined following attributes:
-
- \lo Identifier (key DATUM_ID) specify the unique id string for the datum.
- \lo Label (key DATUM_LABEL) specify human readable name of the datum.
- \lo Units of measure (key DATUM_UNITS) for given unit system. Attribute name consist of a name
- of unit system and a keyword got from DDS_KeyWords by key DATUM_UNITS. For example for unit system
- named SI and default keyword attribute name will be "SIunits". This attribute should be specified
- for each deaclared unit system. Value of this attribute should be string describs units of measure.
- Possible designations for units of measure and their multiple prefixes see in package UnitsAPI of
- library OpenCascade (files Units.dat and Lexi_Expr.dat). Units of measure will be used for numeric
- value conversion from one unit system to another one.
- \lo Format (key DATUM_FORMAT) specify the format string which will be used during initial formatting
- of value. This string should be specified in sprintf() format.
- \lo Filter (key DATUM_FILTER) specify the regualr expression. Each user entered string will be checked up
- on matching to this expression (if it defined). Non matched strings will be rejected.
- \lo Required value (key DATUM_REQUIRED). If this attributed defined and value is true then user can't
- leave a input filed blank (parameter must be always entered).
-
- Tag "description" (key DESCR) can be defined under the tag "datum". This tag contains two sub tags:
- \lo "short description" (key SHORT_D) specify a brief datum description text
- \lo "long description" (key LONG_D) specify a detailed description text
-
- Tag "options" (key OPTIONS) can be defined under the tag "datum". This tag contains one or more sub
- tags "option" (key OPTION). Each of these XML elements should contain text option value and attribute
- "name" (key OPTION_NAME) which specified option name.
-
- Each tag "datum" define most common parameters of phisical characteristic.
- This parameters placed in two groups:
- \lo Domain parameters under tag "domain" (key DY_DOMAIN). This tag can contains value description tag
- (key VALUE_DESCR) for discrete data or list reference tag (key VALUE_LIST_REF) for enumerable data.
- Discrete data described following parameters:
- default value (key VD_DEFV)
- maximum value (key VD_MAXV)
- minimum value (key VD_MINV)
- type of value (key VD_TYPE) - possible values: String, Integer, Float, List
- Enumerable data described by "list reference" attribute (key VLR_LIST) which reference on
- list (see "list definition" tag) by list id.
-
- \li One or several tag "list definition" (key VALUE_LIST). This tag define the list of items for enumerable
- data. Attribute "list id" (key VALUE_LIST_ID) specify the identifier string for the list and attribute
- "list name" (key VALUE_LIST_NAME) define a list name string. Each list item described by tag "list value"
- (key VALUE_LIST_VALUE) under tag "list definition". Each this tag contains item string text and have
- following attributes:
- \lo "list item id" (key VALUE_LIST_VALUEID) - integer numerical identifier for item
- \lo "list item icon" (key VALUE_LIST_VALUEICON) - icon file name for item
-
- Below the example of a XML file with use default keywords.
-
- <datadictionary version="1.0">
- <component name="My Component">
-
- <!-- specify two unit systems -->
-
- <unitSystems>
- <system name="SI" label="System international">
- <system name="AS" label="Anglo - sacson system">
- </unitSystems>
-
- <!-- specify datum -->
- <!-- units of measure for SI - meters (m), for AS - inches (in) -->
- <datum SIunits="m" ASunits="in" format="%.25f" id="X" label="X coordinate" required="">
- <domain>
- <!-- default value not specified -->
- <valueDescr default="" max="999999999.999" min="0.000" type="Float"/>
- </domain>
- <description>
- <shortDescr>X coordinate for object</shortDescr>
- <longDescr>X multiplier of object coordinates. Describe position of object in direction of X axis</longDescr>
- </description>
- </datum>
-
- <datum SIunits="m" ASunits="in" format="%.25f" id="Y" label="Y coordinate" required="">
- <domain>
- <valueDescr default="" max="999999999.999" min="0.000" type="Float"/>
- </domain>
- <description>
- <shortDescr>Y coordinate for object</shortDescr>
- <longDescr>Y multiplier of object coordinates. Describe position of object in direction of Y axis</longDescr>
- </description>
- </datum>
-
- <!-- datum for object name with filter which not allow to input more that 8 letters,
- numbers or unerscores with first letter only -->
- <datum format="%.8us" id="ObjectName" label="Name" required="yes"
- filter="^([A-Z]+)([A-Z,0-9,_]*)$">
- <domain>
- <!-- limits and default not specified, type is string -->
- <valueDescr default="" max="" min="" type="String" />
- </domain>
- <description>
- <!-- long description not specified -->
- <shortDescr>Name of object</shortDescr>
- </description>
- </datum>
-
-
- <!-- datum for enumeration of side -->
- <datum format="" id="Side" label="Side" required="">
- <domain>
- <!-- default list item is item with id 0 -->
- <valueDescr default="0" type="List"/>
- <!-- list reference on list named "side_list" -->
- <listRef list="side_list"/>
- </domain>
- <description>
- <shortDescr>Side of object</shortDescr>
- </description>
- </datum>
-
- <!-- list definition for enumeration of side -->
- <valueList listid="side_list" name="Side">
- <value id="1">left</value>
- <value id="2">right</value>
- <value id="3">top</value>
- <value id="4">bottom</value>
- <value id="0">undefined</value>
- </valueList>
-
- </component>
- </datadictionary>
-
-
-*/
-
-/*!
- Constructor. Creates the instance of dictionary. Private method. Use DDS_Dictionary::Get() instead.
-*/
-DDS_Dictionary::DDS_Dictionary()
-: MMgt_TShared()
-{
-}
-
-/*!
- Copy constructor. Internal.
-*/
-DDS_Dictionary::DDS_Dictionary( const DDS_Dictionary& )
-{
-}
-
-/*!
- Assigment operator. Internal.
-*/
-void DDS_Dictionary::operator=( const DDS_Dictionary& )
-{
-}
-
-/*!
- Returns the names list of defined unit systems from all components.
- Parameter \atheSystems will contains the sequence of string names.
-*/
-void DDS_Dictionary::GetUnitSystems( TColStd_SequenceOfAsciiString& theSystems ) const
-{
- theSystems.Clear();
-
- NCollection_Map<TCollection_AsciiString> aMap;
- for ( Standard_Integer i = 1; i <= myGroupMap.Extent(); i++ )
- {
- TColStd_SequenceOfAsciiString theSeq;
- myGroupMap.FindFromIndex( i )->GetUnitSystems( theSeq );
- for ( Standard_Integer s = 1; s <= theSeq.Length(); s++ )
- {
- if ( aMap.Contains( theSeq.Value( s ) ) )
- continue;
-
- theSystems.Append( theSeq.Value( s ) );
- aMap.Add( theSeq.Value( s ) );
- }
- }
-
-}
-
-/*!
- Returns the names list of defined unit systems from the specified component \atheComponent.
- Parameter \atheSystems will contains the sequence of string names. If component not found then
- empty list returned.
-*/
-void DDS_Dictionary::GetUnitSystems( TColStd_SequenceOfAsciiString& theSystems,
- const TCollection_AsciiString& theComponent ) const
-{
- theSystems.Clear();
- if ( myGroupMap.Contains( theComponent ) )
- myGroupMap.FindFromKey( theComponent )->GetUnitSystems( theSystems );
-}
-
-/*!
- Returns the label of unit system \atheSystem. Function find the given unit system in
- all components. If unit system not found in any component then empty string returned.
-*/
-TCollection_ExtendedString DDS_Dictionary::GetUnitSystemLabel( const TCollection_AsciiString& theSystem ) const
-{
- TCollection_ExtendedString aLabel;
- for ( Standard_Integer i = 1; i <= myGroupMap.Extent() && !aLabel.Length(); i++ )
- aLabel = myGroupMap.FindFromIndex( i )->GetUnitSystemLabel( theSystem );
- return aLabel;
-}
-
-/*!
- Returns the label of unit system \atheSystem from component \atheComponent. Function find
- the given unit system in the specified component only. If unit system not found in the
- component then empty string returned.
-*/
-TCollection_ExtendedString DDS_Dictionary::GetUnitSystemLabel( const TCollection_AsciiString& theSystem,
- const TCollection_AsciiString& theComponent ) const
-{
- TCollection_ExtendedString aLabel;
- if ( myGroupMap.Contains( theComponent ) )
- aLabel = myGroupMap.FindFromKey( theComponent )->GetUnitSystemLabel( theSystem );
- return aLabel;
-}
-
-/*!
- Gets the name of active unit system from first got component. If any component exist then
- active unit system name returned or empty string otherwise.
-*/
-TCollection_AsciiString DDS_Dictionary::GetActiveUnitSystem() const
-{
- TCollection_AsciiString aSystem;
- if ( myGroupMap.Extent() )
- aSystem = myGroupMap.FindFromIndex( 1 )->GetActiveUnitSystem();
- return aSystem;
-}
-
-/*!
- Gets the name of active unit system from component \atheComponent. If this component exist
- active unit system name returned or empty string otherwise.
-*/
-TCollection_AsciiString DDS_Dictionary::GetActiveUnitSystem( const TCollection_AsciiString& theComponent ) const
-{
- TCollection_AsciiString aSystem;
- if ( myGroupMap.Contains( theComponent ) )
- aSystem = myGroupMap.FindFromKey( theComponent )->GetActiveUnitSystem();
- return aSystem;
-}
-
-/*!
- Sets the active unit system named \atheSystem. This unit system will be activated in all
- existing components if component have it.
-*/
-void DDS_Dictionary::SetActiveUnitSystem( const TCollection_AsciiString& theSystem )
-{
- for ( Standard_Integer i = 1; i <= myGroupMap.Extent(); i++ )
- myGroupMap.FindFromIndex( i )->SetActiveUnitSystem( theSystem );
-}
-
-/*!
- Sets the active unit system named \atheSystem for component \atheComponent. If specified unit
- system doesn't exist in the component then function do nothing.
-*/
-void DDS_Dictionary::SetActiveUnitSystem( const TCollection_AsciiString& theSystem,
- const TCollection_AsciiString& theComponent )
-{
- if ( myGroupMap.Contains( theComponent ) )
- myGroupMap.FindFromKey( theComponent )->SetActiveUnitSystem( theSystem );
-}
-
-/*!
- Returns the instance of dictionary. Create instance if it is NULL.
-*/
-Handle(DDS_Dictionary) DDS_Dictionary::Get()
-{
- static Handle(DDS_Dictionary) sDictionary;
-
- if ( sDictionary.IsNull() )
- sDictionary = new DDS_Dictionary();
-
- return sDictionary;
-}
-
-/*!
- Load datum definitions in the dictionary from XML file \atheFileName. Returns true if load
- successed or false otherwise.
-*/
-Standard_Boolean DDS_Dictionary::Load( const TCollection_AsciiString theFileName )
-{
- static NCollection_Map<TCollection_AsciiString> _LoadMap;
-
- if ( _LoadMap.Contains( theFileName ) )
- return Standard_True;
-
- Handle(DDS_Dictionary) aDic = Get();
- if ( aDic.IsNull() )
- return Standard_False;
-
- LDOMParser aParser;
- if ( aParser.parse( theFileName.ToCString() ) )
- return Standard_False;
-
- LDOM_Document aDoc = aParser.getDocument();
- LDOM_Element aDocElement = aDoc.getDocumentElement();
- for ( LDOM_Element aComponentElem = aDocElement.GetChildByTagName( KeyWord( "COMPONENT" ) );
- !aComponentElem.isNull(); aComponentElem = aComponentElem.GetSiblingByTagName() )
- aDic->FillDataMap( aComponentElem, aDocElement );
-
- _LoadMap.Add( theFileName );
-
- return Standard_True;
-}
-
-/*!
- Gets XML keyword as LDOMString by specified \akey. If key doesn't exist then empty string
- returned. This function provided for convenience.
-*/
-LDOMString DDS_Dictionary::KeyWord( const TCollection_AsciiString& key )
-{
- LDOMString keyWord;
- Handle(DDS_KeyWords) aKeyWords = DDS_KeyWords::Get();
- if ( !aKeyWords.IsNull() )
- {
- TCollection_AsciiString aStr = aKeyWords->GetKeyWord( key );
- if ( aStr.Length() )
- keyWord = LDOMString( aStr.ToCString() );
- }
- return keyWord;
-}
-
-/*!
- Gets dictionary item with specified identifier \atheID from specified component \atheComponent.
- If component or item not found then null handle returned.
-*/
-Handle(DDS_DicItem) DDS_Dictionary::GetDicItem( const TCollection_AsciiString& theID,
- const TCollection_AsciiString& theComponent ) const
-{
- Handle(DDS_DicItem) aDicItem;
- Handle(DDS_DicGroup) aDicGroup;
- if ( myGroupMap.Contains( theComponent ) )
- aDicGroup = myGroupMap.FindFromKey( theComponent );
- if ( !aDicGroup.IsNull() )
- aDicItem = aDicGroup->GetDicItem( theID );
- return aDicItem;
-}
-
-/*!
- Gets dictionary item with specified identifier \atheID. Function find the item in all components.
- If item not found in any component then null handle returned.
-*/
-Handle(DDS_DicItem) DDS_Dictionary::GetDicItem( const TCollection_AsciiString& theID ) const
-{
- Handle(DDS_DicItem) aDicItem;
- for ( Standard_Integer i = 1; i <= myGroupMap.Extent() && aDicItem.IsNull(); i++ )
- aDicItem = myGroupMap.FindFromIndex( i )->GetDicItem( theID );
- return aDicItem;
-}
-
-/*!
- Fill the internal data structures from XML parsed structures. Internal.
-*/
-void DDS_Dictionary::FillDataMap( const LDOM_Element& theComponentData, const LDOM_Element& theDocElement )
-{
- TCollection_AsciiString aCompName = theComponentData.getAttribute( KeyWord( "COMPONENT_NAME" ) );
- if ( !myGroupMap.Contains( aCompName ) )
- myGroupMap.Add( aCompName, new DDS_DicGroup( aCompName ) );
- Handle(DDS_DicGroup) aDicGroup = myGroupMap.FindFromKey( aCompName );
- aDicGroup->FillDataMap( theComponentData, theDocElement );
- myGroupMap.Add( aCompName, aDicGroup );
-}
-
-/*!
- Convert numeric value \atheValue from specified unit of measure \atheUnits to SI unit of measure
- (mm for Length, radians for Angles, etc). Converted value returned.
-*/
-Standard_Real DDS_Dictionary::ToSI( const Standard_Real theValue, const Standard_CString theUnits )
-{
- Standard_Real aRetValue = theValue;
- if ( theUnits && *theUnits && strcmp( theUnits, "%" ) )
- {
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- aRetValue = UnitsAPI::AnyToSI( theValue, theUnits );
- }
- catch( Standard_Failure ) {
- }
- }
- else if ( theUnits && *theUnits )
- aRetValue = theValue / 100.0;
-
- return aRetValue;
-}
-
-/*!
- Convert numeric value \atheValue to specified unit of measure \atheUnits from SI unit of measure
- (mm for Length, radians for Angles, etc). Converted value returned.
-*/
-Standard_Real DDS_Dictionary::FromSI( const Standard_Real theValue, const Standard_CString theUnits )
-{
- Standard_Real aRetValue = theValue;
- if ( theUnits && *theUnits && strcmp( theUnits, "%" ) )
- {
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- aRetValue = UnitsAPI::AnyFromSI( theValue, theUnits );
- }
- catch( Standard_Failure ) {
- }
- }
- else if ( theUnits && *theUnits )
- aRetValue = theValue * 100.0;
-
- return aRetValue;
-}
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef DDS_DICTIONARY_H
-#define DDS_DICTIONARY_H
-
-#include "DDS_DicGroup.h"
-
-#include <LDOMString.hxx>
-
-#include <MMgt_TShared.hxx>
-
-class LDOM_Element;
-class TCollection_AsciiString;
-
-DEFINE_STANDARD_HANDLE(DDS_Dictionary, MMgt_TShared)
-
-class DDS_Dictionary : public MMgt_TShared
-{
-public:
- Standard_EXPORT static Handle(DDS_Dictionary) Get();
-
- // Return instance of data dictionary. Create instance if it is NULL.
-
- Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
- Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString&,
- const TCollection_AsciiString& ) const;
-
- Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString& ) const;
- Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString&,
- const TCollection_AsciiString& ) const;
- Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString& ) const;
- Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString&,
- const TCollection_AsciiString& ) const;
- Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem() const;
- Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem( const TCollection_AsciiString& ) const;
- Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString& );
- Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString&,
- const TCollection_AsciiString& );
-
-
- static Standard_EXPORT Standard_Boolean Load( const TCollection_AsciiString );
-
- static Standard_EXPORT Standard_Real ToSI( const Standard_Real, const Standard_CString );
- static Standard_EXPORT Standard_Real FromSI( const Standard_Real, const Standard_CString );
-
- static Standard_EXPORT LDOMString KeyWord( const TCollection_AsciiString& );
-
-private:
- DDS_Dictionary();
- DDS_Dictionary( const DDS_Dictionary& );
-
- void operator=( const DDS_Dictionary& );
-
- void FillDataMap( const LDOM_Element&, const LDOM_Element& );
-
-private:
- DDS_IndexedDataMapOfDicGroups myGroupMap;
-
-public:
- DEFINE_STANDARD_RTTI(DDS_Dictionary)
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "DDS_KeyWords.h"
-
-IMPLEMENT_STANDARD_HANDLE(DDS_KeyWords, MMgt_TShared)
-IMPLEMENT_STANDARD_RTTIEXT(DDS_KeyWords, MMgt_TShared)
-
-/*!
- \class DDS_KeyWords
-
- This object contains the pairs of internal keys and XML tag or attribute names. This class allow to user
- define set of XML keywords used in datums definition file.
-
- Default keywords table:
- \li D_URI - dictionary
- \li COMPONENT - component
- \li COMPONENT_NAME - name
- \li UNIT_SYSTEMS - unitSystems
- \li UNIT_SYSTEM - system
- \li UNIT_SYSTEM_NAME - name
- \li UNIT_SYSTEM_LABEL - label
- \li DATUM - datum
- \li DATUM_ID - id
- \li DATUM_LABEL - label
- \li DATUM_UNITS - units
- \li DATUM_FORMAT - format
- \li DATUM_FILTER - filter
- \li DATUM_REQUIRED - required
- \li VALUE_LIST - valueList
- \li VALUE_LIST_ID - listid
- \li VALUE_LIST_NAME - name
- \li VALUE_LIST_TYPE - type
- \li VALUE_LIST_VALUE - value
- \li VALUE_LIST_VALUEID - id
- \li VALUE_LIST_VALUEICON - icon
- \li DY_DOMAIN - domain
- \li WARNING_LEVEL - warningLevel
- \li WRONG_VALUE - wrongValue
- \li VALUE_DESCR - valueDescr
- \li VALUE_LIST_REF - listRef
- \li DESCR - description
- \li LONG_D - longDescr
- \li SHORT_D - shortDescr
- \li VD_TYPE - type
- \li VD_DEFV - default
- \li VD_MAXV - max
- \li VD_MINV - min
- \li VD_SPEC - specVal
- \li VLR_LIST - list
- \li PRS - presentation
- \li LATERAL_ZOOM - lateralZoom
- \li LZ_MINV - min
- \li LZ_MAXV - max
- \li LZ_ORDER - order
- \li OPTIONS - options
- \li OPTION - option
- \li OPTION_NAME - name
-*/
-
-/*!
- Constructor
-*/
-
-DDS_KeyWords::DDS_KeyWords()
-: MMgt_TShared()
-{
- SetKeyWord( "D_URI", "dictionary" );
-
- SetKeyWord( "COMPONENT", "component" );
- SetKeyWord( "COMPONENT_NAME", "name" );
-
- SetKeyWord( "UNIT_SYSTEMS", "unitSystems" );
- SetKeyWord( "UNIT_SYSTEM", "system" );
- SetKeyWord( "UNIT_SYSTEM_NAME", "name" );
- SetKeyWord( "UNIT_SYSTEM_LABEL", "label" );
-
- SetKeyWord( "DATUM", "datum" );
- SetKeyWord( "DATUM_ID", "id" );
- SetKeyWord( "DATUM_LABEL", "label" );
- SetKeyWord( "DATUM_UNITS", "units" );
- SetKeyWord( "DATUM_FORMAT", "format" );
- SetKeyWord( "DATUM_FILTER", "filter" );
- SetKeyWord( "DATUM_REQUIRED", "required" );
-
- SetKeyWord( "VALUE_LIST", "valueList" );
- SetKeyWord( "VALUE_LIST_ID", "listid" );
- SetKeyWord( "VALUE_LIST_NAME", "name" );
- SetKeyWord( "VALUE_LIST_TYPE", "type" );
- SetKeyWord( "VALUE_LIST_VALUE", "value" );
- SetKeyWord( "VALUE_LIST_VALUEID", "id" );
- SetKeyWord( "VALUE_LIST_VALUEICON", "icon" );
-
- SetKeyWord( "DY_DOMAIN", "domain" );
- SetKeyWord( "WARNING_LEVEL", "warningLevel" );
- SetKeyWord( "WRONG_VALUE", "wrongValue" );
- SetKeyWord( "VALUE_DESCR", "valueDescr" );
- SetKeyWord( "VALUE_LIST_REF", "listRef" );
-
- SetKeyWord( "DESCR", "description" );
- SetKeyWord( "LONG_D", "longDescr" );
- SetKeyWord( "SHORT_D", "shortDescr" );
-
- SetKeyWord( "VD_TYPE", "type" );
- SetKeyWord( "VD_DEFV", "default" );
- SetKeyWord( "VD_MAXV", "max" );
- SetKeyWord( "VD_MINV", "min" );
- SetKeyWord( "VD_SPEC", "specVal" );
- SetKeyWord( "VLR_LIST", "list" );
- SetKeyWord( "PRS", "presentation" );
- SetKeyWord( "LATERAL_ZOOM", "lateralZoom" );
- SetKeyWord( "LZ_MINV", "min" );
- SetKeyWord( "LZ_MAXV", "max" );
- SetKeyWord( "LZ_ORDER", "order" );
-
- SetKeyWord( "OPTIONS", "options" );
- SetKeyWord( "OPTION", "option" );
- SetKeyWord( "OPTION_NAME", "name" );
-}
-
-/*!
- Returns the static instance of the class DDS_KeyWords
-*/
-
-Handle(DDS_KeyWords) DDS_KeyWords::Get()
-{
- static Handle(DDS_KeyWords) keyWords;
-
- if ( keyWords.IsNull() )
- keyWords = new DDS_KeyWords();
-
- return keyWords;
-}
-
-/*!
- Returns the XML keyword by specified internal key \a key. If the internal key isn't registered
- then empty string will be returned.
-*/
-
-TCollection_AsciiString DDS_KeyWords::GetKeyWord( const TCollection_AsciiString& key ) const
-{
- TCollection_AsciiString keyWord;
- if ( myKeyWord.IsBound( key ) )
- keyWord = myKeyWord.Find( key );
- return keyWord;
-}
-
-/*!
- Register the pair of the internal key \a key and XML keyword \a keyWord.
-*/
-
-void DDS_KeyWords::SetKeyWord( const TCollection_AsciiString& key,
- const TCollection_AsciiString& keyWord )
-{
- if ( myKeyWord.IsBound( key ) )
- myKeyWord.UnBind( key );
-
- myKeyWord.Bind( key, keyWord );
-}
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef DDS_KEYWORDS_H
-#define DDS_KEYWORDS_H
-
-#include "DDS.h"
-
-#include <MMgt_TShared.hxx>
-
-#include <NCollection_DataMap.hxx>
-
-DEFINE_STANDARD_HANDLE(DDS_KeyWords, MMgt_TShared)
-
-class TCollection_AsciiString;
-
-class DDS_KeyWords : public MMgt_TShared
-{
-public:
- Standard_EXPORT static Handle(DDS_KeyWords) Get();
-
- Standard_EXPORT TCollection_AsciiString GetKeyWord( const TCollection_AsciiString& ) const;
- Standard_EXPORT void SetKeyWord( const TCollection_AsciiString&,
- const TCollection_AsciiString& );
-
-private:
- DDS_KeyWords();
-
-private:
- typedef NCollection_DataMap<TCollection_AsciiString,
- TCollection_AsciiString> KeyWordMap;
-
-private:
- KeyWordMap myKeyWord;
-
-public:
- DEFINE_STANDARD_RTTI(DDS_KeyWords)
-};
-
-#endif
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# File : Makefile.in
-# Author : Alexander SOLOVYOV (OCN)
-# Module : DDS
-# $Header: /home/server/cvs/GUI/GUI_SRC/src/DDS/Makefile.in
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@
-
-@COMMENCE@
-
-# header files
-EXPORT_HEADERS= DDS.h \
- DDS_DicGroup.h \
- DDS_DicItem.h \
- DDS_Dictionary.h \
- DDS_KeyWords.h
-
-# Libraries targets
-LIB = libDDS.la
-
-LIB_SRC= DDS_DicGroup.cxx \
- DDS_DicItem.cxx \
- DDS_Dictionary.cxx \
- DDS_KeyWords.cxx
-
-CPPFLAGS+= $(OCC_INCLUDES)
-
-LDFLAGS+= $(CAS_KERNEL) $(CAS_OCAF)
-
-@CONCLUDE@
-
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//
-//
-// File: SalomeApp.h
-// Created: November, 2004
-// Author: OCC team
-// Copyright (C) CEA 2004
-
-
-// The following ifdef block is the standard way of creating macros which make exporting
-// from a DLL simpler. All files within this DLL are compiled with the SalomeApp_EXPORTS
-// symbol defined on the command line. this symbol should not be defined on any project
-// that uses this DLL. This way any other project whose source files include this file see
-// SalomeApp_API functions as being imported from a DLL, wheras this DLL sees symbols
-// defined with this macro as being exported.
-#ifdef WNT
-
-#ifdef EVENT_EXPORTS
-#define EVENT_EXPORT __declspec(dllexport)
-#else
-#define EVENT_EXPORT __declspec(dllimport)
-#endif
-
-#else
-#define EVENT_EXPORT
-#endif //WNT
-
-#define APP_VERSION "0.1"
-
-#if defined WNT
-#pragma warning ( disable: 4251 )
-#endif
-
+++ /dev/null
-# SALOME Utils : general SALOME's definitions and tools
-#
-# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-#
-#
-# File : Makefile.in
-# Author : Marc Tajchman (CEA)
-# Module : SALOME
-# $Header$
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/idl
-
-
-@COMMENCE@
-
-# header files
-EXPORT_HEADERS= \
- Event.h \
- SALOME_Event.hxx
-
-EXPORT_PYSCRIPTS =
-# Libraries targets
-
-LIB = libEvent.la
-LIB_SRC = SALOME_Event.cxx
-
-CPPFLAGS+=$(QT_INCLUDES) $(KERNEL_CXXFLAGS)
-LDFLAGS+=$(QT_MT_LIBS)
-
-@CONCLUDE@
-
-
+++ /dev/null
-// KERNEL SALOME_Event : Define event posting mechanism
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//
-//
-// File : SALOME_Event.cxx
-// Author : Sergey ANIKIN
-// Module : KERNEL
-// $Header$
-
-#include "SALOME_Event.hxx"
-
-//#include "utilities.h"
-
-#include <qsemaphore.h>
-#include <qapplication.h>
-#include <qthread.h>
-
-// asv 21.02.05 : introducing multi-platform approach of thread comparison
-// on Unix using pthread_t type for storing ThreadId
-// on Win32 using integer type for storing ThreadId
-// NOT using integer ThreadId on both Unix and Win32 because (from documentation):
-// "...Do not allow your program to rely on the internal structure or size of the pthread_t..."
-
-#ifdef WIN32
-#include <windows.h>
-
-static DWORD myThread;
-#else
-#include <qthread.h>
-#include <pthread.h>
-
-static pthread_t myThread;
-#endif
-
-/*!
- \return thread id
-*/
-void SALOME_Event::GetSessionThread(){
-#ifdef WIN32
- myThread = ::GetCurrentThreadId();
-#else
- myThread = pthread_self();
-#endif
-}
-
-/*!
- \return true if it is session thread
-*/
-bool SALOME_Event::IsSessionThread(){
- bool aResult = false;
-#ifdef WIN32
- aResult = myThread == ::GetCurrentThreadId();
-#else
- aResult = myThread == pthread_self();
-#endif
-// if(MYDEBUG) INFOS("IsSessionThread() - "<<aResult);
- return aResult;
-}
-
-
-/*!
- Constructor
-*/
-SALOME_Event::SALOME_Event(){
-// if(MYDEBUG) MESSAGE( "SALOME_Event::SALOME_Event(): this = "<<this );
- // Prepare the semaphore
- mySemaphore = new QSemaphore( 2 );
- *mySemaphore += 2;
-}
-
-/*!
- Destructor
-*/
-SALOME_Event::~SALOME_Event(){
-// if(MYDEBUG) MESSAGE( "SALOME_Event::~SALOME_Event(): this = "<<this );
- if ( mySemaphore->available() < mySemaphore->total() )
- *mySemaphore -= mySemaphore->total() - mySemaphore->available();
- delete mySemaphore;
-}
-
-/*!
- Posts the event and optionally waits for its completion
-*/
-void SALOME_Event::process()
-{
- QThread::postEvent( qApp, new QCustomEvent( SALOME_EVENT, (void*)this ) );
-// if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<<this<<", *mySemaphore += 1 " );
- *mySemaphore += 1;
-// if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<<this<<" - COMPLETED" );
-}
-
-/*!
- Signals that this event has been processed
-*/
-void SALOME_Event::processed()
-{
-// if(MYDEBUG) MESSAGE( "SALOME_Event::processed(): this = "<<this );
- // process() takes control over mySemaphore after the next line is executed
- *mySemaphore -= 1;
-}
+++ /dev/null
-// KERNEL SALOME_Event : Define event posting mechanism
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//
-//
-// File : SALOME_Event.hxx
-// Author : Sergey ANIKIN
-// Module : KERNEL
-// $Header$
-
-
-#ifndef SALOME_Event_HeaderFile
-#define SALOME_Event_HeaderFile
-
-#include <qevent.h>
-
-#define SALOME_EVENT QEvent::Type( QEvent::User + 10000 )
-
-class QSemaphore;
-
-/*!
- * \class SALOME_Event
- * Description:
- * This class encapsulates data and functionality required for
- * posting component-specific events to perform arbitrary operations in main GUI thread.
- * SALOME_Event objects can be posted by any thread belonging to the GUI process.
- *
- * It is necessary to derive a custom event class from SALOME_Event and
- * re-implement virtual Execute() method. This method should actually perform
- * the desirable operation. To pass all the required data to Execute() and store a return value,
- * arbitrary data fields can be added to the custom event class. There is
- * no need to protect such fields with a mutex, for only one thread working with
- * a SALOME_Event object is active at any moment.
- *
- * Usage:
- * - create SALOME_Event.
- * Components can derive their own event class from SALOME_Event
- * in order to pass custom data to the event handler.
- * - call process() method to post the event. After process() execution
- * it is possible to examine fields of your custom event object.
- * - perform delete operator on the event to wake up the desktop (you can also set <autoRelease>
- * parameter to TRUE to automatically wake up desktop after process()
- *
- * processed() method is used by the desktop to signal that event processing
- * has been completed.
- *
- * Caveats:
- * There is no.
- */
-
-#include <Event.h>
-
-class EVENT_EXPORT SALOME_Event{
-public:
- SALOME_Event();
- virtual ~SALOME_Event();
-
- // To do real work
- virtual void Execute() = 0;
-
- static bool IsSessionThread();
- void process();
-
-protected:
- void processed();
- friend class SalomeApp_EventFilter;
-
- static void GetSessionThread();
- friend int main(int, char **);
-
-private:
- QSemaphore* mySemaphore;
-};
-
-
-/*!
- \class TMemFunEvent
- \brief Template class for member function
-*/
-template<class TObject, typename TRes> class /*EVENT_EXPORT */TMemFunEvent: public SALOME_Event{
-public:
- typedef TRes TResult;
- TResult myResult;
- typedef TResult (TObject::* TAction)();
- TMemFunEvent(TObject* theObject, TAction theAction,
- TResult theResult = TResult()):
- myObject(theObject),
- myAction(theAction),
- myResult(theResult)
- {}
- virtual void Execute(){
- myResult = (myObject->*myAction)();
- }
-private:
- TObject* myObject;
- TAction myAction;
-};
-
-
-/*!
- \class TVoidMemFunEvent
- \brief Template class for member function
-*/
-template<class TObject> class /*EVENT_EXPORT*/ TVoidMemFunEvent: public SALOME_Event{
-public:
- typedef void (TObject::* TAction)();
- TVoidMemFunEvent(TObject* theObject, TAction theAction):
- myObject(theObject),
- myAction(theAction)
- {}
- virtual void Execute(){
- (myObject->*myAction)();
- }
-private:
- TObject* myObject;
- TAction myAction;
-};
-
-
-/*!
- \class TMemFun1ArgEvent
- \brief Template for member function with one argument
-*/
-template<class TObject, typename TRes, typename TArg, typename TStoreArg = TArg> class /*EVENT_EXPORT*/ TMemFun1ArgEvent:
-public SALOME_Event{
-public:
- typedef TRes TResult;
- TResult myResult;
- typedef TResult (TObject::* TAction)(TArg);
- TMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg,
- TResult theResult = TResult()):
- myObject(theObject),
- myAction(theAction),
- myResult(theResult),
- myArg(theArg)
- {}
- virtual void Execute(){
- myResult = (myObject->*myAction)(myArg);
- }
-private:
- TObject* myObject;
- TAction myAction;
- TStoreArg myArg;
-};
-
-
-/*!
- \class TVoidMemFun1ArgEvent
- \brief Template for member function with one argument
-*/
-template<class TObject, typename TArg, typename TStoreArg = TArg> class /*EVENT_EXPORT*/ TVoidMemFun1ArgEvent: public SALOME_Event{
-public:
- typedef void (TObject::* TAction)(TArg);
- TVoidMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg):
- myObject(theObject),
- myAction(theAction),
- myArg(theArg)
- {}
- virtual void Execute(){
- (myObject->*myAction)(myArg);
- }
-private:
- TObject* myObject;
- TAction myAction;
- TStoreArg myArg;
-};
-
-
-/*!
- \class TMemFun2ArgEvent
- \brief Template for member function with two arguments
-*/
-template<class TObject, typename TRes, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1> class
-/*EVENT_EXPORT*/ TMemFun2ArgEvent: public SALOME_Event{
-public:
- typedef TRes TResult;
- TResult myResult;
- typedef TResult (TObject::* TAction)(TArg,TArg1);
- TMemFun2ArgEvent(TObject* theObject, TAction theAction,
- TArg theArg, TArg1 theArg1,
- TResult theResult = TResult()):
- myObject(theObject),
- myAction(theAction),
- myResult(theResult),
- myArg(theArg),
- myArg1(theArg1)
- {}
- virtual void Execute(){
- myResult = (myObject->*myAction)(myArg,myArg1);
- }
-private:
- TObject* myObject;
- TAction myAction;
- TStoreArg myArg;
- TStoreArg1 myArg1;
-};
-
-
-/*!
- \class TVoidMemFun2ArgEvent
- \brief Template for member function with two arguments
-*/
-template<class TObject, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1> class
-/*EVENT_EXPORT*/ TVoidMemFun2ArgEvent: public SALOME_Event{
-public:
- typedef void (TObject::* TAction)(TArg,TArg1);
- TVoidMemFun2ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1):
- myObject(theObject),
- myAction(theAction),
- myArg(theArg),
- myArg1(theArg1)
- {}
- virtual void Execute(){
- (myObject->*myAction)(myArg,myArg1);
- }
-private:
- TObject* myObject;
- TAction myAction;
- TStoreArg myArg;
- TStoreArg1 myArg1;
-};
-
-
-/*!
- \fn ProcessEvent
- \brief Template function for processing events with result returing
-*/
-template<class TEvent> inline typename TEvent::TResult ProcessEvent(TEvent* theEvent){
- typename TEvent::TResult aResult;
- if(SALOME_Event::IsSessionThread()){
- theEvent->Execute();
- aResult = theEvent->myResult;
- }else{
- theEvent->process();
- aResult = theEvent->myResult;
- }
- delete theEvent;
- return aResult;
-}
-
-
-/*!
- \fn ProcessEvent
- \brief Template function for processing events without result
-*/
-inline void ProcessVoidEvent(SALOME_Event* theEvent){
- if(SALOME_Event::IsSessionThread()){
- theEvent->Execute();
- }else{
- theEvent->process();
- }
- delete theEvent;
-}
-
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer.h
-// Created: November, 2004
-
-//! Macro for exports
-#ifdef WNT
-
-#ifdef GLVIEWER_EXPORTS
-#define GLVIEWER_API __declspec(dllexport)
-#else
-#define GLVIEWER_API __declspec(dllimport)
-#endif
-
-#else
-#define GLVIEWER_API
-#endif // WNT
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_AspectLine.cxx
-// Created: 26/05/2005 3:17:00 PM
-
-#include "GLViewer_AspectLine.h"
-
-/*!
- Default constructor
-*/
-GLViewer_AspectLine::GLViewer_AspectLine()
-{
- myNColor = QColor( 255, 255, 255 );
- myHColor = QColor( 0, 255, 255 );
- mySColor = QColor( 255, 0, 0 );
-
- myLineWidth = 1.0;
- myLineType = 0;
-}
-
-/*!
- Constructor
- \param type: 0 for normal line and 1 for strip line
- \param width - width of line
-*/
-GLViewer_AspectLine::GLViewer_AspectLine( int type, float width )
-{
- myNColor = QColor( 255, 255, 255 );
- myHColor = QColor( 0, 255, 255 );
- mySColor = QColor( 255, 0, 0 );
-
- myLineWidth = width;
- if( type == 1 || type == 0 )
- myLineType = type;
- else
- myLineType = 0;
-}
-
-/*!
- Destructor
-*/
-GLViewer_AspectLine::~GLViewer_AspectLine()
-{
-}
-
-/*!
- Sets line color
- \param nc - normal color
- \param hc - hilighting color
- \param sc - selection color
-*/
-void GLViewer_AspectLine::setLineColors( QColor nc, QColor hc, QColor sc )
-{
- myNColor = nc;
- myHColor = hc;
- mySColor = sc;
-}
-
-/*!
- Sets type of line
- \param type: 0 for normal line and 1 for strip line
-*/
-int GLViewer_AspectLine::setLineType( const int type )
-{
- if( type == 1 || type == 0 )
- {
- myLineType = type;
- return 0;
- }
- return 1;
-}
-
-/*!
- Sets width of line
- \param width - new width of line
-*/
-int GLViewer_AspectLine::setLineWidth( const float width )
-{
- if( width > 0 )
- {
- myLineWidth = width;
- return 0;
- }
- return 1;
-}
-
-/*!
- \return colors of line
- \param nc - variable for normal color
- \param hc - variable for hilighting color
- \param sc - variable for selection color
-*/
-void GLViewer_AspectLine::getLineColors( QColor& nc, QColor& hc, QColor& sc ) const
-{
- nc = myNColor;
- hc = myHColor;
- sc = mySColor;
-}
-
-/*!
- \return binary representation of line aspect
-*/
-QByteArray GLViewer_AspectLine::getByteCopy() const
-{
- int anISize = sizeof( int );
- int aFSize = sizeof( float );
- int aNR = myNColor.red(), aNG = myNColor.green(), aNB = myNColor.blue();
- int aHR = myHColor.red(), aHG = myHColor.green(), aHB = myHColor.blue();
- int aSR = mySColor.red(), aSG = mySColor.green(), aSB = mySColor.blue();
-
- QByteArray aResult( anISize * 10 + aFSize );
-
- int i = 0;
-
- char* aPointer = (char*)&aNR;
- for( i = 0; i < anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aNG;
- for( ; i < 2*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aNB;
- for( ; i < 3*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&aHR;
- for( ; i < 4*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aHG;
- for( ; i < 5*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aHB;
- for( ; i < 6*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&aSR;
- for( ; i < 7*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aSG;
- for( ; i < 8*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aSB;
- for( ; i < 9*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&myLineWidth;
- for( ; i < 9*anISize + aFSize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&myLineType;
- for( ; i < 10*anISize + aFSize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- return aResult;
-}
-
-/*!
- Sets line aspect from binary representation
-*/
-GLViewer_AspectLine* GLViewer_AspectLine::fromByteCopy( QByteArray theBytes )
-{
-
- int anISize = sizeof( int );
- int aFSize = sizeof( float );
- int aNR = 0, aNG = 0, aNB = 0;
- int aHR = 0, aHG = 0, aHB = 0;
- int aSR = 0, aSG = 0, aSB = 0;
- int aLineType = 0;
- float aLineWidth = 0;
-
- int i = 0;
-
- char* aPointer = (char*)&aNR;
- for( i = 0; i < anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
- aPointer = (char*)&aNG;
- for( ; i < 2*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
- aPointer = (char*)&aNB;
- for( ; i < 3*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
-
- aPointer = (char*)&aHR;
- for( ; i < 4*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
- aPointer = (char*)&aHG;
- for( ; i < 5*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
- aPointer = (char*)&aHB;
- for( ; i < 6*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
-
- aPointer = (char*)&aSR;
- for( ; i < 7*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
- aPointer = (char*)&aSG;
- for( ; i < 8*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
- aPointer = (char*)&aSB;
- for( ; i < 9*anISize; i++, aPointer++ )
- *aPointer = theBytes[i];
-
- aPointer = (char*)&aLineWidth;
- for( ; i < 9*anISize + aFSize; i++, aPointer++ )
- *aPointer = theBytes[i];
-
- aPointer = (char*)&aLineType;
- for( ; i < 10*anISize + aFSize; i++, aPointer++ )
- *aPointer = theBytes[i];
-
- GLViewer_AspectLine* anAspect = new GLViewer_AspectLine( aLineType, aLineWidth );
- anAspect->setLineColors( QColor( aNR, aNG, aNB ),
- QColor( aHR, aHG, aHB ),
- QColor( aSR, aSG, aSB ) );
- return anAspect;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_AspectLine.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_ASPECTLINE_H
-#define GLVIEWER_ASPECTLINE_H
-
-#include "GLViewer.h"
-
-#include <qcolor.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \Class GLViewer_AspectLine
- Substitution of Prs2d_AspectLine for OpenGL
-*/
-
-class GLVIEWER_API GLViewer_AspectLine
-{
-public:
- //! A default constructor
- /* Line is Non strip
- * Normal color is white
- * Highlight color is cyan
- * Select color is red
- */
- GLViewer_AspectLine();
- //! A conctructor by type and width of line
- /*!
- \param theType equals 0 for normal line and 1 for strip line
- \param theWidth is a width of new line
- */
- GLViewer_AspectLine( int theType, float theWidth );
-
- //! A destructor
- ~GLViewer_AspectLine();
-
- //! A function for installing the line colors
- /*!
- \param nc is normal color
- \param hc is highlight color
- \param sc is select color
- */
- void setLineColors( QColor nc = Qt::black,
- QColor hc = Qt::cyan,
- QColor sc = Qt::red );
- //! A function for installing the line width
- int setLineWidth( const float theWidth );
- //! A function for installing the line type
- /*!
- \param theType equals 0 for normal line and 1 for strip line
- */
- int setLineType( const int theType );
-
- //! A function for getting line colors information
- /*!
- \param theNC is normal color
- \param theHC is highlight color
- \param theSC is select color
- */
- void getLineColors( QColor& theNC, QColor& theHC, QColor& theSC ) const;
- //! A function for getting information about line width
- float getLineWidth() const { return myLineWidth; };
- //! A function for getting information about line type
- int getLineType() const { return myLineType; };
-
- //! A function for coding object to the byte copy
- /*!
- A function is used for copy-past technollogy in copy method
- */
- QByteArray getByteCopy() const;
-
- //! A function for decoding object from the byte copy
- /*!
- A function is used for copy-past technollogy in past method
- */
- static GLViewer_AspectLine* fromByteCopy( QByteArray );
-
-protected:
- //! A normal color
- QColor myNColor;
- //! A highlight color
- QColor myHColor;
- //! A select color
- QColor mySColor;
- //! A line width
- float myLineWidth;
- //! A line type
- /*! equals 0 for normal line and 1 for strip line */
- int myLineType;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_BaseDrawers.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_BaseDrawers.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_Text.h"
-#include "GLViewer_AspectLine.h"
-#include "GLViewer_BaseObjects.h"
-
-#ifndef WIN32
-#include <GL/glx.h>
-#endif
-
-GLfloat sin_table[SEGMENTS];
-GLfloat cos_table[SEGMENTS];
-
-/*!
- Default constructor
-*/
-GLViewer_MarkerDrawer::GLViewer_MarkerDrawer()
-: GLViewer_Drawer()
-{
- GLfloat angle = 0.0;
- for ( int i = 0; i < SEGMENTS; i++ )
- {
- sin_table[i] = sin( angle );
- cos_table[i] = cos( angle );
- angle += float( STEP );
- }
- myObjectType = "GLViewer_MarkerSet";
-}
-
-/*!
- Destructor
-*/
-GLViewer_MarkerDrawer::~GLViewer_MarkerDrawer()
-{
-}
-
-/*! Draws object in GLViewer
- \param xScale - current scale along X-direction
- \param yScale - current scale along Y-direction
- \param onlyUpdate - = true if only update highlight-select information
-*/
-void GLViewer_MarkerDrawer::create( float xScale, float yScale, bool onlyUpdate )
-{
- QValueList<int>::Iterator it;
- QValueList<int>::Iterator EndIt;
- QValueList<GLViewer_Object*>::Iterator anObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator anEndObjectIt = myObjects.end();
-
- myXScale = xScale;
- myYScale = yScale;
-
- QColor colorN, colorH, colorS;
-
- GLViewer_MarkerSet* aMarkerSet = NULL;
- GLViewer_AspectLine* anAspectLine = NULL;
-
- for( ; anObjectIt != anEndObjectIt; anObjectIt++ )
- {
- aMarkerSet = ( GLViewer_MarkerSet* )(*anObjectIt);
- anAspectLine = aMarkerSet->getAspectLine();
- anAspectLine->getLineColors( colorN, colorH, colorS );
-
- float* aXCoord = aMarkerSet->getXCoord();
- float* anYCoord = aMarkerSet->getYCoord();
- float aRadius = aMarkerSet->getMarkerSize();
-
- QValueList<int> aHNumbers, anUHNumbers, aSelNumbers, anUSelNumbers;
- aMarkerSet->exportNumbers( aHNumbers, anUHNumbers, aSelNumbers, anUSelNumbers );
-
- if( onlyUpdate )
- {
- EndIt = anUHNumbers.end();
- for( it = anUHNumbers.begin(); it != EndIt; ++it )
- {
- drawMarker( aXCoord[*it], anYCoord[*it], aRadius, colorN, anAspectLine );
- }
-
- EndIt = anUSelNumbers.end();
- for( it = anUSelNumbers.begin(); it != EndIt; ++it )
- drawMarker( aXCoord[*it], anYCoord[*it], aRadius, colorN, anAspectLine );
-
- EndIt = aSelNumbers.end();
- for( it = aSelNumbers.begin(); it != EndIt; ++it )
- drawMarker( aXCoord[*it], anYCoord[*it], aRadius, colorS, anAspectLine );
-
- EndIt = aHNumbers.end();
- for( it = aHNumbers.begin(); it != EndIt; ++it )
- {
- drawMarker( aXCoord[*it], anYCoord[*it], aRadius, colorH, anAspectLine );
- }
- }
- else
- {
- int aNumber = aMarkerSet->getNumMarkers();
- for( int i = 0; i < aNumber; i++ )
- drawMarker( aXCoord[i], anYCoord[i], aRadius, colorN, anAspectLine );
-
- EndIt = anUSelNumbers.end();
- for( it = anUSelNumbers.begin(); it != EndIt; ++it )
- drawMarker( aXCoord[*it], anYCoord[*it], aRadius, colorN, anAspectLine );
-
- EndIt = aSelNumbers.end();
- for( it = aSelNumbers.begin(); it != EndIt; ++it )
- drawMarker( aXCoord[*it], anYCoord[*it], aRadius, colorS, anAspectLine );
- }
- if( aMarkerSet->getGLText()->getText() != "" )
- {
- //float aXPos = 0, anYPos = 0;
- //aMarkerSet->getGLText()->getPosition( aXPos, anYPos );
- //drawText( aMarkerSet->getGLText()->getText(), aXPos, anYPos, colorN, &aMarkerSet->getGLText()->getFont(), aMarkerSet->getGLText()->getSeparator() );
- drawText( aMarkerSet );
- }
- }
-}
-
-/*! Draws marker
- \param theXCoord - X position
- \param theYCoord - Y position
- \param theRadius - radius
- \param theColor - color
- \param theAspectLine - line aspect
-*/
-void GLViewer_MarkerDrawer::drawMarker( float& theXCoord, float& theYCoord,
- float& theRadius, QColor& theColor, GLViewer_AspectLine* theAspectLine )
-{
- glColor3f( ( GLfloat )theColor.red() / 255,
- ( GLfloat )theColor.green() / 255,
- ( GLfloat )theColor.blue() / 255 );
-
- glLineWidth( theAspectLine->getLineWidth() );
-
- if ( theAspectLine->getLineType() == 0 )
- glBegin( GL_LINE_LOOP );
- else
- glBegin( GL_LINE_STRIP);
-
- for ( int i = 0; i < SEGMENTS; i++ )
- glVertex2f( theXCoord + cos_table[i] * theRadius / myXScale,
- theYCoord + sin_table[i] * theRadius / myYScale );
- glEnd();
-}
-
-
-/*!
- Default constructor
-*/
-GLViewer_PolylineDrawer::GLViewer_PolylineDrawer()
-:GLViewer_Drawer()
-{
- myObjectType = "GLViewer_Polyline";
-}
-
-/*!
- Destructor
-*/
-GLViewer_PolylineDrawer::~GLViewer_PolylineDrawer()
-{
-}
-
-/*! Draws object in GLViewer
- \param xScale - current scale along X-direction
- \param yScale - current scale along Y-direction
- \param onlyUpdate - = true if only update highlight-select information
-*/
-void GLViewer_PolylineDrawer::create( float xScale, float yScale, bool onlyUpdate )
-{
- QValueList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
-
- myXScale = xScale;
- myYScale = yScale;
-
- QColor color, colorN, colorH, colorS;
- GLViewer_AspectLine* anAspect = NULL;
- GLViewer_Polyline* aPolyline = NULL;
- for( ; aObjectIt != aObjectEndIt; aObjectIt++ )
- {
- anAspect = (*aObjectIt)->getAspectLine();
- aPolyline = (GLViewer_Polyline*)(*aObjectIt);
-
-
- anAspect->getLineColors( colorN, colorH, colorS );
- if( onlyUpdate )
- {
- if( aPolyline->isHighlighted() )
- color = colorH;
- else if( aPolyline->isSelected() )
- color = colorS;
- else
- color = colorN;
- }
- else
- {
- if( aPolyline->isSelected() )
- color = colorS;
- else
- color = colorN;
- }
-
- float* aXCoord = aPolyline->getXCoord();
- float* anYCoord = aPolyline->getYCoord();
- int aSize = aPolyline->getNumber();
-
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
-
- glLineWidth( anAspect->getLineWidth() );
-
- if ( anAspect->getLineType() == 0 )
- glBegin( GL_LINE_LOOP );
- else
- glBegin( GL_LINE_STRIP);
-
- for( int i = 0; i < aSize ; i++ )
- glVertex2f( aXCoord[ i ], anYCoord[ i ] );
-
- if( aPolyline->isClosed() )
- glVertex2f( aXCoord[ 0 ], anYCoord[ 0 ] );
-
- glEnd();
-
- if( aPolyline->getGLText()->getText() != "" )
- {
- //float aXPos = 0, anYPos = 0;
- //aPolyline->getGLText()->getPosition( aXPos, anYPos );
- //drawText( aPolyline->getGLText()->getText(), aXPos, anYPos, color, &aPolyline->getGLText()->getFont(), aPolyline->getGLText()->getSeparator() );
- drawText( aPolyline );
- }
- }
-}
-
-/*!
- Default constructor
-*/
-GLViewer_TextDrawer::GLViewer_TextDrawer()
-: GLViewer_Drawer()
-{
- myObjectType = "GLViewer_TextObject";
-}
-
-/*!
- Destructor
-*/
-GLViewer_TextDrawer::~GLViewer_TextDrawer()
-{
-}
-
-/*! Draws object in GLViewer
- \param xScale - current scale along X-direction
- \param yScale - current scale along Y-direction
- \param onlyUpdate - = true if only update highlight-select information
-*/
-void GLViewer_TextDrawer::create( float xScale, float yScale, bool onlyUpdate )
-{
- QValueList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
-
- myXScale = xScale;
- myYScale = yScale;
-
- QColor color, colorN, colorH, colorS;
- GLViewer_AspectLine* anAspect = NULL;
- GLViewer_TextObject* anObject = NULL;
- //float aXPos = 0, anYPos = 0;
- for( ; aObjectIt != aObjectEndIt; aObjectIt++ )
- {
- anObject = (GLViewer_TextObject*)(*aObjectIt);
- anAspect = anObject->getAspectLine();
-
- anAspect->getLineColors( colorN, colorH, colorS );
- if( onlyUpdate )
- {
- if( anObject->isHighlighted() )
- color = colorH;
- else if( anObject->isSelected() )
- color = colorS;
- else
- color = colorN;
- }
- else
- {
- if( anObject->isSelected() )
- color = colorS;
- else
- color = colorN;
- }
-
- //anObject->getGLText()->getPosition( aXPos, anYPos );
- //drawText( anObject->getGLText()->getText(), aXPos, anYPos, color, &(anObject->getGLText()->getFont()), anObject->getGLText()->getSeparator() );
- drawText( anObject );
- }
-}
-
-/*!
- Updates objects after updating font
-*/
-void GLViewer_TextDrawer::updateObjects()
-{
- QValueList<GLViewer_Object*>::Iterator aObjectIt = myObjects.begin();
- QValueList<GLViewer_Object*>::Iterator aObjectEndIt = myObjects.end();
- for( ; aObjectIt != aObjectEndIt; aObjectIt++ )
- (*aObjectIt)->compute();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_BaseDrawers.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_BASEDRAWERS_H
-#define GLVIEWER_BASEDRAWERS_H
-
-#include <qcolor.h>
-#include <qobject.h>
-#include <qfile.h>
-#include <qfont.h>
-#include <qgl.h>
-
-#include "GLViewer.h"
-#include "GLViewer_Drawer.h"
-
-class GLViewer_AspectLine;
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_MarkerDrawer
- Drawer for GLViewer_MarkerSet
-*/
-
-class GLVIEWER_API GLViewer_MarkerDrawer : public GLViewer_Drawer
-{
-public:
- GLViewer_MarkerDrawer();
- ~GLViewer_MarkerDrawer();
-
- //! Redefined method
- virtual void create( float, float, bool );
-
-private:
- //! Draws marker in point (x,y) of \param radius with \param color and \param aspect
- void drawMarker( float& x, float& y, float& radius, QColor& color, GLViewer_AspectLine* aspect );
-};
-
-/*!
- \class GLViewer_PolylineDrawer
- Drawer for GLViewer_Polyline
-*/
-
-class GLVIEWER_API GLViewer_PolylineDrawer : public GLViewer_Drawer
-{
-public:
- GLViewer_PolylineDrawer();
- ~GLViewer_PolylineDrawer();
- //! Redefined method
- virtual void create( float, float, bool );
-};
-
-/*!
- \class GLViewer_TextDrawer
- Drawer for GLViewer_Text
-*/
-
-class GLVIEWER_API GLViewer_TextDrawer: public GLViewer_Drawer
-{
-
-public:
- GLViewer_TextDrawer();
- ~GLViewer_TextDrawer();
-
- //! Redefined method
- virtual void create( float, float, bool );
- //! Updates objects after updating font
- void updateObjects();
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_BaseObjects.h"
-#include "GLViewer_BaseDrawers.h"
-#include "GLViewer_AspectLine.h"
-#include "GLViewer_CoordSystem.h"
-#include "GLViewer_Text.h"
-#include "GLViewer_Group.h"
-
-#include "GLViewer_Drawer.h"
-
-//#include <cmath>
-//using namespace std;
-
-/*!
- Constructor
-*/
-GLViewer_MarkerSet::GLViewer_MarkerSet( int number, float size, const QString& toolTip ) :
- GLViewer_Object(),
- myNumber( 0 ),
- myXCoord( 0 ),
- myYCoord( 0 )
-{
-
- myMarkerSize = size;
- myHNumbers.clear();
- myUHNumbers.clear();
- mySelNumbers.clear();
- myUSelNumbers.clear();
- myCurSelNumbers.clear();
- myPrevHNumbers.clear();
-
- myType = "GLViewer_MarkerSet";
- myToolTipText = toolTip;
-
- setNumMarkers( number );
-}
-
-/*!
- Destructor
-*/
-GLViewer_MarkerSet::~GLViewer_MarkerSet()
-{
- if ( myXCoord )
- delete[] myXCoord;
- if ( myYCoord )
- delete[] myYCoord;
-}
-
-/*!
- Adds coords to text buffer in HPGL format
- \param buffer - text buffer
- \param command - command to be added with coords
- \param aViewerCS - viewer co-ordinates system
- \param aPaperCS - paper co-ordinates system
- \param x - x co-ordinate
- \param y - y co-ordinate
- \param NewLine - adds new line to buffer
-*/
-void AddCoordsToHPGL( QString& buffer, QString command, GLViewer_CoordSystem* aViewerCS,
- GLViewer_CoordSystem* aPaperCS, double x, double y, bool NewLine = true )
-{
- if( aViewerCS && aPaperCS )
- aViewerCS->transform( *aPaperCS, x, y );
-
- QString temp = command + "%1, %2;";
- buffer += temp.arg( x ).arg( y );
- if( NewLine )
- buffer += ";\n";
-}
-
-/*!
- Adds coords to text buffer in PostScript format
- \param buffer - text buffer
- \param command - command to be added with coords
- \param aViewerCS - viewer co-ordinates system
- \param aPaperCS - paper co-ordinates system
- \param x - x co-ordinate
- \param y - y co-ordinate
- \param NewLine - adds new line to buffer
-*/
-void AddCoordsToPS( QString& buffer, QString command, GLViewer_CoordSystem* aViewerCS,
- GLViewer_CoordSystem* aPaperCS, double x, double y, bool NewLine = true )
-{
- if( aViewerCS && aPaperCS )
- aViewerCS->transform( *aPaperCS, x, y );
-
- QString temp = "%1 %2 "+command;
- buffer += temp.arg( x ).arg( y );
- if( NewLine )
- buffer += "\n";
-}
-
-/*!
- Adds line aspect description to text buffer in PostScript format
- \param buffer - text buffer
- \param anAspect - line aspect
- \param aViewerCS - viewer co-ordinates system
- \param aPaperCS - paper co-ordinates system
-*/
-void AddLineAspectToPS( QString& buffer, GLViewer_AspectLine* anAspect,
- GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPaperCS )
-{
- if( anAspect )
- {
- QColor col1, col2, col3;
- anAspect->getLineColors( col1, col2, col3 );
-
- float aWidth = anAspect->getLineWidth();
- int aLineType = anAspect->getLineType();
-
- QString temp = "%1 %2 %3 setrgbcolor\n";
- double rr = 1 - double( col1.red() ) / 255.0, //color inverting
- gg = 1 - double( col1.green() ) / 255.0,
- bb = 1 - double( col1.blue() ) / 255.0;
-
- buffer += temp.arg( rr ).arg( gg ).arg( bb );
-
- double x_stretch, y_stretch;
- aViewerCS->getStretching( *aPaperCS, x_stretch, y_stretch );
- buffer += temp.arg( x_stretch * aWidth )+" setlinewidth\n";
-
- if( aLineType==0 ) //solid
- buffer += "[] 0 setdash\n";
- else if( aLineType==1 ) //strip
- buffer += "[2] 0 setdash\n";
- }
-}
-
-#ifdef WIN32
-/*!
- Adds line aspect description EMF image
- \param hDC - descriptor of EMF
- \param anAspect - line aspect
- \param aViewerCS - viewer co-ordinates system
- \param aPaperCS - paper co-ordinates system
-*/
-HPEN AddLineAspectToEMF( HDC hDC, GLViewer_AspectLine* anAspect,
- GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPaperCS )
-{
- if( anAspect )
- {
- QColor col1, col2, col3;
- anAspect->getLineColors( col1, col2, col3 );
-
- double x_stretch, y_stretch;
- aViewerCS->getStretching( *aPaperCS, x_stretch, y_stretch );
-
- double aWidth = anAspect->getLineWidth()*x_stretch;
- int aLineType = anAspect->getLineType();
-
- return CreatePen( PS_SOLID, aWidth, RGB( 255-col1.red(), 255-col1.green(), 255-col1.blue() ) );
- }
- else
- return NULL;
-}
-#endif
-
-/*!
- Saves to file PostScript set of markers
- \param hFile - file instance
- \param aViewerCS - viewer co-ordinates system
- \param aPSCS - paper co-ordinates system
-*/
-bool GLViewer_MarkerSet::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
-{
- int noPoints = 20;
-
- QString aBuffer = "newpath\n";
-
- AddLineAspectToPS( aBuffer, getAspectLine(), aViewerCS, aPSCS );
-
- for( int i=0; i<myNumber; i++ )
- {
- aBuffer += "\n";
-
- double x_stretch, y_stretch;
- aViewerCS->getStretching( *aPSCS, x_stretch, y_stretch );
-
- double x0 = myXCoord[i],
- y0 = myYCoord[i],
- r = myMarkerSize,
- x, y;
-
- for( int j=0; j<=noPoints; j++ )
- {
- x = x0 + r*cos( double(j)*2*PI/double(noPoints) );
- y = y0 + r*sin( double(j)*2*PI/double(noPoints) );
- if( j==0 )
- AddCoordsToPS( aBuffer, "moveto", aViewerCS, aPSCS, x, y, true );
- else
- AddCoordsToPS( aBuffer, "lineto", aViewerCS, aPSCS, x, y, true );
- }
- }
- aBuffer+="closepath\nstroke\n";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
-
- return true;
-}
-
-/*!
- Saves to file HPGL set of markers
- \param hFile - file instance
- \param aViewerCS - viewer co-ordinates system
- \param aHPGLCS - paper co-ordinates system
-*/
-bool GLViewer_MarkerSet::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS,
- GLViewer_CoordSystem* aHPGLCS )
-{
- int noPoints = 20;
- QString aBuffer;
- for( int i=0; i<myNumber; i++ )
- {
- aBuffer = "";
-
- double x_stretch, y_stretch;
- aViewerCS->getStretching( *aHPGLCS, x_stretch, y_stretch );
-
- double x0 = myXCoord[i],
- y0 = myYCoord[i],
- r = myMarkerSize,
- x, y;
-
- AddCoordsToHPGL( aBuffer, "PA", aViewerCS, aHPGLCS, x0+r, y0 );
- aBuffer+="PD;\n";
- for( int j=1; j<=noPoints; j++ )
- {
- x = x0 + r*cos( double(j)*2*PI/double(noPoints) );
- y = y0 + r*sin( double(j)*2*PI/double(noPoints) );
- AddCoordsToHPGL( aBuffer, "PD", aViewerCS, aHPGLCS, x, y );
- }
- aBuffer+="PU;\n";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
- }
-
- return true;
-}
-
-#ifdef WIN32
-/*!
- Saves to EMF image set of markers
- \param dc - EMF image descriptor
- \param aViewerCS - viewer co-ordinates system
- \param aEMFCS - paper co-ordinates system
-*/
-bool GLViewer_MarkerSet::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
-{
- int noPoints = 20;
- if( !aViewerCS || !aEMFCS )
- return false;
-
- HPEN pen = AddLineAspectToEMF( dc, getAspectLine(), aViewerCS, aEMFCS );
- HGDIOBJ old = SelectObject( dc, pen );
-
- for( int i=0; i<myNumber; i++ )
- {
- double x0 = myXCoord[i],
- y0 = myYCoord[i],
- r = myMarkerSize,
- x, y;
-
- for( int j=0; j<=noPoints; j++ )
- {
- x = x0 + r*cos( double(j)*2*PI/double(noPoints) );
- y = y0 + r*sin( double(j)*2*PI/double(noPoints) );
- aViewerCS->transform( *aEMFCS, x, y );
- if( j==0 )
- MoveToEx( dc, x, y, NULL );
- else
- LineTo( dc, x, y );
- }
- }
-
- SelectObject( dc, old );
- if( pen )
- DeleteObject( pen );
- return true;
-}
-#endif
-
-/*!
- Computes all necessary information about object for presentation in drawer
-*/
-void GLViewer_MarkerSet::compute()
-{
-// cout << "GLViewer_MarkerSet::compute" << endl;
- GLfloat xa = myXCoord[0];
- GLfloat xb = myXCoord[0];
- GLfloat ya = myYCoord[0];
- GLfloat yb = myYCoord[0];
-
- for ( int i = 0; i < myNumber; i++ )
- {
- xa = QMIN( xa, myXCoord[i] );
- xb = QMAX( xb, myXCoord[i] );
- ya = QMIN( ya, myYCoord[i] );
- yb = QMAX( yb, myYCoord[i] );
- }
-
- myXGap = ( xb - xa ) / 10;
- myYGap = ( yb - ya ) / 10;
-
- myRect->setLeft( xa - myXGap );
- myRect->setTop( yb + myYGap );
- myRect->setRight( xb + myXGap );
- myRect->setBottom( ya - myYGap );
-}
-
-/*!
- Creates corresponding drawer
-*/
-GLViewer_Drawer* GLViewer_MarkerSet::createDrawer()
-{
-// cout << "GLViewer_MarkerSet::createDrawer" << endl;
- return myDrawer = new GLViewer_MarkerDrawer();
-}
-
-/*!
- Computes highlight presentation
- \param x - x coord
- \param y - y coord
- \param tol - tolerance of detecting
- \param isCircle - true if sensitive area of detection is round
- \return true if highlight status is changed
-*/
-GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
-{
- if( !myIsVisible )
- return false;
-// cout << "GLViewer_MarkerSet::highlight " << x <<" " << y << " " << tol << endl;
- int count = 0;
- GLfloat xdist, ydist, radius;
- QValueList<int>::Iterator it;
- QValueList<int> curHNumbers;
- bool isFound;
- GLboolean update;
- int cnt = 0;
-
- radius = tol - myMarkerSize / 2.;
-
- myUHNumbers += myHNumbers;
- myHNumbers.clear();
-
- for ( int i = 0; i < myNumber; i++ )
- {
- xdist = ( myXCoord[i] - x ) * myXScale;
- ydist = ( myYCoord[i] - y ) * myYScale;
-
-// if ( isCircle && ( xdist * xdist + ydist * ydist <= radius * radius ) ||
- if ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ||
- !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) )
- {
- isFound = FALSE;
- count++;
- for ( it = myCurSelNumbers.begin(); it != myCurSelNumbers.end(); ++it )
- if( i == *it )
- {
- isFound = TRUE;
- curHNumbers.append( i );
- }
-
- if( !isFound )
- myHNumbers.append( i );
- else
- cnt++;
- }
- }
- myCurSelNumbers = curHNumbers;
-
- myIsHigh = ( GLboolean )count;
- update = ( GLboolean )( myHNumbers != myPrevHNumbers );
-
- myPrevHNumbers = myHNumbers;
-
- //cout << "GLViewer_MarkerSet::highlight complete with " << (int)myIsHigh << endl;
- return update;
-}
-
-/*!
- Unhilights object
-*/
-GLboolean GLViewer_MarkerSet::unhighlight()
-{
- if( !myHNumbers.isEmpty() )
- {
- myUHNumbers += myHNumbers;
- myPrevHNumbers.clear();
- myHNumbers.clear();
- //??? myCurSelNumbers.clear();
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-/*!
- Selects marker set
- /param x, y - co-ordinates of mouse
- /param tol - tolerance
- /param rect - rectangle (in case of rectangular selection)
- /param isFull - if it is true, then object may selected only if it lays whole in selection zone
- \param isCircle - true if sensitive area of detection is round
- \param isShift - true if selection exec with append option
-*/
-GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
- GLboolean isCircle, GLboolean isShift )
-{
- if( !myIsVisible )
- return false;
-// cout << "GLViewer_MarkerSet::select " << x << " " << y << endl;
- int count = 0;
- GLfloat xdist, ydist, radius;
- QValueList<int>::Iterator it;
- QValueList<int>::Iterator it1;
- QValueList<int>::Iterator remIt;
- QValueList<int>::Iterator curIt;
-
- radius = tol - myMarkerSize / 2.;
-
- if( radius < myMarkerSize / 2.)
- radius = myMarkerSize / 2.;
-
- count = isShift ? mySelNumbers.count() : 0;
-
- myUSelNumbers = mySelNumbers;
-
- if ( !isShift )
- {
- mySelNumbers.clear();
- myCurSelNumbers.clear();
- }
-
- for ( int i = 0; i < myNumber; i++ )
- {
- xdist = ( myXCoord[i] - x ) * myXScale;
- ydist = ( myYCoord[i] - y ) * myYScale;
-
- //if ( isCircle && ( xdist * xdist + ydist * ydist <= radius * radius ) ||
- if ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ||
- !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) )
- {
- count++;
- if ( isShift )
- {
- bool isFound = FALSE;
- for( it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
- if ( *it == i )
- {
- myUSelNumbers.append( *it );
- remIt = it;
- isFound = TRUE;
- break;
- }
-
- if ( !isFound )
- {
- mySelNumbers.append( i );
- myCurSelNumbers.append( i );
- for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 )
- if( i == *it1 )
- {
- myHNumbers.remove( it1 );
- break;
- }
- for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 )
- if( i == *it1 )
- {
- myUHNumbers.remove( it1 );
- break;
- }
- }
- else
- {
- mySelNumbers.remove( remIt );
- for ( curIt = myCurSelNumbers.begin(); curIt != myCurSelNumbers.end(); ++curIt )
- if( *curIt == *remIt)
- {
- myCurSelNumbers.remove( curIt );
- break;
- }
- for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 )
- if( i == *it1 )
- {
- myHNumbers.remove( it1 );
- break;
- }
- for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 )
- if( i == *it1 )
- {
- myUHNumbers.remove( it1 );
- break;
- }
- }
- }
- else
- {
- mySelNumbers.append( i );
- myCurSelNumbers.append( i );
- for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 )
- if( i == *it1 )
- {
- myHNumbers.remove( it1 );
- break;
- }
- for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 )
- if( i == *it1 )
- {
- myUHNumbers.remove( it1 );
- break;
- }
- }
- }
- }
-
- for( it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
- for( it1 = myUSelNumbers.begin(); it1 != myUSelNumbers.end(); ++it1 )
- if( *it == *it1 )
- {
- it1 = myUSelNumbers.remove( it1 );
- it1--;
- }
-
- myIsSel = (GLboolean)count;
-
-// cout << "GLViewer_MarkerSet::select complete with " << (int)myIsSel << endl;
- return myIsSel;
-}
-
-/*!
- Unselects marker set
-*/
-GLboolean GLViewer_MarkerSet::unselect()
-{
- if( !mySelNumbers.isEmpty() )
- {
- myUSelNumbers = mySelNumbers;
- mySelNumbers.clear();
- myCurSelNumbers.clear();
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-/*!
- \return update object rectangle
- Does not equal getRect() if object have a persistence to some viewer transformations
-*/
-GLViewer_Rect* GLViewer_MarkerSet::getUpdateRect()
-{
- GLViewer_Rect* rect = new GLViewer_Rect();
-
- rect->setLeft( myRect->left() + myXGap - myMarkerSize / myXScale );
- rect->setTop( myRect->top() + myYGap + myMarkerSize / myYScale );
- rect->setRight( myRect->right() - myXGap + myMarkerSize / myXScale );
- rect->setBottom( myRect->bottom() - myYGap - myMarkerSize / myYScale );
- //cout << " Additional tolerance " << myMarkerSize / myYScale << endl;
- //rect->setLeft( myRect->left() - myMarkerSize / myXScale );
- //rect->setTop( myRect->top() - myMarkerSize / myYScale );
- //rect->setRight( myRect->right() + myMarkerSize / myXScale );
- //rect->setBottom( myRect->bottom() + myMarkerSize / myYScale );
-
- return rect;
-}
-
-/*!
- Sets array of x coords of points
- \param xCoord - array of co-ordinates
- \param size - array size
-*/
-void GLViewer_MarkerSet::setXCoord( GLfloat* xCoord, int size )
-{
- myXCoord = new GLfloat[ size ];
- for( int i = 0; i < size; i++ )
- myXCoord[i] = xCoord[i];
-}
-
-/*!
- Sets array of y coords of points
- \param yCoord - array of co-ordinates
- \param size - array size
-*/
-void GLViewer_MarkerSet::setYCoord( GLfloat* yCoord, int size )
-{
- myYCoord = new GLfloat[ size ];
- for( int i = 0; i < size; i++ )
- myYCoord[i] = yCoord[i];
-}
-
-/*!
- Sets number of markers
- \param number - new number of markers
-*/
-void GLViewer_MarkerSet::setNumMarkers( GLint number )
-{
- if ( myNumber == number )
- return;
-
- if ( myXCoord && myYCoord )
- {
- delete[] myXCoord;
- delete[] myYCoord;
- }
-
- myNumber = number;
- myXCoord = new GLfloat[ myNumber ];
- myYCoord = new GLfloat[ myNumber ];
-}
-
-
-/*!
- Export numbers of highlighted/selected lines
-*/
-void GLViewer_MarkerSet::exportNumbers( QValueList<int>& highlight,
- QValueList<int>& unhighlight,
- QValueList<int>& select,
- QValueList<int>& unselect )
-{
- highlight = myHNumbers;
- unhighlight = myUHNumbers;
- select = mySelNumbers;
- unselect = myUSelNumbers;
-
- myUHNumbers = myHNumbers;
-}
-
-/*!
- Adds or remove selected number
- \param index - selected index
-*/
-bool GLViewer_MarkerSet::addOrRemoveSelected( int index )
-{
- if( index < 0 || index > myNumber )
- return FALSE;
-
- int n = mySelNumbers.findIndex( index );
- if( n == -1 )
- mySelNumbers.append( index );
- else
- {
- QValueList<int>::Iterator it;
- it = mySelNumbers.at( n );
- mySelNumbers.remove( it );
- myUSelNumbers.append( index );
- }
- return TRUE;
-}
-
-/*!
- Adds some selected numbers
- \param seq - sequence of indices
-*/
-void GLViewer_MarkerSet::addSelected( const TColStd_SequenceOfInteger& seq )
-{
- for ( int i = 1; i <= seq.Length(); i++ )
- if( mySelNumbers.findIndex( seq.Value( i ) ) == -1 )
- mySelNumbers.append( seq.Value( i ) - 1 );
-}
-
-/*!
- Sets some numbers as selected
- \param seq - sequence of indices
-*/
-void GLViewer_MarkerSet::setSelected( const TColStd_SequenceOfInteger& seq )
-{
-// for( QValueList<int>::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
-// if( myUSelNumbers.findIndex( *it ) == -1 )
-// myUSelNumbers.append( *it );
-
- myUSelNumbers = mySelNumbers;
- mySelNumbers.clear();
-
- for ( int i = 1; i <= seq.Length(); i++ )
- mySelNumbers.append( seq.Value( i ) - 1 );
-}
-
-/*! Moves object by recomputing
- \param dx - moving along X coord
- \param dy - moving along Y coord
- \param fromGroup - is true if this method called from group
-*/
-void GLViewer_MarkerSet::moveObject( float theX, float theY, bool fromGroup )
-{
- if( !fromGroup && myGroup)
- {
- myGroup->dragingObjects( theX, theY );
- return;
- }
- for( int i = 0; i < myNumber; i++ )
- {
- myXCoord[i] = myXCoord[i] + theX;
- myYCoord[i] = myYCoord[i] + theY;
- }
- compute();
-}
-
-/*!
- Codes marker set as byte copy
- \return byte array
-*/
-QByteArray GLViewer_MarkerSet::getByteCopy()
-{
- int i = 0;
- int anISize = sizeof( GLint );
- int aFSize = sizeof( GLfloat );
-
- QByteArray aObject = GLViewer_Object::getByteCopy();
-
- QByteArray aResult( anISize + 2*aFSize*myNumber + aFSize + aObject.size());
-
- char* aPointer = (char*)&myNumber;
- for( i = 0; i < anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)myXCoord;
- for( ; i < anISize + aFSize*myNumber; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)myYCoord;
- for( ; i < anISize + 2*aFSize*myNumber; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&myMarkerSize;
- for( ; i < anISize + 2*aFSize*myNumber + aFSize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
-
- for ( ; i < (int)aResult.size(); i++ )
- aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - aFSize];
-
- return aResult;
-}
-
-/*!
- Initialize marker set by byte array
- \param theArray - byte array
-*/
-bool GLViewer_MarkerSet::initializeFromByteCopy( QByteArray theArray )
-{
- int i = 0;
- int anISize = sizeof( GLint );
- int aFSize = sizeof( GLfloat );
-
- char* aPointer = (char*)&myNumber;
- for( i = 0; i < anISize; i++, aPointer++ )
- *aPointer = theArray[i];
-
- int aSize = theArray.size();
- if( aSize < anISize + 2*aFSize*myNumber + aFSize)
- return false;
-
- myXCoord = new GLfloat[myNumber];
- myYCoord = new GLfloat[myNumber];
- aPointer = (char*)myXCoord;
- for( ; i < anISize + aFSize*myNumber; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)myYCoord;
- for( ; i < anISize + 2*aFSize*myNumber; i++, aPointer++ )
- *aPointer = theArray[i];
-
- aPointer = (char*)&myMarkerSize;
- for( ; i < anISize + 2*aFSize*myNumber + aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
-
- int aCurIndex = anISize + 2*aFSize*myNumber + aFSize;
- QByteArray aObject( aSize - aCurIndex );
- for( ; i < aSize; i++ )
- aObject[i - aCurIndex] = theArray[i];
-
-
- if( !GLViewer_Object::initializeFromByteCopy( aObject ) || myType != "GLViewer_MarkerSet" )
- return false;
-
- myHNumbers.clear();
- myUHNumbers.clear();
- mySelNumbers.clear();
- myUSelNumbers.clear();
- myCurSelNumbers.clear();
- myPrevHNumbers.clear();
-
- return true;
-}
-
-/*!
- \class GLViewer_Polyline
- OpenGL Polyline
-*/
-
-#define SECTIONS 100
-#define DISTANTION 5
-
-/*!
- Constructor
- \param number - number of segments
- \param size - size of polyline
- \param toolTip - tool tip of polyline
-*/
-GLViewer_Polyline::GLViewer_Polyline( int number, float size, const QString& toolTip ):
- GLViewer_Object(),
- myNumber( 0 ),
- myXCoord( 0 ),
- myYCoord( 0 )
-{
- myHighFlag = GL_TRUE;
-
- myHNumbers.clear();
- myUHNumbers.clear();
- mySelNumbers.clear();
- myUSelNumbers.clear();
- myCurSelNumbers.clear();
- myPrevHNumbers.clear();
-
- setNumber( number );
-
- myType = "GLViewer_Polyline";
- myToolTipText = toolTip;
-}
-
-/*!
- Destructor, destroys internal arrays of co-ordinates
-*/
-GLViewer_Polyline::~GLViewer_Polyline()
-{
- if ( myXCoord )
- delete[] myXCoord;
- if ( myYCoord )
- delete[] myYCoord;
-}
-
-/*!
- Saves polyline to file PostScript
- \param hFile - file instance
- \param aViewerCS - viewer co-ordinates system
- \param aPSCS - paper co-ordinates system
-*/
-bool GLViewer_Polyline::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
-{
- QString aBuffer = "newpath\n";
-
- AddLineAspectToPS( aBuffer, getAspectLine(), aViewerCS, aPSCS );
-
- for( int i=0; i<myNumber; i++ )
- if( i==0 )
- AddCoordsToPS( aBuffer, "moveto", aViewerCS, aPSCS, myXCoord[i], myYCoord[i] );
- else
- AddCoordsToPS( aBuffer, "lineto", aViewerCS, aPSCS, myXCoord[i], myYCoord[i] );
-
- if( myIsClosed )
- AddCoordsToPS( aBuffer, "lineto", aViewerCS, aPSCS, myXCoord[0], myYCoord[0] );
-
- aBuffer+="closepath\nstroke\n";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
-
- return true;
-}
-
-/*!
- Saves polyline to file HPGL
- \param hFile - file instance
- \param aViewerCS - viewer co-ordinates system
- \param aHPGLCS - paper co-ordinates system
-*/
-bool GLViewer_Polyline::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
-{
- QString aBuffer = "";
- for( int i=0; i<myNumber; i++ )
- {
- AddCoordsToHPGL( aBuffer, "PA", aViewerCS, aHPGLCS, myXCoord[i], myYCoord[i] );
- if( i==0 )
- aBuffer+="PD;\n";
- }
-
- if( myIsClosed )
- AddCoordsToHPGL( aBuffer, "PA", aViewerCS, aHPGLCS, myXCoord[0], myYCoord[0] );
-
- aBuffer+="PU;\n";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
-
- return true;
-}
-
-#ifdef WIN32
-/*!
- Saves polyline to EMF image
- \param dc - EMF image descriptor
- \param aViewerCS - viewer co-ordinates system
- \param aEMFCS - paper co-ordinates system
-*/
-bool GLViewer_Polyline::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
-{
- if( !aViewerCS || !aEMFCS )
- return false;
-
- HPEN pen = AddLineAspectToEMF( dc, getAspectLine(), aViewerCS, aEMFCS );
- HGDIOBJ old = SelectObject( dc, pen );
-
- double x, y;
- for( int i=0; i<myNumber; i++ )
- {
- x = myXCoord[i];
- y = myYCoord[i];
- aViewerCS->transform( *aEMFCS, x, y );
- if( i==0 )
- MoveToEx( dc, x, y, NULL );
- else
- LineTo( dc, x, y );
- }
-
- if( myIsClosed )
- {
- x = myXCoord[0];
- y = myYCoord[0];
- aViewerCS->transform( *aEMFCS, x, y );
- LineTo( dc, x, y );
- }
-
- SelectObject( dc, old );
- if( pen )
- DeleteObject( pen );
-
- return true;
-}
-#endif
-
-/*!
- Computes all necessary information about object for presentation in drawer
-*/
-void GLViewer_Polyline::compute()
-{
-// cout << "GLViewer_MarkerSet::compute" << endl;
- GLfloat xa = myXCoord[0];
- GLfloat xb = myXCoord[0];
- GLfloat ya = myYCoord[0];
- GLfloat yb = myYCoord[0];
-
- for ( int i = 0; i < myNumber; i++ )
- {
- xa = QMIN( xa, myXCoord[i] );
- xb = QMAX( xb, myXCoord[i] );
- ya = QMIN( ya, myYCoord[i] );
- yb = QMAX( yb, myYCoord[i] );
- }
-
- GLfloat xGap = ( xb - xa ) / 10;
- GLfloat yGap = ( yb - ya ) / 10;
-
- myRect->setLeft( xa - xGap );
- myRect->setTop( yb + yGap );
- myRect->setRight( xb + xGap );
- myRect->setBottom( ya - yGap );
-}
-
-/*!
- \return update object rectangle
- Does not equal getRect() if object have a persistence to some viewer transformations
-*/
-GLViewer_Rect* GLViewer_Polyline::getUpdateRect()
-{
- GLViewer_Rect* rect = new GLViewer_Rect();
-
- rect->setLeft( myRect->left() - myXGap );
- rect->setTop( myRect->top() + myYGap );
- rect->setRight( myRect->right() + myXGap );
- rect->setBottom( myRect->bottom() - myYGap );
-
- return rect;
-}
-
-/*!
- Creates corresponding drawer
-*/
-GLViewer_Drawer* GLViewer_Polyline::createDrawer()
-{
-// cout << "GLViewer_MarkerSet::createDrawer" << endl;
- return myDrawer = new GLViewer_PolylineDrawer();
-}
-
-/*!
- Computes highlight presentation
- \param x - x coord
- \param y - y coord
- \param tol - tolerance of detecting
- \param isCircle - true if sensitive area of detection is round
- \return true if highlight status is changed
-*/
-GLboolean GLViewer_Polyline::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
-{
- if( !myIsVisible )
- return false;
- GLfloat xa, xb, ya, yb, l;
- GLfloat rsin, rcos, r, ra, rb;
- GLboolean update;
- GLboolean highlighted = myIsHigh;
-
- myIsHigh = GL_FALSE;
-
- int c = 0;
- if( myIsClosed )
- c = 1;
-
- for( int i = 0; i < myNumber-1+c; i++ )
- {
- xa = myXCoord[i];
- ya = myYCoord[i];
- if( i != myNumber-1 )
- {
- xb = myXCoord[i+1];
- yb = myYCoord[i+1];
- }
- else
- {
- xb = myXCoord[0];
- yb = myYCoord[0];
- }
-
- l = sqrt( (xb-xa)*(xb-xa) + (yb-ya)*(yb-ya) );
- rsin = (yb-ya) / l;
- rcos = (xb-xa) / l;
- r = ( (x-xa)*(y-yb) - (x-xb)*(y-ya) ) / ( rsin*(ya-yb) + rcos*(xa-xb) );
- ra = sqrt( (x-xa)*(x-xa) + (y-ya)*(y-ya) );
- rb = sqrt( (x-xb)*(x-xb) + (y-yb)*(y-yb) );
- if( fabs( r ) * myXScale <= DISTANTION && ra <= l + DISTANTION && rb <= l + DISTANTION )
- {
- myIsHigh = GL_TRUE;
- break;
- }
- }
-
- if( !myHighFlag && myIsHigh )
- myIsHigh = GL_FALSE;
- else
- myHighFlag = GL_TRUE;
-
- update = ( GLboolean )( myIsHigh != highlighted );
-
-// cout << "GLViewer_Polyline::highlight complete with " << (int)myIsHigh << endl;
- return update;
-}
-
-/*!
- Unhilights object
-*/
-GLboolean GLViewer_Polyline::unhighlight()
-{
-// if( !myHNumbers.isEmpty() )
-// {
-// myUHNumbers = myHNumbers;
-// myHNumbers.clear();
-// return GL_TRUE;
-// }
-
- if( myIsHigh )
- {
- myIsHigh = GL_FALSE;
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-/*!
- Selects polyline
- /param x, y - co-ordinates of mouse
- /param tol - tolerance
- /param rect - rectangle (in case of rectangular selection)
- /param isFull - if it is true, then object may selected only if it lays whole in selection zone
- \param isCircle - true if sensitive area of detection is round
- \param isShift - true if selection exec with append option
-*/
-GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
- GLboolean isCircle, GLboolean isShift )
-{
- if( !myIsVisible )
- return false;
- GLfloat xa, xb, ya, yb, l;
- GLfloat rsin, rcos, r, ra, rb;
- GLboolean update;
- GLboolean selected = myIsSel;
-
- myIsSel = GL_FALSE;
-
- int c = 0;
- if( myIsClosed )
- c = 1;
-
- for( int i = 0; i < myNumber-1+c; i++ )
- {
- xa = myXCoord[i];
- ya = myYCoord[i];
- if( i != myNumber-1 )
- {
- xb = myXCoord[i+1];
- yb = myYCoord[i+1];
- }
- else
- {
- xb = myXCoord[0];
- yb = myYCoord[0];
- }
-
- l = sqrt( (xb-xa)*(xb-xa) + (yb-ya)*(yb-ya) );
- rsin = (yb-ya) / l;
- rcos = (xb-xa) / l;
- r = ( (x-xa)*(y-yb) - (x-xb)*(y-ya) ) / ( rsin*(ya-yb) + rcos*(xa-xb) );
- ra = sqrt( (x-xa)*(x-xa) + (y-ya)*(y-ya) );
- rb = sqrt( (x-xb)*(x-xb) + (y-yb)*(y-yb) );
- if( fabs( r ) * myXScale <= DISTANTION && ra <= l + DISTANTION && rb <= l + DISTANTION )
- {
- myIsSel = GL_TRUE;
- break;
- }
- }
-
- if ( myIsSel )
- {
- myHighFlag = GL_FALSE;
- myIsHigh = GL_FALSE;
- }
- else
- myHighFlag = GL_TRUE;
-
- update = ( GLboolean )( myIsSel != selected );
-
- // cout << "GLViewer_Polyline::select complete with " << (int)myIsSel << endl;
-
- // return update; !!!!!!!!!!!!!!!!!!!!!!!!!!! no here
- return myIsSel;
-}
-
-/*!
- Unselects polyline
-*/
-GLboolean GLViewer_Polyline::unselect()
-{
-// if( !mySelNumbers.isEmpty() )
-// {
-// myUSelNumbers = mySelNumbers;
-// mySelNumbers.clear();
-// myCurSelNumbers.clear();
-// return GL_TRUE;
-// }
-
- if( myIsSel )
- {
- myIsSel = GL_FALSE;
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-/*!
- Sets array of abscisses for points of polyline
- \param xCoord - array of of abscisses
- \param size - size of array
-*/
-void GLViewer_Polyline::setXCoord( GLfloat* xCoord, int size )
-{
- myXCoord = new GLfloat[ size ];
- for( int i = 0; i < size; i++ )
- myXCoord[i] = xCoord[i];
-}
-
-/*!
- Sets array of ordinates for points of polyline
- \param xCoord - array of of ordinates
- \param size - size of array
-*/
-void GLViewer_Polyline::setYCoord( GLfloat* yCoord, int size )
-{
- myYCoord = new GLfloat[ size ];
- for( int i = 0; i < size; i++ )
- myYCoord[i] = yCoord[i];
-}
-
-/*!
- Sets number of points
- \param number - new number of points
-*/
-void GLViewer_Polyline::setNumber( GLint number )
-{
- if ( myNumber == number )
- return;
-
- if ( myXCoord && myYCoord )
- {
- delete[] myXCoord;
- delete[] myYCoord;
- }
-
- myNumber = number;
- myXCoord = new GLfloat[ myNumber ];
- myYCoord = new GLfloat[ myNumber ];
-}
-
-/*!
- Export numbers of highlighted/selected lines
-*/
-void GLViewer_Polyline::exportNumbers( QValueList<int>& highlight,
- QValueList<int>& unhighlight,
- QValueList<int>& select,
- QValueList<int>& unselect )
-{
- highlight = myHNumbers;
- unhighlight = myUHNumbers;
- select = mySelNumbers;
- unselect = myUSelNumbers;
-}
-
-/*!
- Moves object by recomputing
- \param dx - moving along X coord
- \param dy - moving along Y coord
- \param fromGroup - is true if this method called from group
-*/
-void GLViewer_Polyline::moveObject( float theX, float theY, bool fromGroup )
-{
- if( !fromGroup && myGroup)
- {
- myGroup->dragingObjects( theX, theY );
- return;
- }
- for( int i = 0; i < myNumber; i++ )
- {
- myXCoord[i] = myXCoord[i] + theX;
- myYCoord[i] = myYCoord[i] + theY;
- }
- compute();
-}
-
-/*!
- Codes polyline as byte copy
- \return byte array
-*/
-QByteArray GLViewer_Polyline::getByteCopy()
-{
- int i = 0;
- int anISize = sizeof( GLint );
- int aFSize = sizeof( GLfloat );
- int aBSize = sizeof( GLboolean );
-
- QByteArray aObject = GLViewer_Object::getByteCopy();
-
- QByteArray aResult( aFSize*myNumber*2 + anISize + 2*aBSize + aObject.size());
-
- char* aPointer = (char*)&myNumber;
- for( i = 0; i < anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)myXCoord;
- for( ; i < anISize + aFSize*myNumber; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)myYCoord;
- for( ; i < anISize + 2*aFSize*myNumber; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&myIsClosed;
- for( ; i < anISize + 2*aFSize*myNumber + aBSize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&myHighSelAll;
- for( ; i < anISize + 2*aFSize*myNumber + 2*aBSize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- for ( ; i < (int)aResult.size(); i++ )
- aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - 2*aBSize];
-
- return aResult;
-}
-
-
-/*!
- Initialize polyline by byte array
- \param theArray - byte array
-*/
-bool GLViewer_Polyline::initializeFromByteCopy( QByteArray theArray )
-{
- int i = 0;
- int anISize = sizeof( GLint );
- int aFSize = sizeof( GLfloat );
- int aBSize = sizeof( GLboolean );
-
- char* aPointer = (char*)&myNumber;
- for( i = 0; i < anISize; i++, aPointer++ )
- *aPointer = theArray[i];
-
- int aSize = theArray.size();
- if( aSize < aFSize*myNumber*2 + anISize + 2*aBSize )
- return false;
-
- myXCoord = new GLfloat[myNumber];
- myYCoord = new GLfloat[myNumber];
- aPointer = (char*)myXCoord;
- for( ; i < anISize + aFSize*myNumber; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)myYCoord;
- for( ; i < anISize + 2*aFSize*myNumber; i++, aPointer++ )
- *aPointer = theArray[i];
-
- aPointer = (char*)&myIsClosed;
- for( ; i < anISize + 2*aFSize*myNumber + aBSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&myHighSelAll;
- for( ; i < anISize + 2*aFSize*myNumber + 2*aBSize; i++, aPointer++ )
- *aPointer = theArray[i];
-
- int aCurIndex = anISize + 2*aFSize*myNumber + 2*aBSize;
- QByteArray aObject( aSize - aCurIndex );
- for( ; i < aSize; i++ )
- aObject[i - aCurIndex] = theArray[i];
-
- if( !GLViewer_Object::initializeFromByteCopy( aObject ) || myType != "GLViewer_Polyline" )
- return false;
-
- myHNumbers.clear();
- myUHNumbers.clear();
- mySelNumbers.clear();
- myUSelNumbers.clear();
- myCurSelNumbers.clear();
- myPrevHNumbers.clear();
-
- return true;
-}
-
-
-
-/*!
- Constructor
- \param theStr - text string
- \param xPos - x position
- \param yPos - y position
- \param color - color of text
- \param toolTip - tooltip of text object
-*/
-GLViewer_TextObject::GLViewer_TextObject( const QString& theStr, float xPos, float yPos,
- const QColor& color, const QString& toolTip )
- : GLViewer_Object()
-{
- myGLText = new GLViewer_Text( theStr, xPos, yPos, color );
- myWidth = 0;
- myHeight = 0;
-
- myHighFlag = GL_TRUE;
-
- myToolTipText = toolTip;
-}
-
-/*!
- Destructor
-*/
-GLViewer_TextObject::~GLViewer_TextObject()
-{
- if ( myGLText )
- delete myGLText;
-}
-
-/*!
- Saves text object to file PostScript
- \param hFile - file instance
- \param aViewerCS - viewer co-ordinates system
- \param aPSCS - paper co-ordinates system
-*/
-bool GLViewer_TextObject::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
-{
- QString aText = myGLText->getText();
- float xPos, yPos;
- myGLText->getPosition( xPos, yPos );
-
- QString aBuffer = "/Times-Roman findfont\n";
- aBuffer += "12 scalefont setfont\n";
-
- AddCoordsToPS( aBuffer, "moveto", aViewerCS, aPSCS, double(xPos), double(yPos) );
- aBuffer += "(" + aText + ") show\n";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
-
- return true;
-}
-
-/*!
- Saves text object to file HPGL
- \param hFile - file instance
- \param aViewerCS - viewer co-ordinates system
- \param aHPGLCS - paper co-ordinates system
-*/
-bool GLViewer_TextObject::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
-{
- QString aText = myGLText->getText();
- float xPos, yPos;
- myGLText->getPosition( xPos, yPos );
-
- QString aBuffer = "";
- AddCoordsToHPGL( aBuffer, "PA", aViewerCS, aHPGLCS, double(xPos), double(yPos) );
-
- aBuffer = "LB" + aText + "#;";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
-
- return true;
-}
-
-#ifdef WIN32
-/*!
- Saves text object to EMF image
- \param dc - EMF image descriptor
- \param aViewerCS - viewer co-ordinates system
- \param aEMFCS - paper co-ordinates system
-*/
-bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
-{
- QString aText = myGLText->getText();
- float xPos, yPos;
- myGLText->getPosition( xPos, yPos );
-
- double x = double( xPos ),
- y = double( yPos );
-
- aViewerCS->transform( *aEMFCS, x, y );
- const char* str = aText.ascii();
-
- int nHeight = 35*14; // height of font
- int nWidth = 35*12; // average character width
- int nEscapement = 0; // angle of escapement
- int nOrientation = 0; // base-line orientation angle
- int fnWeight = FW_NORMAL; // font weight
- DWORD fdwItalic = FALSE; // italic attribute option
- DWORD fdwUnderline = FALSE; // underline attribute option
- DWORD fdwStrikeOut = FALSE; // strikeout attribute option
- DWORD fdwCharSet = ANSI_CHARSET; // character set identifier
- DWORD fdwOutputPrecision = OUT_DEFAULT_PRECIS; // output precision
- DWORD fdwClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
- DWORD fdwQuality = PROOF_QUALITY; // output quality
- DWORD fdwPitchAndFamily = FIXED_PITCH | FF_DONTCARE; // pitch and family
- LPCTSTR lpszFace = NULL; // typeface name
-
-
- HFONT aFont = CreateFont( nHeight, nWidth, nEscapement, nOrientation, fnWeight, fdwItalic,
- fdwUnderline, fdwStrikeOut, fdwCharSet, fdwOutputPrecision,
- fdwClipPrecision, fdwQuality, fdwPitchAndFamily, lpszFace );
- LOGBRUSH aBrushData;
- aBrushData.lbStyle = BS_HOLLOW;
-
- HBRUSH aBrush = CreateBrushIndirect( &aBrushData );
-
- HGDIOBJ old1 = SelectObject( dc, aFont );
- HGDIOBJ old2 = SelectObject( dc, aBrush );
-
- TextOut( dc, x, y, str, aText.length() );
-
- SelectObject ( dc, old1 );
- SelectObject ( dc, old2 );
-
- DeleteObject( aFont );
-
- return true;
-}
-#endif
-
-/*!
- Creates corresponding drawer
-*/
-GLViewer_Drawer* GLViewer_TextObject::createDrawer()
-{
- myDrawer = new GLViewer_TextDrawer();
- compute();
- return myDrawer;
-}
-
-/*!
- Computes all necessary information about object for presentation in drawer
-*/
-void GLViewer_TextObject::compute()
-{
- float xPos, yPos;
- QString aStr = myGLText->getText();
- myGLText->getPosition( xPos, yPos );
-
- myWidth = myGLText->getWidth();
- myHeight = myGLText->getHeight();
- myRect->setLeft( xPos );
- myRect->setTop( yPos + myHeight );
- myRect->setRight( xPos + myWidth );
- myRect->setBottom( yPos );
-}
-
-/*!
- Installing already exist drawer with same type
- \param theDrawer - new drawer
-*/
-void GLViewer_TextObject::setDrawer( GLViewer_Drawer* theDrawer )
-{
- myDrawer = theDrawer;
- //compute();
-}
-
-/*!
- \return update object rectangle
- Does not equal getRect() if object have a persistence to some viewer transformations
-*/
-GLViewer_Rect* GLViewer_TextObject::getUpdateRect()
-{
- GLViewer_Rect* rect = new GLViewer_Rect();
-
- float xPos, yPos;
- QString aStr = myGLText->getText();
- myGLText->getPosition( xPos, yPos );
-
- rect->setLeft( myRect->left() + myXGap - myWidth / myXScale );
- rect->setTop( myRect->top() + myYGap + myHeight / myYScale );
- rect->setRight( myRect->right() - myXGap + myWidth / myXScale );
- rect->setBottom( myRect->bottom() - myYGap - myHeight / myYScale );
-
- return rect;
-}
-
-/*!
- Computes highlight presentation
- \param x - x coord
- \param y - y coord
- \param tol - tolerance of detecting
- \param isCircle - true if sensitive area of detection is round
- \return true if highlight status is changed
-*/
-GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat theTol, GLboolean isCircle )
-{
- if( !myIsVisible )
- return false;
-
- float xPos, yPos;
- myGLText->getPosition( xPos, yPos );
-
- QRect aRect;
- aRect.setLeft( (int)xPos );
- aRect.setRight( (int)(xPos + myWidth / myXScale) );
- aRect.setTop( (int)yPos );// - myHeight / myYScale );
- aRect.setBottom( (int)(yPos + myHeight / myYScale) );
-
- //cout << "theX: " << theX << " theY: " << theY << endl;
- //cout << "aRect.left(): " << aRect.left() << " aRect.right(): " << aRect.right() << endl;
- //cout << "aRect.top(): " << aRect.top() << " aRect.bottom(): " << aRect.bottom() << endl;
-
- QRegion obj( aRect );
- QRegion intersection;
- QRect region;
-
- region.setLeft( (int)(theX - theTol) );
- region.setRight( (int)(theX + theTol) );
- region.setTop( (int)(theY - theTol) );
- region.setBottom( (int)(theY + theTol) );
-
- QRegion circle( (int)(theX - theTol), (int)(theY - theTol),
- (int)(2 * theTol), (int)(2 * theTol), QRegion::Ellipse );
- if( isCircle )
- intersection = obj.intersect( circle );
- else
- intersection = obj.intersect( region );
-
- if( intersection.isEmpty() )
- myIsHigh = false;
- else
- myIsHigh = true;
-
- if( !myHighFlag && myIsHigh )
- myIsHigh = GL_FALSE;
- else
- myHighFlag = GL_TRUE;
-
- return myIsHigh;
-}
-
-/*!
- Unhilights object
-*/
-GLboolean GLViewer_TextObject::unhighlight()
-{
- if( myIsHigh )
- {
- myIsHigh = GL_FALSE;
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-/*!
- Selects text object
- /param x, y - co-ordinates of mouse
- /param tol - tolerance
- /param rect - rectangle (in case of rectangular selection)
- /param isFull - if it is true, then object may selected only if it lays whole in selection zone
- \param isCircle - true if sensitive area of detection is round
- \param isShift - true if selection exec with append option
-*/
-GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTol, GLViewer_Rect rect,
- GLboolean isFull, GLboolean isCircle, GLboolean isShift )
-{
- if( !myIsVisible )
- return false;
-
- QRegion obj( myRect->toQRect() );
- QRegion intersection;
- QRect region;
-
- region.setLeft( (int)(theX - theTol) );
- region.setRight( (int)(theX + theTol) );
- region.setTop( (int)(theY - theTol) );
- region.setBottom( (int)(theY + theTol) );
-
- QRegion circle( (int)(theX - theTol), (int)(theY - theTol),
- (int)(2 * theTol), (int)(2 * theTol), QRegion::Ellipse );
- if( isCircle )
- intersection = obj.intersect( circle );
- else
- intersection = obj.intersect( region );
-
- if( intersection.isEmpty() )
- myIsSel = false;
- else
- myIsSel = true;
-
- if ( myIsSel )
- {
- myHighFlag = GL_FALSE;
- myIsHigh = GL_FALSE;
- }
- else
- myHighFlag = GL_TRUE;
-
- return myIsSel;
-}
-
-/*!
- Unselects text object
-*/
-GLboolean GLViewer_TextObject::unselect()
-{
- if( myIsSel )
- {
- myIsSel = GL_FALSE;
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-/*!
- Moves object by recomputing
- \param dx - moving along X coord
- \param dy - moving along Y coord
- \param fromGroup - is true if this method called from group
-*/
-void GLViewer_TextObject::moveObject( float theX, float theY, bool fromGroup )
-{
- if( !fromGroup && myGroup)
- {
- myGroup->dragingObjects( theX, theY );
- return;
- }
- float aX, anY;
- myGLText->getPosition( aX, anY );
- aX += theX;
- anY += theY;
- myGLText->setPosition( aX, anY );
- compute();
-}
-
-/*!
- Codes text object as byte copy
- \return byte array
-*/
-QByteArray GLViewer_TextObject::getByteCopy()
-{
- QByteArray aObject = GLViewer_Object::getByteCopy();
-
- return aObject;
-}
-
-/*!
- Initialize text object by byte array
- \param theArray - byte array
-*/
-bool GLViewer_TextObject::initializeFromByteCopy( QByteArray theArray )
-{
- if( !GLViewer_Object::initializeFromByteCopy( theArray ) || myType != "GLViewer_TextObject" )
- return false;
-
- myHighFlag = true;
- return true;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_BaseObjects.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_BASEOBJECTS_H
-#define GLVIEWER_BASEOBJECTS_H
-
-#include "GLViewer.h"
-#include "GLViewer_Object.h"
-
-#include <qcolor.h>
-#include <qvaluelist.h>
-
-#include <TColStd_SequenceOfInteger.hxx>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_MarkerSet
- OpenGL MarkerSet
-*/
-class GLVIEWER_API GLViewer_MarkerSet : public GLViewer_Object
-{
-public:
- //! A constructor
- GLViewer_MarkerSet( int number = 1, float size = 5.0, const QString& toolTip = "GLMarker" );
- //! A destructor
- ~GLViewer_MarkerSet();
-
- // redefined methods
- virtual void compute();
- virtual GLViewer_Drawer* createDrawer();
-
- virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
- virtual GLboolean unhighlight();
- virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
- GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
- virtual GLboolean unselect();
-
- virtual GLViewer_Rect* getUpdateRect();
-
- virtual void moveObject( float, float, bool fromGroup = false );
-
- virtual QByteArray getByteCopy();
- virtual bool initializeFromByteCopy( QByteArray );
-
- virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
- virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );
-
-#ifdef WIN32
- virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
-#endif
-
- //! Sets array of x coords of markers
- void setXCoord( GLfloat* xCoord, int size );
- //! Sets array of y coords of markers
- void setYCoord( GLfloat* yCoord, int size );
- //! Returns x coords
- GLfloat* getXCoord() const { return myXCoord; }
- //! Returns y coords
- GLfloat* getYCoord() const { return myYCoord; }
-
- //! Sets markers number
- void setNumMarkers( GLint );
- //! returns markers number
- GLint getNumMarkers() const { return myNumber; };
- //! Sets merker radius
- void setMarkerSize( const float size ) { myMarkerSize = size; }
- //! Returns merker radius
- float getMarkerSize() const { return myMarkerSize; }
-
- //! Export numbers of heghlighted/selected markers
- void exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
- QValueList<int>& sel, QValueList<int>& unsel );
-
- //! Returns selected numbers
- QValueList<int> getSelectedElements() { return mySelNumbers; }
- //! Adds or remove selected number
- bool addOrRemoveSelected( int index );
- //! Adds selected numbers
- void addSelected( const TColStd_SequenceOfInteger& );
- //! Sets selected nembers
- void setSelected( const TColStd_SequenceOfInteger& );
-
-protected:
- GLint myNumber;
- GLfloat* myXCoord;
- GLfloat* myYCoord;
- GLfloat myMarkerSize;
- QValueList<int> myHNumbers;
- QValueList<int> myUHNumbers;
- QValueList<int> mySelNumbers;
- QValueList<int> myCurSelNumbers;
- QValueList<int> myUSelNumbers;
- QValueList<int> myPrevHNumbers;
- TColStd_SequenceOfInteger mySelectedIndexes;
-};
-
-/*!
- \class GLViewer_Polyline
- OpenGL Polyline
-*/
-class GLVIEWER_API GLViewer_Polyline: public GLViewer_Object
-{
-public:
- GLViewer_Polyline( int number = 1, float size = 5.0, const QString& toolTip = "GLPolyline" );
- ~GLViewer_Polyline();
-
- // redefined methods
- virtual void compute();
- virtual GLViewer_Drawer* createDrawer();
-
- virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE );
- virtual GLboolean unhighlight();
- virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
- GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
- virtual GLboolean unselect();
-
- virtual GLViewer_Rect* getUpdateRect();
-
- virtual void moveObject( float, float, bool fromGroup = false );
-
- virtual QByteArray getByteCopy();
- virtual bool initializeFromByteCopy( QByteArray );
-
- virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
- virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );
-
-#ifdef WIN32
- virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
-#endif
-
- //! Sets array of x coords of points
- void setXCoord( GLfloat* xCoord, int size );
- //! Sets array of y coords of points
- void setYCoord( GLfloat* yCoord, int size );
- //! Returns x coords
- GLfloat* getXCoord() const { return myXCoord; }
- //! Returns y coords
- GLfloat* getYCoord() const { return myYCoord; }
-
- //! SetS number of points
- void setNumber( GLint );
- //! Returns number of points
- GLint getNumber() const { return myNumber; };
-
- //! On/off closed status of polyline
- void setClosed( GLboolean closed ) { myIsClosed = closed; }
- //! Checks closed status of polyline
- GLboolean isClosed() const { return myIsClosed; }
-
- //! On/off highlight as whole object status
- void setHighSelAll( GLboolean highSelAll ) { myHighSelAll = highSelAll; }
- //! Checks highlight as whole object status
- GLboolean isHighSelAll() const { return myHighSelAll; }
-
- //! Export numbers of highlighted/selected lines
- void exportNumbers( QValueList<int>& high, QValueList<int>& unhigh,
- QValueList<int>& sel, QValueList<int>& unsel );
-
- //! Returns numbers of selected lines
- QValueList<int> getSelectedElements() { return mySelNumbers; }
-
-protected:
- GLfloat* myXCoord;
- GLfloat* myYCoord;
- GLint myNumber;
- GLboolean myIsClosed;
- GLboolean myHighSelAll;
-
- QValueList<int> myHNumbers;
- QValueList<int> myUHNumbers;
- QValueList<int> mySelNumbers;
- QValueList<int> myUSelNumbers;
- QValueList<int> myCurSelNumbers;
- QValueList<int> myPrevHNumbers;
- TColStd_SequenceOfInteger mySelectedIndexes;
-
- GLboolean myHighFlag;
-};
-
-/*!
- \class GLViewer_TextObject
- Text as Object for OpenGL
-*/
-class GLVIEWER_API GLViewer_TextObject : public GLViewer_Object
-{
-public:
- GLViewer_TextObject( const QString&, float xPos = 0, float yPos = 0,
- const QColor& color = QColor( 0, 255, 0 ), const QString& toolTip = "GLText" );
- ~GLViewer_TextObject();
-
- virtual void compute();
- virtual GLViewer_Drawer* createDrawer();
-
- virtual void setDrawer( GLViewer_Drawer* theDrawer );
-
- virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE );
- virtual GLboolean unhighlight();
- virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
- GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE );
- virtual GLboolean unselect();
-
- virtual GLViewer_Rect* getUpdateRect();
-
- virtual void moveObject( float, float, bool fromGroup = false );
-
- virtual QByteArray getByteCopy();
- virtual bool initializeFromByteCopy( QByteArray );
-
- virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
- virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );
-
-#ifdef WIN32
- virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
-#endif
-
- int getWidth(){ return myWidth; }
- int getHeight(){ return myWidth; }
- void setWidth( int w ){ myWidth=w; }
- void setHeight( int h ){ myHeight=h; }
-
-protected:
- bool myHighFlag;
- int myWidth;
- int myHeight;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Compass.cxx
-// Created: November, 2004
-
-#include "GLViewer_Compass.h"
-#include "GLViewer_Drawer.h"
-
-/*!
- Constructor
- \param color - a color of compass
- \param size - a diameter of compass
- \param pos - a position
- \param WidthTop - width of wide part of arrow
- \param WidthBottom - width of base part of arrow
- \param HeightTop - height of arrow header
- \param HeightBottom - height of arrow cut on bottom
-*/
-GLViewer_Compass::GLViewer_Compass ( const QColor& color, const int size, const Position pos,
- const int WidthTop, const int WidthBottom, const int HeightTop,
- const int HeightBottom )
-{
- myCol = color;
- mySize = size;
- myPos = pos;
- myArrowWidthTop = WidthTop;
- myArrowWidthBottom = WidthBottom;
- myArrowHeightTop = HeightTop;
- myArrowHeightBottom = HeightBottom;
- myIsVisible = true;
- QFont* aFont = new QFont("Times",16);
- myFont = new GLViewer_TexFont( aFont );
- isGenereted = false;
- //myFont->generateTexture();
-}
-
-/*!
- Destructor
-*/
-GLViewer_Compass::~GLViewer_Compass()
-{
- delete myFont;
-}
-
-/*!
- Sets parameters of compass
- \param color - a color of compass
- \param size - a diameter of compass
- \param pos - a position
-*/
-void GLViewer_Compass::setCompass( const QColor& color, const int size, const Position pos )
-{
- myCol = color;
- mySize = size;
- myPos = pos;
-}
-
-/*!
- Sets visibility of compass
- \param vis - new visibility state
-*/
-void GLViewer_Compass::setVisible( const bool vis )
-{
- myIsVisible = vis;
-}
-
-/*!
- Sets size of compass
- \param size - new size
-*/
-void GLViewer_Compass::setSize( const int size )
-{
- if( size > 0 )
- mySize=size;
-}
-
-/*!
- Sets arrow width top
- \param WidthTop - new arrow width top
-*/
-void GLViewer_Compass::setArrowWidthTop( const int WidthTop )
-{
- if( WidthTop < myArrowWidthBottom || WidthTop > mySize )
- return;
- myArrowWidthTop=WidthTop;
-}
-
-/*!
- Sets arrow width bottom
- \param WidthBot - new arrow width bottom
-*/
-void GLViewer_Compass::setArrowWidthBottom( const int WidthBot )
-{
- if( WidthBot > myArrowWidthTop || WidthBot < 1 )
- return;
- myArrowWidthBottom=WidthBot;
-}
-
-/*!
- Sets arrow height top
- \param HeightTop - new arrow height top
-*/
-void GLViewer_Compass::setArrowHeightTop( const int HeightTop )
-{
- if( HeightTop > (2*mySize-myArrowHeightBottom ) || HeightTop < 1 )
- return;
- myArrowHeightTop=HeightTop;
-}
-
-/*!
- Sets arrow height bottom
- \param HeightBot - new arrow height bottom
-*/
-void GLViewer_Compass::setArrowHeightBottom( const int HeightBot )
-{
- if( HeightBot > ( 2*mySize-myArrowHeightTop ) || HeightBot < 1)
- return;
- myArrowHeightBottom=HeightBot;
-}
-
-/*!
- \return font of compass
-*/
-GLViewer_TexFont* GLViewer_Compass::getFont()
-{
- if(!isGenereted)
- {
- myFont->generateTexture();
- isGenereted = true;
- }
- return myFont;
-}
-
-/*!
- Sets font of compass
- \param theFont - new font
-*/
-void GLViewer_Compass::setFont( QFont theFont )
-{
- delete myFont;
- myFont = new GLViewer_TexFont( &theFont );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Compass.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_COMPASS_H
-#define GLVIEWER_COMPASS_H
-
-#include "GLViewer.h"
-
-#include <qcolor.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-class GLViewer_TexFont;
-
-/*! Class GLViewer_Compass
- * Class implement representatiof of compass in one of corner in GLViewer.
- * Compass it's a some round visual pointer rotated with view window and
- * located in fixed place (in one fixed corner)
- */
-class GLVIEWER_API GLViewer_Compass
-{
-public:
- //! Position of compass
- enum Position
- {
- TopLeft,
- TopRight,
- BottomLeft,
- BottomRight
- };
-
- //! A constructor
- /*!
- *\param color - a color of compass
- *\param size - a diameter of compass
- *\param pos - a position
- *\param WidthTop - width of wide part of arrow
- *\param WidthBottom - width of base part of arrow
- *\param HeightTop - height of arrow header
- *\param HeightBottom - height of arrow cut on bottom
- */
- GLViewer_Compass( const QColor& color = QColor ( 0, 255, 0 ),
- const int size = 60,
- const Position pos = TopRight,
- const int WidthTop = 20,
- const int WidthBottom = 10,
- const int HeightTop = 25,
- const int HeightBottom = 7 );
- //! A destructor
- ~GLViewer_Compass();
-
- //! A function installing main parameters of compass
- void setCompass( const QColor& color, const int size, const Position pos );
- //! A function installing a visible status
- void setVisible( const bool vis = true );
- //! Returns visible status
- bool getVisible(){ return myIsVisible; };
-
- //! A function installing diameter
- void setSize( const int size );
- //! Returns diameter
- int getSize(){ return mySize; }
-
- //! A function installing position
- void setPos( const Position pos ){ myPos = pos; }
- //! Returns position
- int getPos(){ return myPos; }
-
- //! A function installing color
- void setColor( const QColor& color ){ myCol = color; }
- //! Returns color
- QColor getColor(){ return myCol; }
-
- //! A function installing width of wide part of arrow
- void setArrowWidthTop( const int WidthTop );
- //! Returns width of wide part of arrow
- int getArrowWidthTop(){ return myArrowWidthTop; }
-
- //! A function installing width of base part of arrow
- void setArrowWidthBottom( const int WidthBot );
- //! Returns width of base part of arrow
- int getArrowWidthBottom(){return myArrowWidthBottom;};
-
- //! A function installing height of arrow header
- void setArrowHeightTop( const int HeightTop );
- //! Returns height of arrow header
- int getArrowHeightTop(){return myArrowHeightTop;};
-
- //! A function installing height of arrow cut on bottom
- void setArrowHeightBottom( const int HeightBot );
- //! Returns height of arrow cut on bottom
- int getArrowHeightBottom(){return myArrowHeightBottom;};
-
- //! A function installing
- void setFont( QFont theFont );
- //! Returns
- GLViewer_TexFont* getFont();
-
-protected:
- //! Compass color
- QColor myCol;
- //! Compass diameter
- int mySize;
- //! Compass position
- int myPos;
- //! Compass invisible status
- bool myIsVisible;
- //! Width of wide part of arrow
- int myArrowWidthTop;
- //! Width of base part of arrow
- int myArrowWidthBottom;
- //! Height of arrow header
- int myArrowHeightTop;
- //! Height of arrow cut on bottom
- int myArrowHeightBottom;
- //! Compass font
- GLViewer_TexFont* myFont;
- //! Status of generated font
- bool isGenereted;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Context.cxx
-// Created: November, 2004
-
-/*!
- \class GLViewer_AspectLine
- \brief Class for manage of presentations in GLViewer
-*/
-
-#include "GLViewer_Context.h"
-
-#include "GLViewer_Group.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_ViewPort2d.h"
-
-#include <TColStd_SequenceOfInteger.hxx>
-
-#define TOLERANCE 12
-
-/*!
- Constructor
-*/
-GLViewer_Context::GLViewer_Context( GLViewer_Viewer2d* v ) :
- myGLViewer2d( v ),
- myHighlightColor( Quantity_NOC_CYAN1 ),
- mySelectionColor( Quantity_NOC_RED ),
- myTolerance( TOLERANCE )
-{
- myUpdateAll = true;
-
- myLastPicked = 0;
- myLastPickedChanged = false;
-
- myHFlag = GL_TRUE;
- mySFlag = GL_TRUE;
-
- mySelCurIndex = 0;
-}
-
-/*!
- Destructor
-*/
-GLViewer_Context::~GLViewer_Context()
-{
- myActiveObjects.clear();
- myInactiveObjects.clear();
- mySelectedObjects.clear();
-}
-
-/*!
- Hiilights objects under cursor
- \param x - X coord of mouse cursor
- \param y - Y coord of mouse cursor
- \param byCircle - true if needs round sensitive area around mouse cursor, else rectangle
- function search object rectangle which intersect with sensitive area and call object highlight method
-*/
-int GLViewer_Context::MoveTo( int xi, int yi, bool byCircle )
-{
- GLfloat x = (GLfloat)xi;
- GLfloat y = (GLfloat)yi;
- myGLViewer2d->transPoint( x, y );
-
- myXhigh = x;
- myYhigh = y;
-
- GLboolean isHigh = GL_FALSE;
- GLboolean onObject = GL_FALSE;
-
- GLViewer_Object* aPrevLastPicked = myLastPicked;
- GLViewer_Object* lastPicked = 0;
-
- ObjList anUpdatedObjects;
-
- if( myActiveObjects.isEmpty() )
- return -1;
-
- ObjList::iterator it = myActiveObjects.end();
- ObjList::iterator itEnd = myActiveObjects.begin();
- for( it--; ; --it )
- {
- GLViewer_Object* object = *it;
-
- GLViewer_Rect* rect = object->getUpdateRect();
- if( rect->contains( GLViewer_Pnt( x, y ) ) )
- {
- onObject = GL_TRUE;
- object->highlight( x, y, myTolerance, GL_FALSE );
- isHigh = object->isHighlighted();
- }
-
- if( isHigh )
- {
- lastPicked = object;
- break;
- }
-
- if( it == itEnd )
- break;
- }
-
- if( !myHFlag )
- {
- myLastPicked = lastPicked;
- return -1;
- }
-
- if ( !onObject )
- {
- //cout << 0 << endl;
- it = myActiveObjects.begin();
- itEnd = myActiveObjects.end();
-
- for( ; it != itEnd; ++it )
- (*it)->unhighlight();
-
- anUpdatedObjects.append( (*it) );
-
- myLastPicked = 0;
- myLastPickedChanged = aPrevLastPicked != myLastPicked;
-
- if( myLastPickedChanged )
- myGLViewer2d->updateAll();
-
- return 0;
- }
-
- if( !myLastPicked && isHigh )
- {
- //cout << 1 << endl;
- myLastPicked = lastPicked;
- anUpdatedObjects.append( myLastPicked );
- }
- else if( myLastPicked && !isHigh )
- {
- //cout << 2 << endl;
- myLastPicked->unhighlight();
- anUpdatedObjects.append( myLastPicked );
- myLastPicked = 0;
- }
- else if( myLastPicked && isHigh )
- {
- //cout << 3 << endl;
- myLastPicked->highlight( x, y, myTolerance, byCircle );
- anUpdatedObjects.append( myLastPicked );
- if( myLastPicked != lastPicked )
- {
- myLastPicked->unhighlight();
- myLastPicked = lastPicked;
- anUpdatedObjects.append( myLastPicked );
- }
- }
-
- myLastPickedChanged = ( aPrevLastPicked != myLastPicked );
-
- if( myLastPickedChanged || myUpdateAll )
- myGLViewer2d->updateAll();
- else
- myGLViewer2d->activateDrawers( anUpdatedObjects, TRUE, TRUE );
-
- return 0;
-}
-
-/*! Selects already highlighting object by calling object method select
- \param Append - true if new selection will be append to existing selection, false - another
- \param byCircle - true if needs round selection area in complex object
-*/
-int GLViewer_Context::Select( bool Append, bool byCircle )
-{
- ObjList::Iterator it, itEnd, oit, oitEnd;
- SelectionStatus status = SS_Invalid;
-
- bool updateAll = false;
-
- ObjList aList;
-
- if ( !mySFlag )
- return status;//invalid
-
- if( myHFlag && myLastPicked )
- {
- if( mySelectedObjects.count() == 1 && mySelectedObjects.first() == myLastPicked )
- status = SS_LocalChanged;
-
- if ( !Append )
- {
- for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end() ; it != itEnd; ++it )
- if( myLastPicked != *it )
- {
- updateAll = (*it)->unselect() || updateAll;
- aList.append( *it );
- }
-
- if( updateAll || myUpdateAll )
- myGLViewer2d->updateAll();
- else
- myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
-
- if( mySelectedObjects.count() != 0 && status == SS_Invalid )
- status = SS_GlobalChanged;
- mySelectedObjects.clear();
- }
- else if( myLastPicked->isSelected() && status != SS_LocalChanged )
- {
- mySelectedObjects.remove( myLastPicked );
- myLastPicked->unselect();
- myGLViewer2d->updateAll();
-
- if( mySelectedObjects.count() != 0 && status == SS_Invalid )
- status = SS_GlobalChanged;
-
- return status;
- }
-
- if ( myLastPicked->select( myXhigh, myYhigh, myTolerance, GLViewer_Rect(), false, byCircle, Append )
- && mySelectedObjects.findIndex( myLastPicked ) == -1 )
- {
- mySelectedObjects.append( myLastPicked );
- myGLViewer2d->activateDrawer( myLastPicked, TRUE, TRUE );
-
- if( status == SS_Invalid )
- status = SS_GlobalChanged;
- }
- else if( status == SS_LocalChanged )
- status = SS_GlobalChanged;
-
- return status;
- }
-
- if( myHFlag && !myLastPicked )
- {
- if ( !Append )
- {
- for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end() ; it != itEnd; ++it )
- if ( myLastPicked != *it )
- {
- updateAll = (*it)->unselect() || updateAll;
- aList.append( *it );
- }
-
- if( updateAll || myUpdateAll )
- myGLViewer2d->updateAll();
- else
- myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
-
- if( mySelectedObjects.count() != 0 )
- status = SS_GlobalChanged;
-
- mySelectedObjects.clear();
- }
- return status;
- }
-
- if( !myHFlag )
- {
- bool isSel = false;
- GLfloat aXScale;
- GLfloat aYScale;
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )myGLViewer2d->getActiveView()->getViewPort();
- vp->getScale( aXScale, aYScale );
-
- if ( !Append )
- {
- for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end() ; it != itEnd; ++it )
- if( myLastPicked != *it )
- {
- updateAll = (*it)->unselect() || updateAll;
- aList.append( *it );
- }
-
- if( updateAll || myUpdateAll )
- myGLViewer2d->updateAll();
- else
- myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
-
- if( mySelectedObjects.count() != 0 )
- status = SS_GlobalChanged;
-
- mySelectedObjects.clear();
- }
-
- for( oit = myActiveObjects.begin(), oitEnd = myActiveObjects.end(); oit != oitEnd; ++oit )
- {
- (*oit)->setScale( aXScale, aYScale );
- GLViewer_Rect* rect = (*oit)->getUpdateRect();
-
- if( rect->contains( GLViewer_Pnt( myXhigh, myXhigh ) ) )
- {
- (*oit)->select( myXhigh, myYhigh, myTolerance, GLViewer_Rect(), false, byCircle, Append );
- isSel = (*oit)->isSelected();
- }
- if( isSel )
- {
- myLastPicked = *oit;
- mySelectedObjects.append( myLastPicked );
- myGLViewer2d->activateDrawer( myLastPicked, TRUE, TRUE );
- status = SS_GlobalChanged;
- return status;
- }
- }
- }
-
- return SS_NoChanged;
-}
-
-/*! Selects objects on scene by rectangle
- \param theRect - rectangle of selection
- \param Append - true if new selection will be append to existing selection, false - another
- function search object rectangle which intersect with theRect and call object select method
-*/
-int GLViewer_Context::SelectByRect( const QRect& theRect, bool Append )
-{
- GLfloat aXScale;
- GLfloat aYScale;
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )myGLViewer2d->getActiveView()->getViewPort();
- vp->getScale( aXScale, aYScale );
-
- SelectionStatus status = SS_NoChanged;
-
- ObjList aList;
- ObjList::Iterator it, itEnd;
-
- if ( !mySFlag || myActiveObjects.empty() )
- return SS_Invalid;
-
- bool updateAll = false;
- if( !Append )
- {
- if( mySelectedObjects.count() != 0 )
- status = SS_GlobalChanged;
-
- for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end(); it != itEnd; ++it )
- {
- updateAll = (*it)->unselect() || updateAll;
- aList.append( *it );
- }
- mySelectedObjects.clear();
- }
-
- for( it = myActiveObjects.begin(), itEnd = myActiveObjects.end(); it != itEnd; ++it )
- {
- bool isSel = false;
- (*it)->setScale( aXScale, aYScale );
- QRect rect = myGLViewer2d->getQRect( *( (*it)->getRect() ) );
-
- if( rect.intersects( theRect ) )
- {
- GLViewer_Rect aRect = myGLViewer2d->getGLVRect( theRect );
- (*it)->select( myXhigh, myYhigh, myTolerance, aRect, false, false, Append );
- isSel = (*it)->isSelected();
- }
-
- if( isSel && mySelectedObjects.findIndex( *it ) == -1 )
- {
- aList.append( *it );
- mySelectedObjects.append( *it );
- status = SS_GlobalChanged;
- }
- }
-
- if( updateAll || myUpdateAll )
- myGLViewer2d->updateAll();
- else
- myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
-
- return status;
-}
-
-/*!
- Sets color of hilighting
- \param aCol - new color of highlighting
-*/
-void GLViewer_Context::SetHighlightColor( Quantity_NameOfColor aCol )
-{
- myHighlightColor = aCol;
-
- Quantity_Color colorH( aCol );
- int redH = 255 * (int)colorH.Red();
- int greenH = 255 * (int)colorH.Green();
- int blueH = 255 * (int)colorH.Blue();
- QColor colH = QColor( redH, greenH, blueH );
-
- Quantity_Color colorS( mySelectionColor );
- int redS = 255 * (int)colorS.Red();
- int greenS = 255 * (int)colorS.Green();
- int blueS = 255 * (int)colorS.Blue();
- QColor colS = QColor( redS, greenS, blueS );
-
- myGLViewer2d->updateColors( colH, colS);
-}
-
-/*!
- Sets color of selection
- \param aCol - new color of selection
-*/
-void GLViewer_Context::SetSelectionColor( Quantity_NameOfColor aCol )
-{
- mySelectionColor = aCol;
-
- Quantity_Color colorH( myHighlightColor );
- int redH = 255 * (int)colorH.Red();
- int greenH = 255 * (int)colorH.Green();
- int blueH = 255 * (int)colorH.Blue();
- QColor colH = QColor( redH, greenH, blueH );
-
- Quantity_Color colorS( aCol );
- int redS = 255 * (int)colorS.Red();
- int greenS = 255 * (int)colorS.Green();
- int blueS = 255 * (int)colorS.Blue();
- QColor colS = QColor( redS, greenS, blueS );
-
- myGLViewer2d->updateColors( colH, colS);
-}
-
-/*!
- \return number of selected objects
-*/
-int GLViewer_Context::NbSelected()
-{
- return mySelectedObjects.count();
-}
-
-/*!
- Inits iteration through selected objects
-*/
-void GLViewer_Context::InitSelected()
-{
- mySelCurIndex = 0;
-}
-
-/*!
- Checks if iteration through selected objects may be continued
-*/
-bool GLViewer_Context::MoreSelected()
-{
- return ( mySelCurIndex < NbSelected() );
-}
-
-/*!
- Iterates to next selected object
-*/
-bool GLViewer_Context::NextSelected()
-{
- if ( mySelCurIndex >= 0 && mySelCurIndex < NbSelected() )
- {
- mySelCurIndex++;
- return TRUE;
- }
-
- return FALSE;
-}
-
-/*!
- \return current selected object (must be used only in cycle as "for( InitSelected(); MoreSelected(); NextSelected() ) {...}" )
-*/
-GLViewer_Object* GLViewer_Context::SelectedObject()
-{
- return mySelectedObjects[ mySelCurIndex ];
-}
-
-/*!
- \return true if object is selected
- \param theObj - object to be checked
-*/
-bool GLViewer_Context::isSelected( GLViewer_Object* theObj )
-{
- return mySelectedObjects.contains( theObj );
-}
-
-/*! Inserts new object in context
- \param theObject - object to be inserted
- \param display - true if needs display object immediatly after inserting, else false
- \param isActive - true if needs inserting object in active list
-*/
-int GLViewer_Context::insertObject( GLViewer_Object* object, bool display, bool isActive )
-{
-// cout << "GLViewer_Context::insertObject" << endl;
-
- if( !object )
- return -1;
-
- if( isActive )
- {
- myActiveObjects.append( object );
- if( display )
- {
- //QRect* rect = object->getRect()->toQRect();
- //myGLViewer2d->updateBorders( *rect );
- myGLViewer2d->activateDrawer( object, FALSE );
- }
- }
- else
- myInactiveObjects.append( object );
-
- return myActiveObjects.count() + myInactiveObjects.count();
-}
-
-/*!
- Replaces object in context
- \param oldObject - object to be replaced
- \param newObject - object for replacing
-*/
-bool GLViewer_Context::replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject )
-{
- if( !oldObject || !newObject )
- return false;
-
- if( myActiveObjects.contains( oldObject ) )
- {
- myActiveObjects.remove( oldObject );
- myActiveObjects.append( newObject );
- return true;
- }
-
- if( myInactiveObjects.contains( oldObject ) )
- {
- myInactiveObjects.remove( oldObject );
- myInactiveObjects.append( newObject );
- return true;
- }
-
- return false;
-}
-
-/*!
- Updates scales of all objects in context
-*/
-void GLViewer_Context::updateScales( GLfloat scX, GLfloat scY )
-{
- if( scX <= 0 || scY <= 0 )
- return;
-
- ObjList::iterator it, itEnd;
-
- for( it = myActiveObjects.begin(), itEnd = myActiveObjects.end(); it != itEnd; ++it )
- (*it)->setScale( scX, scY );
-
- for( it = myInactiveObjects.begin(), itEnd = myInactiveObjects.end(); it != itEnd; ++it )
- (*it)->setScale( scX, scY );
-}
-
-/*!
- Clears hilighting of objects
- \param updateViewer - if it is true, viewer must be updated
-*/
-void GLViewer_Context::clearHighlighted( bool updateViewer )
-{
- if( myHFlag && myLastPicked )
- {
- myLastPicked->unhighlight();
- myLastPicked = 0;
-
- if( updateViewer )
- myGLViewer2d->updateAll();
- }
-}
-
-/*!
- Clears selection of objects
- \param updateViewer - if it is true, viewer must be updated
-*/
-void GLViewer_Context::clearSelected( bool updateViewer )
-{
- if( !mySFlag )
- return;
-
- ObjList::Iterator it, itEnd;
- ObjList aList;
-
- for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end(); it != itEnd; ++it )
- {
- (*it)->unselect();
- aList.append( *it );
- }
-
- if( updateViewer )
- myGLViewer2d->activateDrawers( aList, TRUE );
- mySelectedObjects.clear();
-}
-
-/*!
- Selects object, other selected objects are left as selected
- \param updateViewer - if it is true, viewer must be updated
-*/
-void GLViewer_Context::setSelected( GLViewer_Object* object, bool updateViewer )
-{
- if( !object )
- return;
-
- if( myActiveObjects.contains( object ) && !mySelectedObjects.contains( object ) )
- {
- object->setSelected( TRUE );
- mySelectedObjects.append( object );
- }
-
- if( updateViewer )
- myGLViewer2d->activateDrawer( object, TRUE, TRUE );
-}
-
-/*!
- Unselects object, other selected objects are left as selected
- \param updateViewer - if it is true, viewer must be updated
-*/
-void GLViewer_Context::remSelected( GLViewer_Object* object, bool updateViewer )
-{
- if( !object || !mySelectedObjects.contains( object ) )
- return;
-
- mySelectedObjects.remove( object );
- object->unselect();
-
- if( updateViewer )
- myGLViewer2d->activateDrawer( object, TRUE, TRUE );
-}
-
-/*!
- Erases object in viewer
- \param theUpdateViewer - if it is true, viewer must be updated
-*/
-void GLViewer_Context::eraseObject( GLViewer_Object* theObject, bool theUpdateViewer )
-{
- if( !theObject || !myActiveObjects.contains( theObject ) )
- return;
-
- theObject->unhighlight();
- theObject->unselect();
- theObject->setVisible( false );
-
- if( theUpdateViewer )
- myGLViewer2d->updateAll();
-}
-
-/*!
- Deletes object in
- \param updateViewer - if it is true, viewer must be updated
-*/
-void GLViewer_Context::deleteObject( GLViewer_Object* theObject, bool updateViewer )
-{
- if( !theObject ||
- ( !myActiveObjects.contains( theObject ) && !myInactiveObjects.contains( theObject ) ) )
- return;
-
- if( myActiveObjects.contains( theObject ) )
- myActiveObjects.remove( theObject );
- else if( myInactiveObjects.contains( theObject ) )
- myInactiveObjects.remove( theObject );
- else
- return;
-
- if( mySelectedObjects.contains( theObject ) )
- mySelectedObjects.remove( theObject );
-
- GLViewer_Group* aGroup = theObject->getGroup();
- if( aGroup )
- aGroup->removeObject( theObject );
-
- if( myLastPicked == theObject )
- myLastPicked = 0;
-
- if ( updateViewer )
- myGLViewer2d->updateAll();
-}
-
-/*!
- Installs active status to object
- \param theObject
-*/
-bool GLViewer_Context::setActive( GLViewer_Object* theObject )
-{
- if( !theObject || !myInactiveObjects.contains( theObject ) )
- return false;
-
- myInactiveObjects.remove( theObject );
- myActiveObjects.append( theObject );
- return true;
-}
-
-/*!
- Installs inactive status to object
- \param theObject
-*/
-bool GLViewer_Context::setInactive( GLViewer_Object* theObject )
-{
- if( !theObject || !myActiveObjects.contains( theObject ) )
- return false;
-
- myActiveObjects.remove( theObject );
- myInactiveObjects.append( theObject );
- return true;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Context.h
-// Created: November, 2004
-
-
-#ifndef GLVIEWER_CONTEXT_H
-#define GLVIEWER_CONTEXT_H
-
-#ifdef WNT
-#include "windows.h"
-#endif
-
-#include "GLViewer_Defs.h"
-#include "GLViewer_Object.h"
-
-#include <qrect.h>
-#include <qobject.h>
-#include <qregion.h>
-
-#include <Quantity_NameOfColor.hxx>
-#include <Quantity_Color.hxx>
-
-#include <GL/gl.h>
-
-class GLViewer_Viewer2d;
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*! \class GLViewer_Context
- * Class for manage of presentations in GLViewer
- */
-class GLVIEWER_API GLViewer_Context
-{
-public:
- //! A constructor
- GLViewer_Context( GLViewer_Viewer2d* );
- //! A desructor
- ~GLViewer_Context();
-
- //! A function installing update flag in highlighting technology
- void setUpdateAll( bool on ) { myUpdateAll = on; }
- //! Returns update flag in highlighting technology
- bool isUpdateAll() const { return myUpdateAll; }
-
- //! Main interactive method. Trace mouse in viewer window
- /*!
- *\param x - X coord of mouse cursor
- *\param y - Y coord of mouse cursor
- *\paran byCircle - true if needs round sensitive area around mouse cursor, else rectangle
- *function search object rectangle which intersect with sensitive area and call object highlight method
- */
- int MoveTo( int x, int y, bool byCircle = FALSE );
- /*! A function selecting already highlighting object by calling object method select
- *\param Append - true if new selection will be append to existing selection, false - another
- *\param byCircle - true if needs round selection area in complex object
- */
- int Select( bool Append = FALSE, bool byCircle = FALSE );
- /*! A function selecting objects on scene by rectangle
- *\param theRect - rectangle of selection
- *\param Append - true if new selection will be append to existing selection, false - another
- *function search object rectangle which intersect with theRect and call object select method
- */
- int SelectByRect( const QRect& theRect, bool Append = FALSE );
-
- //! A function installing highlight color for all presentation (does not work)
- void SetHighlightColor( Quantity_NameOfColor aCol );
- //! A function installing select color for all presentation (does not work)
- void SetSelectionColor( Quantity_NameOfColor aCol );
- //! Returns highlight color
- Quantity_NameOfColor HighlightColor() { return myHighlightColor; }
- //! Returns select color
- Quantity_NameOfColor SelectionColor() { return mySelectionColor; }
-
- //! Returns number of objects in current selection
- int NbSelected();
- //! A function set iterator of selected objects on first object
- void InitSelected();
- //! Retuns true if iterator of selected objects is not set on last object
- bool MoreSelected();
- //! Increment of iterator of selected objects
- bool NextSelected();
- //! Returns object corresponding the current iterator of selected objects
- GLViewer_Object* SelectedObject();
-
- //! Returns true if theObject is selected
- bool isSelected( GLViewer_Object* theObject );
-
- //! Insert new object in context
- /*!
- *\param theObject - inserting object
- *\param display - true if needs display object immediatly after inserting, else false
- *\param isActive - true if needs inserting object in active list
- */
- int insertObject( GLViewer_Object* theObject, bool display = false, bool isActive = true );
- //! Replacing objects in context
- /*!
- * Function search active and incative objects
- */
- bool replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject );
- //! A function updating scales of all objects in context
- void updateScales( GLfloat theX, GLfloat theY );
- //! A function installing tolerance in window pixels for highlghting and selection methods
- void setTolerance( int tol ) { myTolerance = tol; }
-
- //! Returns list of context objects
- /*!
- * \return active objects if isActive = true, else inactive objects
- */
- const ObjList& getObjects( bool isActive = true )
- { return isActive ? myActiveObjects : myInactiveObjects; }
-
- //! Returns first active object
- GLViewer_Object* getFirstObject() { return *( myActiveObjects.begin() ); }
-
- //! A function clear highlighted object information
- void clearHighlighted( bool updateViewer );
- //! A function clear selection object information
- void clearSelected( bool updateViewer );
- //! A function make theObject as selected object and update viewer if updateViewer = true
- void setSelected( GLViewer_Object* theObject, bool updateViewer );
- //! A function make theObject as unselected object and update viewer if updateViewer = true
- void remSelected( GLViewer_Object* theObject, bool updateViewer );
-
- //! Returns highlighted object
- GLViewer_Object* getCurrentObject() { return myLastPicked; }
- //! Returns true if after last MoveTo method calling highlight object is changed
- bool currentObjectIsChanged() { return myLastPickedChanged; }
-
- //! A function installing to theObject invisible status and update viewer if updateViewer = true
- void eraseObject( GLViewer_Object* theObject, bool updateViewer = true );
- //! A function remove theObject from context and update viewer if updateViewer = true
- void deleteObject( GLViewer_Object* theObject, bool updateViewer = true );
-
- //! A function installing to theObject active status
- bool setActive( GLViewer_Object* theObject );
- //! A function installing to theObject inactive status
- bool setInactive( GLViewer_Object* theObject );
-
-protected:
- //! Flag of updating viewer after highlight
- /*!
- * if = true, the viewer update all objects after change of highlight object,
- * else - only highlight object
- */
- bool myUpdateAll;
-
- GLViewer_Viewer2d* myGLViewer2d;
- //! Highlighted object
- GLViewer_Object* myLastPicked;
- //! = true if after last MoveTo method calling highlight object is changed
- bool myLastPickedChanged;
-
- //! List of active object
- /*!Active objects if consider in highlight and select methods*/
- ObjList myActiveObjects;
- //! List of inactive object
- /*!Active objects isn't consider in highlight and select methods*/
- ObjList myInactiveObjects;
-
- //! List of selected objects
- ObjList mySelectedObjects;
- //! Selected object iterator
- int mySelCurIndex;
-
- //! X coordinate of mouse cursor
- GLfloat myXhigh;
- //! Y coordinate of mouse cursor
- GLfloat myYhigh;
-
- //! Color for highlight
- Quantity_NameOfColor myHighlightColor;
- //! Color for selection
- Quantity_NameOfColor mySelectionColor;
- //! If = false - moveTo method is not any highlighting
- GLboolean myHFlag;
- //! If = false - select method is not any select
- GLboolean mySFlag;
- //! Tolerance in window pixels for highlghting and selection methods
- int myTolerance;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Context.cxx
-// Created: November, 2004
-
-#include "GLViewer_CoordSystem.h"
-#include <math.h>
-
-/*!
- Constructor
- \param aType - type of CS
- \param X0 - X of origin in reference CS
- \param Y0 - Y of origin in reference CS
- \param XUnit - X unit in reference CS
- \param YUnit - Y unit in reference CS
- \param Rotation - rotation relative reference CS
-*/
-GLViewer_CoordSystem::GLViewer_CoordSystem( CSType aType, double X0, double Y0,
- double XUnit, double YUnit, double Rotation )
-{
- setType( aType );
- setOrigin( X0, Y0 );
- setUnits( XUnit, YUnit );
- setRotation( Rotation );
-}
-
-/*!
- \return origin in reference CS
-*/
-void GLViewer_CoordSystem::getOrigin( double& x, double& y ) const
-{
- x = myX0;
- y = myY0;
-}
-
-/*!
- Sets origin in reference CS
-*/
-void GLViewer_CoordSystem::setOrigin( double x, double y )
-{
- myX0 = x;
- myY0 = y;
-}
-
-/*!
- \return units
-*/
-void GLViewer_CoordSystem::getUnits( double& x, double& y ) const
-{
- x = myXUnit;
- y = myYUnit;
-}
-
-/*!
- Sets units
-*/
-void GLViewer_CoordSystem::setUnits( double x, double y )
-{
- if( x>0 )
- myXUnit = x;
- else
- myXUnit = 1.0;
-
- if( y>0 )
- myYUnit = y;
- else
- myYUnit = 1.0;
-}
-
-/*!
- \return rotation
-*/
-double GLViewer_CoordSystem::getRotation() const
-{
- return myRotation;
-}
-
-/*!
- Sets rotation
-*/
-void GLViewer_CoordSystem::setRotation( double rotation )
-{
- myRotation = rotation;
-}
-
-/*!
- \return type
-*/
-GLViewer_CoordSystem::CSType GLViewer_CoordSystem::getType() const
-{
- return myType;
-}
-
-/*!
- Sets type
-*/
-void GLViewer_CoordSystem::setType( CSType type )
-{
- myType = type;
-}
-
-/*!
- Recalculate co-ordinates to reference co-ordinates
- \param x, y - co-ordinates
-*/
-void GLViewer_CoordSystem::toReference( double& x, double& y )
-{
- if( myType==Cartesian )
- {
- double newx = myX0 + myXUnit*x*cos(myRotation) - myYUnit*y*sin(myRotation),
- newy = myY0 + myXUnit*x*sin(myRotation) + myYUnit*y*cos(myRotation);
- x = newx;
- y = newy;
- }
- else if( myType==Polar )
- {
- double r = x, phi = y;
- x = myX0 + myXUnit*r*cos(phi+myRotation);
- y = myY0 + myXUnit*r*sin(phi+myRotation);
- }
-}
-
-/*!
- Recalculate co-ordinates from reference co-ordinates
- \param x, y - co-ordinates
-*/
-void GLViewer_CoordSystem::fromReference( double& x, double& y )
-{
- x = (x - myX0) / myXUnit;
- y = (y - myY0) / myYUnit;
-
- if( myType==Cartesian )
- {
- double newx = x*cos(myRotation) + y*sin(myRotation),
- newy = -x*sin(myRotation) + y*cos(myRotation);
- x = newx;
- y = newy;
- }
- else if( myType==Polar )
- {
- double r = sqrt( x*x+y*y );
- double phi = 0.0;
- double eps = 1E-8, pi = 3.14159265;
-
- if( r>eps )
- if( fabs(x)>eps )
- {
- double arg = y/x;
- phi = atan(arg);
- if( x<0 ) // 2-nd or 4-rd quarter
- phi+=pi;
- }
- else if( y>0 )
- phi = pi/2.0;
- else
- phi = 3*pi/2.0;
-
- x = r;
- y = phi-myRotation;
- }
-}
-
-/*!
- Recalculate co-ordinates to co-ordinates of other CS
- \param aSystem - other CS
- \param x, y - co-ordinates
-*/
-void GLViewer_CoordSystem::transform( GLViewer_CoordSystem& aSystem, double& x, double& y )
-{
- toReference( x, y );
- aSystem.fromReference( x, y );
-}
-
-/*!
- \return stretching of CS along X and Y axis
-*/
-void GLViewer_CoordSystem::getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY )
-{
- theX = myXUnit / aSystem.myXUnit;
- theY = myYUnit / aSystem.myYUnit;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_CoordSystem.h
-// Created: November, 2004
-
-/*! Class GLViewer_CoordSystem
- * Class implementing mathematical model of 2D coordinate system
- */
-
-#ifndef GLVIEWER_COORDSYSTEM_H
-#define GLVIEWER_COORDSYSTEM_H
-
-#include "GLViewer.h"
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_CoordSystem
- \brief Class implementing mathematical model of 2D coordinate system
-*/
-class GLVIEWER_API GLViewer_CoordSystem
-{
-public:
- //! A type of coordinate system
- enum CSType
- {
- Cartesian,
- Polar
- };
-
-private:
- //! The coordinates of origin in the reference CS
- double myX0, myY0;
- //! The lengths of axis units in the reference unit
- double myXUnit, myYUnit;
- //! The rotation in radians relative to reference CS
- double myRotation;
-
- //! In the polar CS myYUnit is ignored, but myXUnit is the unit of polar radius
- CSType myType;
-
-public:
- //! A constructor ( by default new system is identical to reference )
- GLViewer_CoordSystem( CSType aType, double X0 = 0.0, double Y0 = 0.0,
- double XUnit = 1.0, double YUnit = 1.0, double Rotation = 0.0 );
-
- //! Returns the origin in reference system
- void getOrigin( double& x, double& y ) const;
- //! A function installing the origin in reference system
- void setOrigin( double x, double y );
-
- //! Returns units along axes
- void getUnits( double& x, double& y ) const;
- //! A function installing units along axes
- void setUnits( double x, double y );
-
- //! Returns rotation angle of axes in reference system
- double getRotation() const;
- //! A function installing rotation angle of axes in reference system
- void setRotation( double rotation );
-
- //! Returns type of system
- CSType getType() const;
- //! A function installing type of system
- void setType( CSType type );
-
- //! Transform the coordinates x, y from current CS to aSystem
- void transform( GLViewer_CoordSystem& aSystem, double& x, double& y );
-
-
- //! Return how many times line width in aSystem system bigger than in current
- virtual void getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY );
-
-
-protected:
- //! A function transforms system coords to coords in reference system
- virtual void toReference( double& x, double& y );
- //! A function transforms from coords in reference system to system coords
- virtual void fromReference( double& x, double& y );
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Defs.h
-// Created: March, 2005
-
-#ifndef GLVIEWER_DEFS_H
-#define GLVIEWER_DEFS_H
-
-#include <qmap.h>
-#include <qvaluelist.h>
-
-class GLViewer_Object;
-//Selection staus
-enum SelectionChangeStatus
-{
- SCS_Invalid,
- SCS_Local,
- SCS_Global
-};
-
-//! Fit Selection Rectangle
-static const int SELECTION_RECT_GAP = 50;
-
-//! Display Text Format of Objects
-enum DisplayTextFormat
-{
- DTF_TEXTURE = 0,
- DTF_TEXTURE_SCALABLE = 1,
- DTF_BITMAP = 2
-};
-
-enum SelectionStatus
-{
- SS_Invalid,
- SS_LocalChanged,
- SS_GlobalChanged,
- SS_NoChanged
-};
-
-typedef QMap<GLViewer_Object*,int> ObjectMap;
-typedef QValueList<GLViewer_Object*> ObjList;
-
-#define SEGMENTS 32
-#define PI 3.14159265359
-#define STEP ( float )( 2 * PI / SEGMENTS )
-
-#endif// GLVIEWER_DEFS_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Drawer.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Drawer.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_Text.h"
-#include "GLViewer_ViewFrame.h"
-#include "GLViewer_ViewPort2d.h"
-
-#ifndef WIN32
-#include <GL/glx.h>
-#endif
-
-#include <gp_Pnt2d.hxx>
-
-#include <qimage.h>
-#include <qpainter.h>
-
-#define TEXT_GAP 5
-// Two texture components for texmapped fonts: luminance and alpha
-#define NB_TEX_COMP 2
-// A font is split into rows each containing 32 characters
-#define TEX_ROW_LEN 32
-// Gap in pixels between two character rows in a font texture
-#define TEX_ROW_GAP 2
-
-GLfloat modelMatrix[16];
-
-
-//! code of first font symbol
-static int FirstSymbolNumber = 32;
-//! code of last font symbol
-static int LastSymbolNumber = 127;
-
-QMap<GLViewer_TexFindId,GLViewer_TexIdStored> GLViewer_TexFont::TexFontBase;
-QMap<GLViewer_TexFindId,GLuint> GLViewer_TexFont::BitmapFontCache;
-
-/*!
- Clears all generated fonts
-*/
-void GLViewer_TexFont::clearTextBases()
-{
- //cout << "Clear font map" << endl;
- TexFontBase.clear();
- BitmapFontCache.clear();
-}
-
-/*!
- Default constructor
-*/
-GLViewer_TexFont::GLViewer_TexFont()
-: myMaxRowWidth( 0 ), myFontHeight( 0 )
-{
- myQFont = QFont::defaultFont();
- mySeparator = 2;
- myIsResizeable = false;
- myMinMagFilter = GL_LINEAR;
-
- init();
-}
-
-/*!
- Constructor
- \param theFont - a base font
- \param theSeparator - separator between letters
- \param theIsResizeable - specifies whether text drawn by this object can be scaled along with the scene
- \param theMinMagFilter - min/mag filter, affects text sharpness
-*/
-GLViewer_TexFont::GLViewer_TexFont( QFont* theFont, int theSeparator, bool theIsResizeable, GLuint theMinMagFilter )
-: myMaxRowWidth( 0 ), myFontHeight( 0 )
-{
- myQFont = *theFont;
- mySeparator = theSeparator;
- myIsResizeable = theIsResizeable;
- myMinMagFilter = theMinMagFilter;
-
- init();
-}
-
-/*!
- Destructor
-*/
-GLViewer_TexFont::~GLViewer_TexFont()
-{
- delete[] myWidths;
- delete[] myPositions;
-}
-
-/*!
- Initializes font parameters
-*/
-void GLViewer_TexFont::init()
-{
- myNbSymbols = LastSymbolNumber - FirstSymbolNumber + 1;
-
- // It is unsafe to draw all characters in a single row -
- // this leads to problems on some graphic cards with small GL_MAX_TEXTURE_SIZE.
- // So splitting the characters into rows each containing 32 characters (or less).
- // Assuming contant height of each row (64 pixels) to simplify texture mapping.
- // However, this can be improved if necessary.
- QFontMetrics aFM( myQFont );
- myFontHeight = aFM.height();
-
- myWidths = new int[myNbSymbols];
- myPositions = new int[myNbSymbols];
-
- for( int i = 0, k = FirstSymbolNumber, aWidth = 0; i < myNbSymbols; i++, k++ )
- {
- // is it time to start a new row?
- if ( !( i % TEX_ROW_LEN ) )
- {
- if( aWidth > myMaxRowWidth )
- myMaxRowWidth = aWidth;
- aWidth = 0;
- }
- myWidths[i] = aFM.width( k );
- myPositions[i] = aWidth;
- aWidth += myWidths[i] + 2;
- }
-
- myTexFontWidth = 0;
- myTexFontHeight = 0;
-}
-
-/*!
- Generating font texture
-*/
-bool GLViewer_TexFont::generateTexture()
-{
- GLViewer_TexFindId aFindFont;
- aFindFont.myFontFamily = myQFont.family();//myQFont.toString();
- aFindFont.myIsBold = myQFont.bold();
- aFindFont.myIsItal = myQFont.italic();
- aFindFont.myIsUndl = myQFont.underline();
- aFindFont.myPointSize = myQFont.pointSize();
- aFindFont.myViewPortId = size_t(QGLContext::currentContext());
-
- if( TexFontBase.contains( aFindFont ) )
- {
- GLViewer_TexIdStored aTexture = TexFontBase[ aFindFont ];
- myTexFont = aTexture.myTexFontId;
- myTexFontWidth = aTexture.myTexFontWidth;
- myTexFontHeight = aTexture.myTexFontHeight;
- }
- else
- {
- // Adding some pixels to have a gap between rows
- int aRowPixelHeight = myFontHeight + TEX_ROW_GAP;
- int aDescent = QFontMetrics( myQFont ).descent();
-
- int aNumRows = myNbSymbols / TEX_ROW_LEN;
- if ( myNbSymbols % TEX_ROW_LEN )
- aNumRows++;
- int pixelsHight = aNumRows * aRowPixelHeight;
-
- myTexFontWidth = 64;
- myTexFontHeight = 64;
-
- while( myTexFontWidth < myMaxRowWidth )
- myTexFontWidth <<= 1;
- while( myTexFontHeight < pixelsHight )
- myTexFontHeight <<= 1;
-
- // Checking whether the texture dimensions for the requested font
- // do not exceed the maximum size supported by the OpenGL implementation
- int maxSize;
- glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxSize );
- if ( myTexFontWidth > maxSize || myTexFontHeight > maxSize )
- return false;
-
- QPixmap aPixmap( myTexFontWidth, myTexFontHeight );
- aPixmap.fill( QColor( 0, 0, 0) );
- QPainter aPainter( &aPixmap );
- aPainter.setFont( myQFont );
- int row;
- for( int l = 0; l < myNbSymbols; l++ )
- {
- row = l / TEX_ROW_LEN;
- QString aLetter;
- aLetter += (char)(FirstSymbolNumber + l);
- aPainter.setPen( QColor( 255,255,255) );
- aPainter.drawText( myPositions[l], ( row + 1 ) * aRowPixelHeight - aDescent, aLetter );
- }
-
- QImage aImage = aPixmap.convertToImage();
-
- //int qqq = 0;
- //if (qqq)
- // aImage.save("w:\\work\\CATHARE\\texture.png", "PNG");
-
- char* pixels = new char[myTexFontWidth * myTexFontHeight * NB_TEX_COMP];
-
- for( int i = 0; i < myTexFontHeight; i++ )
- {
- for( int j = 0; j < myTexFontWidth; j++ )
- {
- int aRed = qRed( aImage.pixel( j, myTexFontHeight - i - 1 ) );
- int aGreen = qGreen( aImage.pixel( j, myTexFontHeight - i - 1 ) );
- int aBlue = qBlue( aImage.pixel( j, myTexFontHeight - i - 1 ) );
-
- if( aRed != 0 || aGreen != 0 || aBlue != 0 )
- {
- pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP] = (GLubyte)( (aRed + aGreen + aBlue)/3 );
- pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP + 1]= (GLubyte) 255;
- }
- else
- {
- pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP] = (GLubyte) 0;
- pixels[i * myTexFontWidth * NB_TEX_COMP + j * NB_TEX_COMP + 1]= (GLubyte) 0;
- }
- }
- }
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glGenTextures(1, &myTexFont);
- glBindTexture(GL_TEXTURE_2D, myTexFont);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myMinMagFilter);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myMinMagFilter);
- glTexImage2D(GL_TEXTURE_2D,
- 0,
- GL_INTENSITY,
- myTexFontWidth,
- myTexFontHeight,
- 0,
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_BYTE,
- pixels);
-
- delete[] pixels;
-
- GLViewer_TexIdStored aTexture;
- aTexture.myTexFontId = myTexFont;
- aTexture.myTexFontWidth = myTexFontWidth;
- aTexture.myTexFontHeight = myTexFontHeight;
-
- TexFontBase.insert( aFindFont, aTexture );
- }
- return true;
-}
-
-/*!
- Drawing string in viewer
- \param theStr - string to be drawn
- \param theX - X position
- \param theY - Y position
- \param theScale - scale coefficient
-*/
-void GLViewer_TexFont::drawString( QString theStr, GLdouble theX , GLdouble theY, GLfloat theScale )
-{
- // Adding some pixels to have a gap between rows
- int aRowPixelHeight = myFontHeight + TEX_ROW_GAP;
-
- float aXScale = 1.f, aYScale = 1.f;
- if ( !myIsResizeable )
- {
- glGetFloatv (GL_MODELVIEW_MATRIX, modelMatrix);
- aXScale = modelMatrix[0];
- aYScale = modelMatrix[5];
- }
- else if ( theScale > 0.f )
- {
- aXScale = aXScale / theScale;
- aYScale = aYScale / theScale;
- }
-
- // store attributes
- glPushAttrib( GL_ENABLE_BIT | GL_TEXTURE_BIT );
-
- glEnable(GL_TEXTURE_2D);
- glPixelTransferi(GL_MAP_COLOR, 0);
-
- glAlphaFunc(GL_GEQUAL, 0.05F);
- glEnable(GL_ALPHA_TEST);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-
- glBindTexture(GL_TEXTURE_2D, myTexFont);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- glBegin(GL_QUADS);
-
- float aLettBeginS, aLettEndS, aLettBeginT, aLettEndT;
- float aDY = ( aRowPixelHeight - 1 ) / aYScale, aDX;
- char aLetter;
- int aLettIndex, row;
- for ( int i = 0; i < (int)theStr.length(); i++ )
- {
- aLetter = theStr.data()[i];
- aLettIndex = (int)aLetter - FirstSymbolNumber;
- row = aLettIndex / TEX_ROW_LEN;
-
- aLettBeginS = (float)myPositions[aLettIndex] / ( (float)myTexFontWidth - 1.f );
- aLettEndS = aLettBeginS + ( (float)myWidths[aLettIndex] - 1.f ) / ( (float)myTexFontWidth - 1.f );
- aLettBeginT = ( myTexFontHeight - ( row + 1 ) * aRowPixelHeight ) / ( (float)myTexFontHeight - 1.f );
- aLettEndT = aLettBeginT + ( (float)aRowPixelHeight - 1.f ) / ( (float)myTexFontHeight - 1.f );
-
- aDX = ( (float)myWidths[aLettIndex] - 1.f ) / aXScale;
-
- glTexCoord2f( aLettBeginS, aLettBeginT ); glVertex3f( theX, theY, 1.f );
- glTexCoord2f( aLettBeginS, aLettEndT ); glVertex3f( theX, theY + aDY, 1.f );
- glTexCoord2f( aLettEndS, aLettEndT ); glVertex3f( theX + aDX, theY + aDY, 1.f );
- glTexCoord2f( aLettEndS, aLettBeginT ); glVertex3f( theX + aDX, theY, 1.f );
-
- theX += aDX + mySeparator / aXScale;
- }
-
- glEnd();
- // restore attributes
- glPopAttrib();
-}
-
-/*!
- \return width of string in pixels
-*/
-int GLViewer_TexFont::getStringWidth( QString theStr )
-{
- int aWidth = 0;
- for ( int i = 0; i < (int)theStr.length(); i ++ )
- {
- char aLetter = theStr.data()[i];
- int aLettIndex = (int)aLetter - FirstSymbolNumber;
- aWidth += myWidths[aLettIndex] + mySeparator;
- }
-
- return aWidth;
-}
-
-/*!
- \return height of string in pixels
-*/
-int GLViewer_TexFont::getStringHeight()
-{
- QFontMetrics aFM( myQFont );
- return aFM.height();
-}
-
-/*!
- Generates list base for bitmap fonts
-*/
-static GLuint displayListBase( QFont* theFont )
-{
- if ( !theFont )
- return 0;
- GLuint aList = 0;
- //static QMap<GLViewer_TexFindId, GLuint> fontCache;
- GLViewer_TexFindId aFindFont;
- aFindFont.myFontFamily = theFont->family();//theFont->toString();
- aFindFont.myIsBold = theFont->bold();
- aFindFont.myIsItal = theFont->italic();
- aFindFont.myIsUndl = theFont->underline();
- aFindFont.myPointSize = theFont->pointSize();
-
-#ifdef WIN32
- HGLRC ctx = ::wglGetCurrentContext();
- if ( !ctx )
- return aList;
-
- aFindFont.myViewPortId = (int)ctx;
-
- if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) )
- aList = GLViewer_TexFont::BitmapFontCache[aFindFont];
- else
- {
- GLuint listBase = 0;
- QMap<GLViewer_TexFindId, GLuint>::iterator it = GLViewer_TexFont::BitmapFontCache.begin();
- for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it )
- {
- if ( it.key().myViewPortId == (int)ctx && it.data() > listBase )
- listBase = it.data();
- }
- listBase += 256;
-
- HDC glHdc = ::wglGetCurrentDC();
- ::SelectObject( glHdc, theFont->handle() );
- if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) )
- listBase = 0;
- aList = listBase;
- GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
- }
-#else //X Window
- Display* aDisp = glXGetCurrentDisplay();
- if( !aDisp )
- {
-#ifdef _DEBUG_
- printf( "Can't find current dislay\n" );
-#endif
- return aList;
- }
-
- GLXContext aCont = glXGetCurrentContext();
- if( !aCont )
- {
-#ifdef _DEBUG_
- printf( "Can't find current context\n" );
-#endif
- return aList;
- }
-
- aFindFont.myViewPortId = size_t(aCont);
-
- if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) )
- aList = GLViewer_TexFont::BitmapFontCache[aFindFont];
- else
- {
- GLuint listBase = 0;
- QMap<GLViewer_TexFindId, GLuint>::iterator it = GLViewer_TexFont::BitmapFontCache.begin();
- for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it )
- {
- if ( it.key().myViewPortId == size_t(aCont) && it.data() > listBase )
- listBase = it.data();
- }
- listBase += 256;
-
- //glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase );
- int aFontCont = 0;
- QString aFontDef = theFont->toString();
- char** xFontList = XListFonts( aDisp, aFontDef.latin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont );
- if( !theFont->handle() )
- {
-#ifdef _DEBUG_
- printf( "Can't load font %s. loading default font....\n", aFontDef.latin1()/*aFindFont.myFontString.data()*/ );
-#endif
- QString aFontMask ("-*-*-*-r-*-*-");
- aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 );
-#ifdef _DEBUG_
- printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() );
-#endif
- aFontMask += "-*-*-*-m-*-*-*";
- xFontList = XListFonts( aDisp, aFontMask.data()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont );
- if( aFontCont == 0 )
- {
-#ifdef _DEBUG_
- printf( "Can't load default font\n" );
-#endif
- return 0;
- }
- glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase );
- }
- else
- glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase );
-
- aList = listBase;
- GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
- }
-
-#endif
-
- return aList;
-}
-
-/*!
- Default constructor
-*/
-GLViewer_Drawer::GLViewer_Drawer()
-: myFont( "Helvetica", 10, QFont::Bold )
-{
- myXScale = myYScale = 0.0;
- myObjects.clear();
- myTextList = 0/*-1*/;
- myObjectType = "GLViewer_Object";
- myPriority = 0;
- myTextFormat = DTF_BITMAP;
- myTextScale = 0.125;
-}
-
-/*!
- Destructor
-*/
-GLViewer_Drawer::~GLViewer_Drawer()
-{
- myObjects.clear();
- glDeleteLists( myTextList, 1 );
-}
-
-/*!
- Clears all generated textures
-*/
-void GLViewer_Drawer::destroyAllTextures()
-{
- QMap<GLViewer_TexFindId,GLViewer_TexIdStored>::Iterator anIt= GLViewer_TexFont::TexFontBase.begin();
- QMap<GLViewer_TexFindId,GLViewer_TexIdStored>::Iterator anEndIt= GLViewer_TexFont::TexFontBase.end();
-
- for( ; anIt != anEndIt; anIt++ )
- glDeleteTextures( 1, &(anIt.data().myTexFontId) );
-}
-
-/*!
- Enables and disables antialiasing in Open GL (for points, lines and polygons).
- \param on - if it is true, antialiasing is enabled
-*/
-void GLViewer_Drawer::setAntialiasing(const bool on)
-{
- if (on)
- {
- glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
- glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
-
- glEnable(GL_POINT_SMOOTH);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_POLYGON_SMOOTH);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable (GL_BLEND);
- }
- else
- {
- glDisable(GL_POINT_SMOOTH);
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_POLYGON_SMOOTH);
- glBlendFunc (GL_ONE, GL_ZERO);
- glDisable (GL_BLEND);
- }
-}
-
-/*! Loads texture from file
- \param fileName - the name of texture file
- \param x_size - the horizontal size of picture ( less or equal texture horizontal size )
- \param y_size - the vertical size of picture ( less or equal texture vertical size )
- \param t_size - the size of texture ( texture vertical size equals texture horizontal size )
-*/
-GLuint GLViewer_Drawer::loadTexture( const QString& fileName,
- GLint* x_size,
- GLint* y_size,
- GLint* t_size )
-{
- QImage buf;
- if ( fileName.isEmpty() || !buf.load( fileName ) )
- return 0;
-
- int w = buf.width();
- int h = buf.height();
-
- int size = 16;
- while( size < w || size < h )
- size = size * 2;
-
- GLuint texture;
- GLubyte* pixels = new GLubyte[ size * size * 4 ];
-
- for( int i = 0; i < size; i++ )
- {
- for( int j = 0; j < size; j++ )
- {
- GLubyte r, g, b, a;
- if( j < w && i < h )
- {
- QRgb pixel = buf.pixel( j, h - i - 1 );
- r = (GLubyte)qRed( pixel );
- g = (GLubyte)qGreen( pixel );
- b = (GLubyte)qBlue( pixel );
- a = (GLubyte)qAlpha( pixel );
- }
- else
- {
- r = (GLubyte)255;
- g = (GLubyte)255;
- b = (GLubyte)255;
- a = (GLubyte)255;
- }
-
- int index = 4 * ( i * size + j );
- pixels[ index ] = r;
- pixels[ index + 1 ] = g;
- pixels[ index + 2 ] = b;
- pixels[ index + 3 ] = a;
- }
- }
-
- //initialize texture
- glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- glGenTextures( 1, &texture );
- glBindTexture( GL_TEXTURE_2D, texture );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, pixels );
-
- delete[] pixels;
-
- if ( x_size )
- *(x_size) = w;
-
- if ( y_size )
- *(y_size) = h;
-
- if ( t_size )
- *(t_size) = size;
-
- return texture;
-}
-
-/*! Draw square texture
- \param texture - the texture ID
- \param size - the size of square texture
- \param x - x coord
- \param y - y coord
-*/
-void GLViewer_Drawer::drawTexture( GLuint texture, GLint size, GLfloat x, GLfloat y )
-{
- /*float xScale = myXScale;
- float yScale = myYScale;
-
- glColor4f( 1.0, 1.0, 1.0, 1.0 );
-
- glEnable( GL_TEXTURE_2D );
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- glAlphaFunc( GL_GREATER, 0.95F );
- glEnable( GL_ALPHA_TEST );
-
- glBindTexture( GL_TEXTURE_2D, texture );
- glBegin( GL_QUADS );
-
- glTexCoord2f( 0.0, 0.0 );
- glVertex3f( x-size/2./xScale, y-size/2./yScale, 0.0 );
-
- glTexCoord2f( 0.0, 1.0 );
- glVertex3f( x-size/2./xScale, y+size/2./yScale, 0.0 );
-
- glTexCoord2f( 1.0, 1.0 );
- glVertex3f( x+size/2./xScale, y+size/2./yScale, 0.0 );
-
- glTexCoord2f( 1.0, 0.0 );
- glVertex3f( x+size/2./xScale, y-size/2./yScale, 0.0 );
-
- glEnd();
- glFlush();
-
- glDisable( GL_ALPHA_TEST );
- glDisable( GL_TEXTURE_2D );*/
-
- drawTexture( texture, size, size, x, y );
-}
-
-/*! Draw texture
- \param texture - the texture ID
- \param x_size - the horizontal size of texture
- \param y_size - the vertical size of texture
- \param x - x coord
- \param y - y coord
-*/
-void GLViewer_Drawer::drawTexture( GLuint texture, GLint x_size, GLint y_size, GLfloat x, GLfloat y )
-{
- /*float xScale = myXScale;
- float yScale = myYScale;
-
- glColor4f( 1.0, 1.0, 1.0, 1.0 );
-
- glEnable( GL_TEXTURE_2D );
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- glAlphaFunc( GL_GREATER, 0.95F );
- glEnable( GL_ALPHA_TEST );
-
- glBindTexture( GL_TEXTURE_2D, texture );
- glBegin( GL_QUADS );
-
- glTexCoord2f( 0.0, 0.0 );
- glVertex3f( x-x_size/2./xScale, y-y_size/2./yScale, 0.0 );
-
- glTexCoord2f( 0.0, 1.0 );
- glVertex3f( x-x_size/2./xScale, y+y_size/2./yScale, 0.0 );
-
- glTexCoord2f( 1.0, 1.0 );
- glVertex3f( x+x_size/2./xScale, y+y_size/2./yScale, 0.0 );
-
- glTexCoord2f( 1.0, 0.0 );
- glVertex3f( x+x_size/2./xScale, y-y_size/2./yScale, 0.0 );
-
- glEnd();
- glFlush();
-
- glDisable( GL_ALPHA_TEST );
- glDisable( GL_TEXTURE_2D );*/
- drawTexturePart( texture, 1.0, 1.0, x_size, y_size, x, y );
-}
-
-/*! Draw texture part
- \param texture - the texture ID
- \param x_ratio - the horizontal ratio of texture part
- \param y_ratio - the vertical ratio of texture part
- \param x_size - the horizontal size of texture
- \param y_size - the vertical size of texture
- \param x - x coord
- \param y - y coord
- \param scale - common scale factor ( if = 0, use drawer scales )
-*/
-void GLViewer_Drawer::drawTexturePart( GLuint texture,
- GLfloat x_ratio,
- GLfloat y_ratio,
- GLfloat x_size,
- GLfloat y_size,
- GLfloat x,
- GLfloat y,
- GLfloat scale )
-{
- if( !texture )
- return;
-
- float xScale = scale > 0. ? 1./scale : myXScale;
- float yScale = scale > 0. ? 1./scale : myYScale;
-
- glColor4f( 1.0, 1.0, 1.0, 1.0 );
-
-
- glEnable( GL_TEXTURE_2D );
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
- bool hasAlpha = glIsEnabled( GL_ALPHA_TEST );
- glDisable( GL_ALPHA_TEST );
-
- glBindTexture( GL_TEXTURE_2D, texture );
- glBegin( GL_QUADS );
-
- glTexCoord2f( 0.0, 0.0 );
- glVertex3f( x-x_size/2./xScale, y-y_size/2./yScale, 0.0 );
-
- glTexCoord2f( 0.0, y_ratio );
- glVertex3f( x-x_size/2./xScale, y+y_size/2./yScale, 0.0 );
-
- glTexCoord2f( x_ratio, y_ratio );
- glVertex3f( x+x_size/2./xScale, y+y_size/2./yScale, 0.0 );
-
- glTexCoord2f( x_ratio, 0.0 );
- glVertex3f( x+x_size/2./xScale, y-y_size/2./yScale, 0.0 );
-
- glEnd();
- glFlush();
-
- if ( hasAlpha )
- glEnable( GL_ALPHA_TEST );
-
- glDisable( GL_TEXTURE_2D );
-}
-
-/*!
- Draw text
- \param text - text to be drawn
- \param xPos - x position
- \param yPos - y position
- \param color - color of text
- \param theFont - font of text
- \param theSeparator - letter separator
- \param theFormat - text format (by default DTF_BITMAP)
-*/
-void GLViewer_Drawer::drawText( const QString& text, GLfloat xPos, GLfloat yPos,
- const QColor& color, QFont* theFont, int theSeparator, DisplayTextFormat theFormat )
-{
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
-
- if( theFormat != DTF_BITMAP )
- {
- GLViewer_TexFont aTexFont( theFont, theSeparator, theFormat == DTF_TEXTURE_SCALABLE, GL_LINEAR );
- // Font texture was not found or generated --> cannot draw text
- if ( !aTexFont.generateTexture() )
- return;
-
- if ( theFormat == DTF_TEXTURE_SCALABLE )
- aTexFont.drawString( text, xPos, yPos, textScale() );
- else
- aTexFont.drawString( text, xPos, yPos );
- }
- else
- {
- glRasterPos2f( xPos, yPos );
- glListBase( displayListBase( theFont ) );
- glCallLists( text.length(), GL_UNSIGNED_BYTE, text.local8Bit().data() );
- }
-}
-
-/*!
- Draws object-text
-*/
-void GLViewer_Drawer::drawText( GLViewer_Object* theObject )
-{
- if( !theObject )
- return;
-
- GLViewer_Text* aText = theObject->getGLText();
- if( !aText )
- return;
-
- GLfloat aPosX, aPosY;
- aText->getPosition( aPosX, aPosY );
- // get temporary copy of font
- QFont aTmpVarFont = aText->getFont();
- drawText( aText->getText(), aPosX, aPosY, aText->getColor(), &aTmpVarFont, aText->getSeparator(), aText->getDisplayTextFormat() );
-}
-
-/*! Draw text
- \param text - the text string
- \param x - x coord
- \param y - y coord
- \param hPosition - horizontal alignment
- \param vPosition - vertical alignment
- \param color - text color
- \param smallFont - font format
-*/
-void GLViewer_Drawer::drawGLText( QString text, float x, float y,
- int hPosition, int vPosition, QColor color, bool smallFont )
-{
- QFont aFont( myFont );
- if( smallFont )
- aFont.setPointSize( int(aFont.pointSize() * 0.8) );
-
- GLfloat scale = textScale() > 0. ? textScale() : 1.;
-
- QFontMetrics aFontMetrics( aFont );
- float width = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.width( text ) * scale : aFontMetrics.width( text ) / myXScale;
- float height = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.height() * scale : aFontMetrics.height() / myYScale;
- float gap = 5 / myXScale;
-
- switch( hPosition )
- {
- case GLText_Left : x -= ( gap + width ); break;
- case GLText_Center : x -= width / 2; break;
- case GLText_Right : x += gap; break;
- default : break;
- }
-
- switch( vPosition )
- {
- case GLText_Top : y += height * 0.5; break;
- case GLText_Center : y -= height * 0.5; break;
- case GLText_Bottom : y -= height * 1.5; break;
- default : break;
- }
-
- drawText( text, x, y, color, &aFont, 2, myTextFormat );
-}
-
-/*!
- \return a rectangle of text (without viewer scale)
-*/
-GLViewer_Rect GLViewer_Drawer::textRect( const QString& text ) const
-{
- GLfloat scale = textScale() > 0. ? textScale() : 1.;
-
- QFontMetrics aFontMetrics( myFont );
- float width = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.width( text ) * scale : aFontMetrics.width( text );
- float height = myTextFormat == DTF_TEXTURE_SCALABLE ? aFontMetrics.height() * scale : aFontMetrics.height();
-
- return GLViewer_Rect( 0, width, height, 0 );
-}
-
-/*!
- Draws rectangle
- \param rect - instance of primitive
- \param color - color of primitive
-*/
-void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, QColor color )
-{
- if( !rect )
- return;
-
- float x1 = rect->left();
- float x2 = rect->right();
- float y1 = rect->bottom();
- float y2 = rect->top();
-
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glLineWidth( 1.0 );
-
- glBegin( GL_LINE_LOOP );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
-}
-
-/*!
- Saves object to file with format of HPGL
- \param hFile - file
- \param aViewerCS - viewer co-ordinate system
- \param aHPGLCS - paper co-ordinate system
-*/
-bool GLViewer_Drawer::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
-{
- bool result = true;
- for( int i=0, n=myObjects.count(); i<n; i++ )
- result &= myObjects[i]->translateToHPGL( hFile, aViewerCS, aHPGLCS );
- return result;
-}
-
-/*!
- Saves object to file with format of PostScript
- \param hFile - file
- \param aViewerCS - viewer co-ordinate system
- \param aPSCS - paper co-ordinate system
-*/
-bool GLViewer_Drawer::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
-{
- bool result = true;
- for( int i=0, n=myObjects.count(); i<n; i++ )
- result &= myObjects[i]->translateToPS( hFile, aViewerCS, aPSCS );
- return result;
-}
-
-#ifdef WIN32
-/*!
- Saves object to file with format of EMF
- \param hFile - file
- \param aViewerCS - viewer co-ordinate system
- \param aEMFCS - paper co-ordinate system
-*/
-bool GLViewer_Drawer::translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
-{
- bool result = true;
- for( int i=0, n=myObjects.count(); i<n; i++ )
- result &= myObjects[i]->translateToEMF( hDC, aViewerCS, aEMFCS );
- return result;
-}
-#endif
-
-/*!
- Draws rectangle
- \param rect - instance of primitive
- \param lineWidth - width of line
- \param gap - gap of rectangle
- \param color - color of primitive
- \param filled - if it is true, then rectangle will be drawn filled with color "fillingColor"
- \param fillingColor - color of filling
-*/
-void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, GLfloat lineWidth, GLfloat gap,
- QColor color, bool filled, QColor fillingColor )
-{
- if( !rect )
- return;
-
- float x1 = rect->left() - gap;
- float x2 = rect->right() + gap;
- float y1 = rect->bottom() - gap;
- float y2 = rect->top() + gap;
-
- if( filled )
- {
- glColor3f( ( GLfloat )fillingColor.red() / 255,
- ( GLfloat )fillingColor.green() / 255,
- ( GLfloat )fillingColor.blue() / 255 );
- glBegin( GL_POLYGON );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
- }
-
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glLineWidth( lineWidth );
-
- glBegin( GL_LINE_LOOP );
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
- glEnd();
-}
-
-/*!
- Draws contour
- \param pntList - list of points
- \param color - color of contour
- \param lineWidth - width of line
-*/
-void GLViewer_Drawer::drawContour( const GLViewer_PntList& pntList, QColor color, GLfloat lineWidth )
-{
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glLineWidth( lineWidth );
-
- glBegin( GL_LINES );
- QValueList<GLViewer_Pnt>::const_iterator it = pntList.begin();
- for( ; it != pntList.end(); ++it )
- glVertex2f( (*it).x(), (*it).y() );
- glEnd();
-}
-
-/*!
- Draws rectangular contour
- \param rect - instance of rectangle
- \param color - color of primitive
- \param lineWidth - width of line
- \param pattern - pattern of line
- \param isStripe - enables line stipple
-*/
-void GLViewer_Drawer::drawContour( GLViewer_Rect* rect, QColor color, GLfloat lineWidth,
- GLushort pattern, bool isStripe )
-{
- float x1 = rect->left();
- float x2 = rect->right();
- float y1 = rect->bottom();
- float y2 = rect->top();
-
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glLineWidth( lineWidth );
-
- if ( isStripe )
- {
- glEnable( GL_LINE_STIPPLE );
- glLineStipple( 1, pattern );
- }
-
- glBegin( GL_LINE_LOOP );
-
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
-
- glEnd();
- glDisable( GL_LINE_STIPPLE );
-}
-
-/*!
- Draws polygon
- \param pntList - list of points
- \param color - color of polygon
-*/
-void GLViewer_Drawer::drawPolygon( const GLViewer_PntList& pntList, QColor color )
-{
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
- glBegin( GL_POLYGON );
- QValueList<GLViewer_Pnt>::const_iterator it = pntList.begin();
- for( ; it != pntList.end(); ++it )
- glVertex2f( (*it).x(), (*it).y() );
- glEnd();
-}
-
-/*!
- Draws rectangle
- \param rect - instance of rectangle
- \param color - color of polygon
- \param pattern - pattern of line
- \param isStripe - enables line stipple
-*/
-void GLViewer_Drawer::drawPolygon( GLViewer_Rect* rect, QColor color,
- GLushort pattern, bool isStripe )
-{
- float x1 = rect->left();
- float x2 = rect->right();
- float y1 = rect->bottom();
- float y2 = rect->top();
- glColor3f( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255 );
-
- if ( isStripe )
- {
- glEnable( GL_LINE_STIPPLE );
- glLineStipple( 1, pattern );
- }
- glBegin( GL_POLYGON );
-
- glVertex2f( x1, y1 );
- glVertex2f( x1, y2 );
- glVertex2f( x2, y2 );
- glVertex2f( x2, y1 );
-
- glEnd();
- glDisable( GL_LINE_STIPPLE );
-}
-
-GLubyte rasterVertex[5] = { 0x70, 0xf8, 0xf8, 0xf8, 0x70 };
-
-/*!
- Draws vertex
- \param x - x position
- \param y - y position
- \param color - color of vertex
-*/
-void GLViewer_Drawer::drawVertex( GLfloat x, GLfloat y, QColor color )
-{
- glColor3f( ( GLfloat )color.red() / 255, ( GLfloat )color.green() / 255, ( GLfloat )color.blue() / 255 );
- glRasterPos2f( x, y );
- glBitmap( 5, 5, 2, 2, 0, 0, rasterVertex );
-}
-
-GLubyte rasterCross[7] = { 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82 };
-
-/*!
- Draws cross
- \param x - x position
- \param y - y position
- \param color - color of cross
-*/
-void GLViewer_Drawer::drawCross( GLfloat x, GLfloat y, QColor color )
-{
- glColor3f( ( GLfloat )color.red() / 255, ( GLfloat )color.green() / 255, ( GLfloat )color.blue() / 255 );
- glRasterPos2f( x, y );
- glBitmap( 7, 7, 3, 3, 0, 0, rasterCross );
-}
-
-/*!
- Draws arrow
- \param red, green, blue - components of color
- \param lineWidth - width of line
- \param staff -
- \param length - length of arrow
- \param width - width of arrow
- \param x - x position
- \param y - y position
- \param angle - angle of arrow
- \param filled - drawn as filled
-*/
-void GLViewer_Drawer::drawArrow( const GLfloat red, const GLfloat green, const GLfloat blue,
- GLfloat lineWidth,
- GLfloat staff, GLfloat length, GLfloat width,
- GLfloat x, GLfloat y, GLfloat angle, GLboolean filled )
-{
- GLfloat vx1 = x;
- GLfloat vy1 = y + staff + length;
- GLfloat vx2 = vx1 - width / 2;
- GLfloat vy2 = vy1 - length;
- GLfloat vx3 = vx1 + width / 2;
- GLfloat vy3 = vy1 - length;
-
- gp_Pnt2d p0( x, y );
- gp_Pnt2d p1( vx1, vy1 );
- gp_Pnt2d p2( vx2, vy2 );
- gp_Pnt2d p3( vx3, vy3 );
-
- p1.Rotate( p0, angle );
- p2.Rotate( p0, angle );
- p3.Rotate( p0, angle );
-
- vx1 = p1.X(); vy1 = p1.Y();
- vx2 = p2.X(); vy2 = p2.Y();
- vx3 = p3.X(); vy3 = p3.Y();
-
- glColor3f( red, green, blue );
- glLineWidth( lineWidth );
-
- glBegin( GL_LINES );
- glVertex2f( x, y );
- glVertex2f( vx1, vy1 );
- glEnd();
-
- filled = true;
- if( !filled )
- {
- glBegin( GL_LINES );
- glVertex2f( vx1, vy1 );
- glVertex2f( vx2, vy2 );
- glVertex2f( vx1, vy1 );
- glVertex2f( vx3, vy3 );
- glEnd();
- }
- else
- {
- glBegin( GL_POLYGON );
- glVertex2f( vx1, vy1 );
- glVertex2f( vx2, vy2 );
- glVertex2f( vx3, vy3 );
- glEnd();
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Drawer.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_DRAWER_H
-#define GLVIEWER_DRAWER_H
-
-#ifdef WNT
-#include "windows.h"
-#endif
-
-#include <qcolor.h>
-#include <qobject.h>
-#include <qfile.h>
-#include <qfont.h>
-#include <qgl.h>
-
-#include <GL/gl.h>
-
-#include "GLViewer.h"
-#include "GLViewer_Defs.h"
-#include "GLViewer_Geom.h"
-
-class GLViewer_Object;
-class GLViewer_Rect;
-class GLViewer_CoordSystem;
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-/*!
- * Struct GLViewer_TexIdStored
- * Structure for store information about texture
- */
-struct GLVIEWER_API GLViewer_TexIdStored
-{
- //! Texture ID
- GLuint myTexFontId;
- //! Texture width
- int myTexFontWidth;
- //! texture height
- int myTexFontHeight;
-};
-
-/*!
- * Struct GLViewer_TexFindId
- * Structure for srorage information about texture font
- */
-struct GLVIEWER_API GLViewer_TexFindId
-{
- //! Font family description
- QString myFontFamily;
- //! Bold parameter
- bool myIsBold;
- //! Italic parameter
- bool myIsItal;
- //! Underline parameter
- bool myIsUndl;
- //! Font Size
- int myPointSize;
- //! View POrt ID
- int myViewPortId;
- //! Overloaded operator for using struct as MAP key
- bool operator < (const GLViewer_TexFindId theStruct) const
- {
- if ( myViewPortId != theStruct.myViewPortId )
- return myViewPortId < theStruct.myViewPortId;
- else if ( myPointSize != theStruct.myPointSize )
- return myPointSize < theStruct.myPointSize;
- else if ( myIsBold != theStruct.myIsBold )
- return myIsBold < theStruct.myIsBold;
- else if ( myIsItal != theStruct.myIsItal )
- return myIsItal < theStruct.myIsItal;
- else if ( myIsUndl != theStruct.myIsUndl )
- return myIsUndl < theStruct.myIsUndl;
- else
- return myFontFamily < theStruct.myFontFamily;
- }
-};
-
-/*!
- \class GLViewer_TexFont
- Font for GLViewer_Drawer, Drawing bitmap and texture fonts in GLViewer
-*/
-
-class GLVIEWER_API GLViewer_TexFont
-{
-public:
- //! A default constructor
- GLViewer_TexFont();
- //! A constructor
- /*
- * \param theFont - a base font
- * \param theSeparator - separator between letters
- * \param theIsResizeable - specifies whether text drawn by this object can be scaled along with the scene
- * \param theMinMagFilter - min/mag filter, affects text sharpness
- */
- GLViewer_TexFont( QFont* theFont,
- int theSeparator = 2,
- bool theIsResizeable = false,
- GLuint theMinMagFilter = GL_LINEAR/*_ATTENUATION*/ );
- //! A destructor
- ~GLViewer_TexFont();
-
- //! Generating font texture
- bool generateTexture();
- //! Drawing string theStr in point with coords theX and theY
- void drawString( QString theStr,
- GLdouble theX = 0.0,
- GLdouble theY = 0.0,
- GLfloat theScale = 1.0 );
-
- //! Returns separator between letters
- int getSeparator(){ return mySeparator; }
- //! Installing separator between letters
- void setSeparator( int theSeparator ){ mySeparator = theSeparator; }
-
- //! Returns width of string in pixels
- int getStringWidth( QString theString );
- //! Returns height of string in pixels
- int getStringHeight();
-
- //! Clears all generated fonts
- static void clearTextBases();
-
- //! Map for strorage generated texture fonts
- static QMap<GLViewer_TexFindId,GLViewer_TexIdStored> TexFontBase;
- //! Map for strorage generated bitmaps fonts
- static QMap<GLViewer_TexFindId,GLuint> BitmapFontCache;
-
-private:
- //! Initializes font parameters
- void init();
-
-private:
- //! Number of characters in the font texture
- int myNbSymbols;
- //! Array of letter width
- int* myWidths;
- //! Array of letter positions in texture
- int* myPositions;
- //! Pointer to base font
- QFont myQFont;
- //! Font texture ID
- GLuint myTexFont;
- //! Font texture width
- int myTexFontWidth;
- //! Font texture height
- int myTexFontHeight;
- //! Separator between letters
- int mySeparator;
- //! Flag controlling scalability of this texmapped font
- bool myIsResizeable;
- //! Min/mag filter
- GLuint myMinMagFilter;
- //! Font height
- int myFontHeight;
- //! Diagnostic information
- int myMaxRowWidth;
-};
-
-/*!
- \class GLViewer_Drawer
- Drawer for GLViewer_Objects.
- Drawer creates only one times per one type of object
-*/
-class GLVIEWER_API GLViewer_Drawer
-{
-public:
- //! Text position relatively object
- enum
- {
- GLText_Center = 0,
- GLText_Left,
- GLText_Right,
- GLText_Top,
- GLText_Bottom
- };
-
- // Objects status ( needs for change colors )
- //enum ObjectStatus
- //{
- // OS_Normal = 0,
- // OS_Highlighted,
- // OS_Selected
- //};
-
- //
- //enum ClosedStatus
- //{
- // CS_CLOSED = 0,
- // CS_OPEN = 1
- //};
-
- //! A constructor
- GLViewer_Drawer();
- //! A destructor
- virtual ~GLViewer_Drawer();
-
- //! Main method which drawing object in GLViewer
- /*
- *\param xScale - current scale along X-direction
- *\param yScale - current scale along Y-direction
- *\param onlyUpdate - = true if only update highlight-select information
- */
- virtual void create( float xScale, float yScale, bool onlyUpdate ) = 0;
-
- //! Adds object to drawer display list
- virtual void addObject( GLViewer_Object* theObject ){ myObjects.append( theObject ); }
- //! Clears drawer display list
- virtual void clear(){ myObjects.clear(); }
-
- //! Returns object type (needs for dynamic search of right drawer )
- QString getObjectType() const { return myObjectType; }
-
- //! Returns object priority
- int getPriority() const { return myPriority; }
-
- //! The function enables and disables antialiasing in Open GL (for points, lines and polygons).
- void setAntialiasing(const bool on);
-
- //! Clears all generated textures
- static void destroyAllTextures();
-
- //! A function translate object in to HPGL file on disk
- /*!
- *\param hFile the name of PostScript file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
- */
- virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS );
-
- //! A function translate object in to PostScript file on disk
- /*!
- *\param hFile the name of PostScript file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aPSCS the GLViewer_CoordSystem of PostScript page
- */
- virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
-
-#ifdef WIN32
- //! A function translate object in to EMF file on disk
- /*!
- *\warning WIN32 only
- *
- *\param dc the name of HDC associated with file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aEMFCS the GLViewer_CoordSystem of EMF page
- */
- virtual bool translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
-#endif
-
- //! Loads texture from file
- /*!
- *\param fileName - the name of texture file
- *\param x_size - the horizontal size of picture ( less or equal texture horizontal size )
- *\param y_size - the vertical size of picture ( less or equal texture vertical size )
- *\param t_size - the size of texture ( texture vertical size equals texture horizontal size )
- */
- static GLuint loadTexture( const QString& fileName,
- GLint* x_size = 0,
- GLint* y_size = 0,
- GLint* t_size = 0);
-
- //! Draw square texture
- /*!
- *\param texture - the texture ID
- *\param size - the size of square texture
- *\param x - x coord
- *\param y - y coord
- */
- void drawTexture( GLuint texture,
- GLint size,
- GLfloat x,
- GLfloat y );
-
- //! Draw texture
- /*!
- *\param texture - the texture ID
- *\param x_size - the horizontal size of texture
- *\param y_size - the vertical size of texture
- *\param x - x coord
- *\param y - y coord
- */
- void drawTexture( GLuint texture,
- GLint x_size,
- GLint y_size,
- GLfloat x,
- GLfloat y );
-
- //! Draw texture part
- /*!
- *\param texture - the texture ID
- *\param x_ratio - the horizontal ratio of texture part
- *\param y_ratio - the vertical ratio of texture part
- *\param x_size - the horizontal size of texture
- *\param y_size - the vertical size of texture
- *\param x - x coord
- *\param y - y coord
- *\param scale - common scale factor ( if = 0, use drawer scales )
- */
- void drawTexturePart( GLuint texture,
- GLfloat x_ratio,
- GLfloat y_ratio,
- GLfloat x_size,
- GLfloat y_size,
- GLfloat x,
- GLfloat y,
- GLfloat scale = 0 );
-
-
-
- //! Draw text string
- /*!
- *\param text - the text string
- *\param xPos - x coord
- *\param yPos - y coord
- *\param color - text color
- *\param aFont - base font of text
- *\param theSeparator - letter separator
- *\param DisplayTextFormat - text format
- */
- void drawText( const QString& text,
- GLfloat xPos,
- GLfloat yPos,
- const QColor& color,
- QFont* aFont,
- int theSeparator,
- DisplayTextFormat = DTF_BITMAP );
-
- //! Draw text string
- /*!
- *\param text - the text string
- *\param x - x coord
- *\param y - y coord
- *\param hPosition - horizontal alignment
- *\param vPosition - vertical alignment
- *\param color - text color
- *\param smallFont - font format
- */
- void drawGLText( QString text,
- float x,
- float y,
- int hPosition = GLText_Center,
- int vPosition = GLText_Center,
- QColor color = Qt::black,
- bool smallFont = false );
-
- //! Sets a default font to be used by drawGLText method
- /*!
- *\param font - the default font
- */
- inline void setFont( const QFont& font ) { myFont = font; }
-
- //! Returns a default font used by drawGLText method
- inline QFont font() const { return myFont; }
-
- //! Sets a default text displaying format to be used by drawGLText method
- /*!
- *\param format - the default text displaying format
- */
- inline void setTextFormat( const DisplayTextFormat format ) { myTextFormat = format; }
-
- //! Returns a default text displaying format used by drawGLText method
- inline DisplayTextFormat textFormat() const { return myTextFormat; }
-
- //! Sets a text string displaying scale factor (used only with text format DTF_TEXTURE_SCALABLE)
- /*!
- *\param factor - scale factor
- */
- inline void setTextScale( const GLfloat factor ) { myTextScale = factor; }
-
- //! Returns a text string displaying scale factor
- inline GLfloat textScale() const { return myTextScale; }
-
- //! Returns a rectangle of text (without viewer scale)
- GLViewer_Rect textRect( const QString& ) const;
-
-
- //! Draw rectangle with predefined color
- static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black );
-
-protected:
- //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow
- //* with predefined color
- static void drawRectangle( GLViewer_Rect*, GLfloat, GLfloat = 0, QColor = Qt::black,
- bool = false, QColor = Qt::white );
- static void drawContour( GLViewer_Rect*, QColor, GLfloat, GLushort, bool );
- static void drawContour( const GLViewer_PntList&, QColor, GLfloat );
- static void drawPolygon( GLViewer_Rect*, QColor, GLushort, bool );
- static void drawPolygon( const GLViewer_PntList&, QColor );
- static void drawVertex( GLfloat, GLfloat, QColor );
- static void drawCross( GLfloat, GLfloat, QColor );
- static void drawArrow( const GLfloat red, const GLfloat green, const GLfloat blue,
- GLfloat, GLfloat, GLfloat, GLfloat,
- GLfloat, GLfloat, GLfloat, GLboolean = GL_FALSE );
-
- //! Draw object text
- virtual void drawText( GLViewer_Object* theObject );
-
- //! X Scale factor
- float myXScale;
- //! Y scale factor
- float myYScale;
-
- //! List of objects
- QValueList<GLViewer_Object*> myObjects;
- //! List generated textures
- GLuint myTextList;
-
- //! Type of supporting object
- QString myObjectType;
- //! Dislay priority
- int myPriority;
-
- //! Default font for drawGLText() method
- QFont myFont;
- //! Default text displaying format for drawGLText() method
- DisplayTextFormat myTextFormat;
-
- //! Scale factor for text string draw, by default 0.125
- //! (used only with text format DTF_TEXTURE_SCALABLE)
- GLfloat myTextScale;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif // GLVIEWER_DRAWER_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-//#include <GLViewerAfx.h>
-#include <GLViewer_Geom.h>
-
-#define FAR_POINT 1e10 // Value used as a "very distant" co-ordinate
-#define TOLERANCE 1e-3
-
-/*!
- constructs a real segment bounded by two points
-*/
-GLViewer_Segment::GLViewer_Segment( const GLViewer_Pnt& thePnt1,
- const GLViewer_Pnt& thePnt2 )
-: myPnt1( thePnt1 ),
- myPnt2( thePnt2 )
-{
- myA = myPnt1.y() - myPnt2.y();
- myB = myPnt2.x() - myPnt1.x();
- myC = myPnt1.x() * myPnt2.y() - myPnt2.x() * myPnt1.y();
-}
-
-/*!
- constructs a ray starting at <thePnt> and directed along positive X axis direction (or Y axis if vertical )
-*/
-GLViewer_Segment::GLViewer_Segment( const GLViewer_Pnt& thePnt,
- const GLfloat theA,
- const GLfloat theB,
- const GLfloat theC )
-: myPnt1( thePnt ),
- myA( theA ),
- myB( theB ),
- myC( theC )
-{
- if ( fabs( myB ) < TOLERANCE )
- myPnt2 = GLViewer_Pnt( myPnt1.x(), FAR_POINT );
- else
- myPnt2 = GLViewer_Pnt( FAR_POINT, - myA / myB * FAR_POINT - myC / myB );
-}
-
-/*!
- destructor, does nothing
-*/
-GLViewer_Segment::~GLViewer_Segment()
-{
-}
-
-/*!
- detects intersection with segment <theOther>
-*/
-bool GLViewer_Segment::HasIntersection( const GLViewer_Segment& theOther ) const
-{
- bool aRes = false;
- GLfloat aDiv = myA * theOther.myB - myB * theOther.myA;
- if ( fabs( aDiv ) > TOLERANCE )
- {
- GLfloat aX = ( myB * theOther.myC - theOther.myB * myC ) / aDiv;
- GLfloat aX11 = myPnt1.x() > myPnt2.x() ? myPnt2.x() : myPnt1.x();
- GLfloat aX12 = myPnt1.x() > myPnt2.x() ? myPnt1.x() : myPnt2.x();
- GLfloat aX21 = theOther.myPnt1.x() > theOther.myPnt2.x() ? theOther.myPnt2.x() : theOther.myPnt1.x();
- GLfloat aX22 = theOther.myPnt1.x() > theOther.myPnt2.x() ? theOther.myPnt1.x() : theOther.myPnt2.x();
-
- GLfloat aY = ( myC * theOther.myA - theOther.myC * myA ) / aDiv;
- GLfloat aY11 = myPnt1.y() > myPnt2.y() ? myPnt2.y() : myPnt1.y();
- GLfloat aY12 = myPnt1.y() > myPnt2.y() ? myPnt1.y() : myPnt2.y();
- GLfloat aY21 = theOther.myPnt1.y() > theOther.myPnt2.y() ? theOther.myPnt2.y() : theOther.myPnt1.y();
- GLfloat aY22 = theOther.myPnt1.y() > theOther.myPnt2.y() ? theOther.myPnt1.y() : theOther.myPnt2.y();
-
- if ( fabs( aX11 - aX12 ) > TOLERANCE )
- aRes = aX11 < aX && aX < aX12;
- else
- aRes = aY11 < aY && aY < aY12;
-
- if ( aRes )
- {
- if ( fabs( aX21 - aX22 ) > TOLERANCE )
- aRes = aX21 < aX && aX < aX22;
- else
- aRes = aY21 < aY && aY < aY22;
- }
- }
-
- return aRes;
-}
-
-/*!
- constructs a closed polygon from the given ordered list of points
-*/
-GLViewer_Poly::GLViewer_Poly( const GLViewer_PntList* thePoints )
-: myPoints( (GLViewer_PntList*)thePoints )
-{
-}
-
-/*!
- destructor, <myPoints> mustn't be deleted here!
-*/
-GLViewer_Poly::~GLViewer_Poly()
-{
-}
-
-/*!
- \return true if <thePnt> lies within this polygon
-*/
-bool GLViewer_Poly::IsIn( const GLViewer_Pnt& thePnt ) const
-{
- if ( !myPoints )
- return false;
-
- //cout << thePnt.x() << endl;
- //cout << thePnt.y() << endl << endl;
-
- int aNbInter = 0;
- GLViewer_Segment aRay( thePnt, 0., 1., -thePnt.y() );
-
- GLViewer_PntList::const_iterator it1 = myPoints->begin();
- GLViewer_PntList::const_iterator it2 = myPoints->begin();
- ++it2;
- for ( ; it1 != myPoints->end(); ++it1, ++it2 )
- {
- if ( it2 == myPoints->end() )
- it2 = myPoints->begin();
-
- if ( aRay.HasIntersection( GLViewer_Segment( *it1, *it2 ) ) )
- aNbInter++;
- }
-
- return ( aNbInter % 2 == 1 );
-}
-/*!
- \return true if <thePnt> lies within this polygon
-*/
-/*
-bool GLViewer_Poly::IsIn( const GLViewer_Pnt& thePnt, const float tolerance ) const
-{
- if ( !myPoints )
- return false;
-
- float x = thePnt.x();
- float y = thePnt.y();
- bool res = false;
-
- GLViewer_Pnt p1( x - tolerance, y - tolerance );
- GLViewer_Pnt p2( x - tolerance, y + tolerance );
- GLViewer_Pnt p3( x + tolerance, y - tolerance );
- GLViewer_Pnt p4( x + tolerance, y + tolerance );
-
- res = ( IsInPnt( thePnt ) ||
- IsInPnt( p1 ) || IsInPnt( p2 ) || IsInPnt( p3 ) || IsInPnt( p4 ) );
-
- return res;
-}
-*/
-/*!
- \return true if <thePoly> covers this polygon
-*/
-bool GLViewer_Poly::IsCovers( const GLViewer_Poly& thePoly ) const
-{
- if ( !myPoints || !thePoly.Count() )
- return false;
-
- GLViewer_PntList::const_iterator it = myPoints->begin();
-
- for ( ; it != myPoints->end(); ++it )
- {
- if( !thePoly.IsIn( *it ) )
- return false;
- }
-
- return true;
-}
-
-/*!
- \return true if <theRect> covers this polygon
-*/
-bool GLViewer_Poly::IsCovers( const GLViewer_Rect& theRect ) const
-{
- if ( !myPoints ) //needs check for <theRect>
- return false;
-
- GLViewer_PntList aList;
- GLViewer_PntList::iterator it = aList.begin();
-
- aList.insert( it, GLViewer_Pnt( theRect.left(), theRect.top() ) );
- aList.insert( it, GLViewer_Pnt( theRect.right(), theRect.top() ) );
- aList.insert( it, GLViewer_Pnt( theRect.right(), theRect.bottom() ) );
- aList.insert( it, GLViewer_Pnt( theRect.left(), theRect.bottom() ) );
-
- return IsCovers( GLViewer_Poly( &aList ) );
-}
-
-/*!
- \return true if polygon has intersection with segment or ray
- \param theSegment - segment to check intersection
-*/
-bool GLViewer_Poly::HasIntersection( const GLViewer_Segment& theSegment ) const
-{
- if ( !myPoints )
- return false;
-
- bool aRes = false;
- GLViewer_PntList::const_iterator it1 = myPoints->begin();
- GLViewer_PntList::const_iterator it2 = myPoints->begin();
- ++it2;
- for ( ; !aRes && it1 != myPoints->end(); ++it1, ++it2 )
- {
- if ( it2 == myPoints->end() )
- it2 = myPoints->begin();
-
- aRes = theSegment.HasIntersection( GLViewer_Segment( *it1, *it2 ) );
- }
-
- return aRes;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Geom.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_GEOM_H
-#define GLVIEWER_GEOM_H
-
-#include "GLViewer.h"
-
-#include <qrect.h>
-#include <qvaluelist.h>
-#include <qgl.h>
-#include <math.h>
-
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*! Struct GLViewer_Pnt
-* Substitution of QPoint for OpenGL
-*/
-
-struct GLVIEWER_API GLViewer_Pnt
-{
-public:
- GLViewer_Pnt() : myX( 0. ), myY( 0. ) {};
- GLViewer_Pnt( GLfloat theX, GLfloat theY ) : myX( theX ), myY( theY ) {}
-
- GLfloat x() const { return myX; }
- GLfloat y() const { return myY; }
- void setX( GLfloat theX ) { myX = theX; }
- void setY( GLfloat theY ) { myY = theY; }
- void setXY( GLfloat theX, GLfloat theY ) { myX = theX; myY = theY; }
- void move( GLfloat theDX, GLfloat theDY ) { myX += theDX; myY += theDY; }
-
-private:
- GLfloat myX;
- GLfloat myY;
-};
-
-typedef QValueList<GLViewer_Pnt> GLViewer_PntList;
-
-/*! Class GLViewer_Rect
-* Substitution of QRect for OpenGL
-*/
-
-class GLVIEWER_API GLViewer_Rect
-{
-public:
- GLViewer_Rect(): myLeft(0.0), myRight(0.0), myTop(0.0), myBottom(0.0){}
- GLViewer_Rect( float theLeft, float theRight, float theTop, float theBottom )
- : myLeft(theLeft), myRight(theRight), myTop(theTop), myBottom(theBottom) {}
- GLViewer_Rect( QRect theRect ) {
- myLeft = ( float )theRect.left(); myRight = ( float )theRect.right();
- myTop = ( float )theRect.top(); myBottom = ( float )theRect.bottom(); }
-
- float left() const { return myLeft; }
- float right() const { return myRight; }
- float top() const { return myTop; }
- float bottom() const { return myBottom; }
-
- float width() const { return fabs( myRight - myLeft ); }
- float height() const { return fabs( myTop - myBottom ); }
-
- void setLeft( float theLeft ) { myLeft = theLeft; }
- void setRight( float theRight ) { myRight = theRight; }
- void setTop( float theTop ) { myTop = theTop; }
- void setBottom( float theBottom ) { myBottom = theBottom; }
-
- void setCoords( float theLeft, float theRight, float theBottom, float theTop )
- { myLeft = theLeft; myRight = theRight; myBottom = theBottom; myTop = theTop; }
-
- //! \warning This method translate only rect format
- QRect toQRect() { return QRect( ( int )myLeft, ( int )myBottom,
- ( int )( myRight - myLeft ),
- ( int )( myTop - myBottom ) ); }
-
- //! On/off empty status
- void setIsEmpty( bool on ) { myIsEmpty = on; }
- //! Checks empty status
- bool isEmpty() const { return myIsEmpty; }
-
- //! Checks null status
- bool isNull() const { return myLeft == 0.0 && myRight == 0.0 && myBottom == 0.0 && myTop == 0.0; }
- //! Checks valid status
- bool isValid() const { return ( myLeft < myRight && myBottom < myTop ); }
-
- //! Checks staus of contains point
- bool contains( GLViewer_Pnt pnt ) { return ( pnt.x() > left() &&
- pnt.x() < right() &&
- pnt.y() > bottom() &&
- pnt.y() < top() ); }
-
- void move( const float x, const float y )
- {
- myLeft += x;
- myRight += x;
- myTop += y;
- myBottom += y;
- }
-
-protected:
- float myLeft;
- float myRight;
- float myTop;
- float myBottom;
-
- bool myIsEmpty;
-};
-
-/*! Class GLViewer_Segment
-* Segment for 2d detection
-*/
-
-class GLVIEWER_API GLViewer_Segment
-{
-public:
- GLViewer_Segment( const GLViewer_Pnt& thePnt1,
- const GLViewer_Pnt& thePnt2 );
-
- //! Ordinary segment construction
- /*!Construction of a ray with given equation Ax + By + C = 0 */
-
- GLViewer_Segment( const GLViewer_Pnt& thePnt,
- const GLfloat theA,
- const GLfloat theB,
- const GLfloat theC );
- ~GLViewer_Segment();
-
- bool HasIntersection( const GLViewer_Segment& theOther ) const;
- // Detects intersection with another segment or ray
-
-private:
- GLViewer_Pnt myPnt1;
- GLViewer_Pnt myPnt2;
- GLfloat myA;
- GLfloat myB;
- GLfloat myC;
-};
-
-/*! Class GLViewer_Poly
-* Polygon for 2d detection
-*/
-
-class GLVIEWER_API GLViewer_Poly
-{
-public:
- GLViewer_Poly( const GLViewer_PntList* thePoints );
- virtual ~GLViewer_Poly();
-
- //! Adds point to polygon
- void AddPoint( GLViewer_Pnt& pnt ) { myPoints->append( pnt ); }
-
- //! Returns number of point
- int Count() const { return myPoints->count(); }
-
- //! Returns true if a point lies inside this polygon
- virtual bool IsIn( const GLViewer_Pnt& thePnt ) const;
-
- //! Returns true if a other polygon covers this polygon
- virtual bool IsCovers( const GLViewer_Poly& thePoly ) const;
-
- //! Likes the above function
- virtual bool IsCovers( const GLViewer_Rect& theRect ) const;
-
- // Returns true if intersection of this polygon with a segment or a ray not empty
- virtual bool HasIntersection( const GLViewer_Segment& theSegment ) const;
-
-private:
- GLViewer_PntList* myPoints;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Grid.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Grid.h"
-#include "GLViewer_Defs.h"
-
-#include <Precision.hxx>
-#include <qglobal.h>
-
-/*!
- Default constructor
-*/
-GLViewer_Grid::GLViewer_Grid() :
- myGridList( 0 ), myGridHeight( (GLfloat)0.0 ), myGridWidth( (GLfloat)0.0 ),
- myWinW( (GLfloat)0.0 ), myWinH( (GLfloat)0.0 ), myXSize( (GLfloat)0.0 ), myYSize( (GLfloat)0.0 ),
- myXPan( (GLfloat)0.0 ), myYPan( (GLfloat)0.0 ), myXScale( (GLfloat)1.0 ), myYScale( (GLfloat)1.0 ),
- myLineWidth( (GLfloat)0.05 ), myCenterWidth( (GLfloat)1.5 ), myCenterRadius( (GLfloat)5.0 ),
- myScaleFactor( 10 ), myIsUpdate( GL_FALSE )
-{
- myGridColor[0] = 0.5;
- myGridColor[1] = 0.5;
- myGridColor[2] = 0.5;
- myAxisColor[0] = 0.75;
- myAxisColor[1] = 0.75;
- myAxisColor[2] = 0.75;
-}
-
-/*!
- Constructor
- \param width and \param height - width and height of grid
- \param winW and \param winH - width and height of window
- \param xSize and \param ySize - steps along x and y direction
- \param xPan and \param yPan - offsets along x and y direction
- \param xScale and \param yScal - scale factors along x and y direction
-*/
-GLViewer_Grid::GLViewer_Grid( GLfloat width, GLfloat height,
- GLfloat winW, GLfloat winH,
- GLfloat xSize, GLfloat ySize,
- GLfloat xPan, GLfloat yPan,
- GLfloat xScale, GLfloat yScale ) :
- myGridList( 0 ), myGridHeight( (GLfloat)0.0 ), myGridWidth( (GLfloat)0.0 ),
- myWinW( (GLfloat)0.0 ), myWinH( (GLfloat)0.0 ), myXSize( (GLfloat)0.0 ), myYSize( (GLfloat)0.0 ),
- myXPan( (GLfloat)0.0 ), myYPan( (GLfloat)0.0 ), myXScale( (GLfloat)1.0 ), myYScale( (GLfloat)1.0 ),
- myLineWidth( (GLfloat)0.05 ), myCenterWidth( (GLfloat)1.5 ), myCenterRadius( (GLfloat)5.0 ),
- myScaleFactor( 10 ), myIsUpdate( GL_FALSE )
-{
- myGridColor[0] = 0.5;
- myGridColor[1] = 0.5;
- myGridColor[2] = 0.5;
- myAxisColor[0] = 0.75;
- myAxisColor[1] = 0.75;
- myAxisColor[2] = 0.75;
-}
-
-/*!
- Destructor
-*/
-GLViewer_Grid::~GLViewer_Grid()
-{
-}
-
-/*!
- Performs OpenGL drawing
-*/
-void GLViewer_Grid::draw()
-{
- if ( myGridList == 0 || myIsUpdate )
- initList();
-
- glCallList( myGridList );
-}
-
-/*!
- Changes color of grid
- \param r, g, b - components of color
-*/
-void GLViewer_Grid::setGridColor( GLfloat r, GLfloat g, GLfloat b )
-{
- if( myGridColor[0] == r && myGridColor[1] == g && myGridColor[2] == b )
- return;
-
- myGridColor[0] = r;
- myGridColor[1] = g;
- myGridColor[2] = b;
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- Changes color of axis
- \param r, g, b - components of color
-*/
-void GLViewer_Grid::setAxisColor( GLfloat r, GLfloat g, GLfloat b )
-{
- if( myAxisColor[0] == r && myAxisColor[1] == g && myAxisColor[2] == b )
- return;
-
- myAxisColor[0] = r;
- myAxisColor[1] = g;
- myAxisColor[2] = b;
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- Changes grid width
- \param w - new grid width
-*/
-void GLViewer_Grid::setGridWidth( float w )
-{
- if( myGridWidth == w )
- return;
-
- myGridWidth = w;
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- Sets Radius of center point( begin coords )
- \param r - new radius
-*/
-void GLViewer_Grid::setCenterRadius( int r )
-{
- if( myCenterRadius == r )
- return;
-
- myCenterRadius = r;
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- Sets grid size along X and Y axis
- \param xSize - size along X axis
- \param ySize - size along Y axis
-*/
-void GLViewer_Grid::setSize( float xSize, float ySize )
-{
- if( myXSize == xSize && myYSize == ySize )
- return;
-
- myXSize = xSize;
- myYSize = ySize;
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- Sets panning of grid
- \param xPan - panning along X axis
- \param yPan - panning along Y axis
-*/
-void GLViewer_Grid::setPan( float xPan, float yPan )
-{
- if( myXPan == xPan && myYPan == yPan )
- return;
-
- myXPan = xPan;
- myYPan = yPan;
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- Sets zoom
- \param zoom - new coefficient of zooming
-*/
-bool GLViewer_Grid::setZoom( float zoom )
-{
- if( zoom == 1.0 )
- return true;
-
- //backup values
- float bXScale = myXScale;
- float bYScale = myYScale;
-
- myXScale /= zoom;
- myYScale /= zoom;
-
- if( fabs(myXScale) < Precision::Confusion() || fabs(myYScale) < Precision::Confusion() )
- { //undo
- myXScale = bXScale;
- myYScale = bYScale;
- return false;
- }
-
- myGridWidth /= zoom;
- myGridHeight /= zoom;
- myIsUpdate = GL_TRUE;
- return true;
-}
-
-/*!
- Sets parameters of grid by zoom coefficient and window size
- \param WinW - window width
- \param WinH - window height
- \param zoom - zoom coefficient
-*/
-void GLViewer_Grid::setResize( float WinW, float WinH, float zoom )
-{
- if( myWinW == WinW && myWinH == WinH && zoom == 1.0 )
- return;
-
- myGridWidth = myGridWidth + ( WinW - myWinW ) * myXScale;
- myGridHeight = myGridHeight + ( WinH - myWinH ) * myYScale;
- myWinW = WinW;
- myWinH = WinH;
- setZoom( zoom );
- myIsUpdate = GL_TRUE;
-}
-
-/*!
- \return grid size along x and y axis
- \param xSize - for size along x axis
- \param ySize - for size along y axis
-*/
-void GLViewer_Grid::getSize( float& xSize, float& ySize ) const
-{
- xSize = myXSize;
- ySize = myYSize;
-}
-
-/*!
- \return panning along x and y axis
- \param xPan - for panning along x axis
- \param yPan - for panning along y axis
-*/
-void GLViewer_Grid::getPan( float& xPan, float& yPan ) const
-{
- xPan = myXPan;
- yPan = myYPan;
-}
-
-/*!
- \return scaling along x and y axis
- \param xScale - for scaling along x axis
- \param yScale - for scaling along y axis
-*/
-void GLViewer_Grid::getScale( float& xScale, float& yScale ) const
-{
- xScale = myXScale;
- yScale = myYScale;
-}
-
-/*!
- Initialize grid display list
-*/
-bool GLViewer_Grid::initList()
-{
- myIsUpdate = GL_FALSE;
-
- if( myXSize == (GLfloat)0.0 )
- myXSize = (GLfloat)0.1;
- if( myYSize == (GLfloat)0.0 )
- myYSize = (GLfloat)0.1;
-
-label:
- if( ( myXSize >= myGridWidth/5 ) && ( myYSize >= myGridHeight/5 ) )
- { //zoom in
- myXSize /= myScaleFactor;
- myYSize /= myScaleFactor;
- goto label;
- }
- else if( ( myXSize * myScaleFactor < myGridWidth/5 )
- || ( myYSize * myScaleFactor < myGridHeight/5 ) )
- { //zoom out
- myXSize *= myScaleFactor;
- myYSize *= myScaleFactor;
- goto label;
- }
-
- //int n = myGridWidth / myXSize;
- //int m = myGridHeight / myYSize;
- // do not initialise integer by float
- //if( ( n != 0 ) || ( m != 0 ) )
- if( ( myGridWidth > 0.5 * myXSize ) || ( myGridHeight > 0.5 * myYSize ) )
- {
- if ( myGridList != 0 )
- {
- glDeleteLists( myGridList, 1 );
- if ( glGetError() != GL_NO_ERROR )
- return FALSE;
- }
-
- float xLoc = (int)(myXPan / myXSize) * myXSize;
- float yLoc = (int)(myYPan / myYSize) * myYSize;
-
- myGridList = glGenLists( 1 );
- glNewList( myGridList, GL_COMPILE );
-
- glColor3f( myGridColor[0], myGridColor[1], myGridColor[2] );
- glLineWidth( myLineWidth );
-
- glBegin( GL_LINES );
- for( int j = 0; ( j-1 ) * myXSize <= myGridWidth / 2 ; j++ )
- {
- glVertex2d( -myXSize * j - xLoc, -myGridHeight / 2 - myYSize - yLoc );
- glVertex2d( -myXSize * j - xLoc, myGridHeight / 2 + myYSize - yLoc );
- glVertex2d( myXSize * j - xLoc, -myGridHeight / 2 - myYSize - yLoc );
- glVertex2d( myXSize * j - xLoc, myGridHeight / 2 + myYSize - yLoc );
- }
- for( int i = 0; ( i-1 ) * myYSize <= myGridHeight / 2 ; i++)
- {
- glVertex2d( -myGridWidth / 2 - myXSize - xLoc, -myYSize * i - yLoc );
- glVertex2d( myGridWidth / 2 + myXSize - xLoc, -myYSize * i - yLoc );
- glVertex2d( -myGridWidth / 2 - myXSize - xLoc, myYSize * i - yLoc );
- glVertex2d( myGridWidth / 2 + myXSize - xLoc, myYSize * i - yLoc );
- }
- glEnd();
-
- glColor3f( myAxisColor[0], myAxisColor[1], myAxisColor[2] );
- glLineWidth( myCenterWidth );
-
- glBegin( GL_LINES );
- glVertex2d( myGridWidth / 2 + myXSize - xLoc, 0);
- glVertex2d( -myGridWidth / 2 - myXSize - xLoc, 0);
- glVertex2d( 0, myGridHeight / 2 + myYSize - yLoc );
- glVertex2d( 0, -myGridHeight / 2 - myYSize - yLoc );
- glEnd();
-
- glBegin( GL_LINE_LOOP );
- double angle = 0.0;
- for ( int k = 0; k < SEGMENTS; k++ )
- {
- glVertex2f( cos(angle) * myCenterRadius * myXScale,
- sin(angle) * myCenterRadius * myYScale );
- angle += STEP;
- }
- glEnd();
-
- glEndList();
- }
- return TRUE;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Grid.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_GRID_H
-#define GLVIEWER_GRID_H
-
-#ifdef WNT
-#include "windows.h"
-#endif
-
-#include "GLViewer.h"
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*! Class GLViewer_Grid
- 2D rectangular grid for GLViewer
- Grid is adapt cells for current view
-*/
-
-class GLVIEWER_API GLViewer_Grid
-{
-public:
- //! A default constructor
- GLViewer_Grid();
- //! A constructor
- /*
- * \param width and \param height - width and height of grid
- * \param winW and \param winH - width and height of window
- * \param xSize and \param ySize - steps along x and y direction
- * \param xPan and \param yPan - offsets along x and y direction
- * \param xScale and \param yScal - scale factors along x and y direction
- */
- GLViewer_Grid( GLfloat width, GLfloat height,
- GLfloat winW, GLfloat winH,
- GLfloat xSize, GLfloat ySize,
- GLfloat xPan, GLfloat yPan,
- GLfloat xScale, GLfloat yScale );
- ~GLViewer_Grid();
-
- //! Draws grid
- void draw();
-
- //! Sets color of grid in RGB format
- void setGridColor( GLfloat r, GLfloat g, GLfloat b );
- //! Sets color of grid axes in RGB format
- void setAxisColor( GLfloat r, GLfloat g, GLfloat b );
- void setGridWidth( float );
- //! Sets Radius of center point( begin coords )
- void setCenterRadius( int );
-
- //! Sets steps along x and y directions
- void setSize( float xs, float ys );
- //! Sets offset along x and y direction
- void setPan( float xp, float yp );
- //! Sets common scale factor along x and y direction
- bool setZoom( float zoom );
- //! Recomputes grid in new size and scale of view
- void setResize( float winW, float winH, float Zoom );
-
- void getSize( float&, float& ) const;
- void getPan( float&, float& ) const;
- void getScale( float&, float& ) const;
-
- //! Sets step of scale
- void setScaleFactor( int );
- int getScaleFactor();
-
-protected:
- //! Initialize grid display list
- bool initList();
-
- GLuint myGridList;
- GLfloat myGridColor[3];
- GLfloat myAxisColor[3];
- GLfloat myGridHeight;
- GLfloat myGridWidth;
- GLfloat myWinW;
- GLfloat myWinH;
- GLfloat myXSize;
- GLfloat myYSize;
- GLfloat myXPan;
- GLfloat myYPan;
- GLfloat myXScale;
- GLfloat myYScale;
- GLfloat myLineWidth;
- GLfloat myCenterWidth;
- GLint myCenterRadius;
- GLint myScaleFactor;
- GLboolean myIsUpdate;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Group.xx
-// Created: March, 2005
-
-//#include "GLViewerAfx.h"
-#include "GLViewer_Group.h"
-#include "GLViewer_Object.h"
-
-/*!
- constructor
-*/
-GLViewer_Group::GLViewer_Group()
-{
- mySelObjNum = 0;
-}
-
-/*!
- destructor
-*/
-GLViewer_Group::~GLViewer_Group()
-{
-}
-
-/*!
- detection of empty group
-*/
-bool GLViewer_Group::isEmpty()
-{
- return myList.empty();
-}
-
-/*!
- \return number of elements
-*/
-int GLViewer_Group::count()
-{
- return myList.size();
-}
-
-/*!
- \return the position of object if group contains it, else -1
-*/
-int GLViewer_Group::contains( GLViewer_Object* theObject )
-{
- if( !theObject )
- return -1;
-
- OGIterator it = myList.begin();
- OGIterator end_it = myList.end();
- for( int i = 0; it != end_it; ++it, i++ )
- if( *it == theObject )
- return i;
-
- return -1;
-}
-
-/*!
- adding object to group
-*/
-int GLViewer_Group::addObject( GLViewer_Object* theObject )
-{
- if( theObject && contains( theObject ) == -1 )
- {
- myList.push_back( theObject );
- theObject->setGroup( this );
- }
- return count();
-}
-
-/*!
- removing object from group
-*/
-int GLViewer_Group::removeObject( GLViewer_Object* theObject )
-{
- if( theObject )
- {
- myList.remove( theObject );
- //theObject->setGroup( NULL );
- }
-
-
- if( isEmpty() )
- {
- this->~GLViewer_Group();
- return -1;
- }
- else
- return count();
-}
-
-/*!
- Dragging operation
- \param Once is true, if this operation calls only one time for all object
- \param x, y - dragging position
-*/
-void GLViewer_Group::dragingObjects( float x, float y, bool once )
-{
- if( !once )
- {
- if( !mySelObjNum )
- {
- OGIterator it = myList.begin();
- OGIterator end_it = myList.end();
- for( int i = 0; it != end_it; ++it, i++ )
- if( (*it)->isSelected() )
- mySelObjNum++;
-
- if( mySelObjNum )
- mySelObjNum--;
- }
- else
- {
- mySelObjNum--;
- return;
- }
- }
-
- OGIterator it = myList.begin();
- OGIterator end_it = myList.end();
- for( int i = 0; it != end_it; ++it, i++ )
- (*it)->moveObject( x, y, true );
-}
-
-/*!
- Updates zoom of object
- \param sender - object to be updated
- \param zoom - zoom coefficient
-*/
-void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
-{
- OGIterator it = myList.begin();
- OGIterator end_it = myList.end();
- for( int i = 0; it != end_it; ++it, i++ )
- {
- GLViewer_Object* anObject = *it;
- if( anObject != sender )
- anObject->setZoom( zoom, true, true );
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Group.h
-// Created: March, 2005
-
-#ifndef GLVIEWER_GROUP_H
-#define GLVIEWER_GROUP_H
-
-#include <list>
-#include "GLViewer.h"
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-class GLViewer_Object;
-
-typedef std::list<GLViewer_Object*> OGList;
-typedef std::list<GLViewer_Object*>::iterator OGIterator;
-
-/*! Class GLViewer_Group
-* Group of GLViewer_Objects for synchronized moving.
-* If you move one or more objects from group, than all objects from group is moved
-* If group is empty, it must be deleted
-*/
-
-class GLVIEWER_API GLViewer_Group
-{
-public:
- GLViewer_Group();
- ~GLViewer_Group();
-
- bool isEmpty();
- //! Returns number ob objects
- int count();
-
- //! Returns index of position, else -1
- int contains( GLViewer_Object* );
- int addObject( GLViewer_Object* );
- int removeObject( GLViewer_Object* );
-
- OGList getObjects() const { return myList; }
-
- //! Dragging operation
- /*! Once = true, if this operation calls only one time for all object*/
- void dragingObjects( float x, float y, bool once = false );
- //!\warning it is for ouv
- void updateZoom( GLViewer_Object* sender, float zoom );
-
-private:
- //! List of objects
- OGList myList;
- //! This number needs for synchranization group with viewport drag methods
- int mySelObjNum;
-};
-
-#endif //GLVIEWER_GROUP_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_MimeSource.h"
-#include "GLViewer_BaseObjects.h"
-
-//#include <cmath>
-//using namespace std;
-
-/*!
- Destructor
-*/
-GLViewer_MimeSource::~GLViewer_MimeSource()
-{
-}
-
-/*!
- Translate objects to byte array
- \param theObjects - list of objects
-*/
-bool GLViewer_MimeSource::setObjects( QValueList<GLViewer_Object*> theObjects )
-{
- if( !theObjects.empty() )
- {
- QStringList aObjectsType;
- QValueList<QByteArray> aObjects;
- QValueList<GLViewer_Object*>::const_iterator anIt = theObjects.begin();
- QValueList<GLViewer_Object*>::const_iterator anEndIt = theObjects.end();
-
- int aObjByteSize = 0;
- for( ; anIt != anEndIt; anIt++ )
- {
- aObjects.append( (*anIt)->getByteCopy() );
- aObjByteSize += aObjects.last().size();
- aObjectsType.append( (*anIt)->getObjectType() );
- }
-
- int anISize = sizeof( int );
- QString aTypes = aObjectsType.join("");
- int aStrByteSize = aTypes.length();
- int aObjNum = aObjects.count();
-
- myByteArray = QByteArray( anISize * (1 + 2*aObjNum) + aStrByteSize + aObjByteSize );
-
- int anIndex = 0, j = 0;
- char* aPointer = (char*)&aObjNum;
- for( anIndex = 0; anIndex < anISize; anIndex++, aPointer++ )
- myByteArray[anIndex] = *aPointer;
-
- QStringList::const_iterator aStrIt = aObjectsType.begin();
- QStringList::const_iterator aEndStrIt = aObjectsType.end();
- for( j = 1; aStrIt != aEndStrIt; aStrIt++, j++ )
- {
- int aStrLen = (*aStrIt).length();
- aPointer = (char*)&aStrLen;
- for( ; anIndex < anISize*( 1 + j ); anIndex++, aPointer++ )
- myByteArray[anIndex] = *aPointer;
- }
-
- int aCurIndex = anIndex;
- const char* aStr = aTypes.data();
-
- for( j = 0 ; anIndex < aCurIndex + aStrByteSize; aPointer++, anIndex++, j++ )
- myByteArray[anIndex] = aStr[j];
-
- aCurIndex = anIndex;
- QValueList<QByteArray>::iterator anObjIt = aObjects.begin();
- QValueList<QByteArray>::iterator anEndObjIt = aObjects.end();
- for( j = 1; anObjIt != anEndObjIt; anObjIt++, j++ )
- {
- int aObjLen = (int)((*anObjIt).size());
- aPointer = (char*)&aObjLen;
- for( ; anIndex < aCurIndex + anISize*j; anIndex++, aPointer++ )
- myByteArray[anIndex] = *aPointer;
- }
-
- aCurIndex = anIndex;
- anObjIt = aObjects.begin();
-
- for( ; anObjIt != anEndObjIt; anObjIt++ )
- {
- int aObjLen = (int)((*anObjIt).size());
- for( j = 0 ; anIndex < aCurIndex + aObjLen; anIndex++, aPointer++, j++ )
- myByteArray[anIndex] = (*anObjIt)[j];
- aCurIndex = anIndex;
- }
-
- return true;
- }
-
- return false;
-}
-
-/*!
- Creates object by it's representation (byte array)
- \param theArray - byte array
- \param theType - type of object
-*/
-GLViewer_Object* GLViewer_MimeSource::getObject( QByteArray theArray, QString theType )
-{
- if( !theArray.isEmpty() )
- {
- if( theType == "GLViewer_MarkerSet" )
- {
- GLViewer_MarkerSet* aObject = new GLViewer_MarkerSet( 0, (float)0.0, 0 );
- if( aObject->initializeFromByteCopy( theArray ) )
- return aObject;
- }
- else if ( theType == "GLViewer_Polyline" )
- {
- GLViewer_Polyline* aObject = new GLViewer_Polyline( 0, (float)0.0, 0 );
- if( aObject->initializeFromByteCopy( theArray ) )
- return aObject;
- }
- else if( theType == "GLViewer_TextObject" )
- {
- GLViewer_TextObject* aObject = new GLViewer_TextObject( 0, 0, 0, QColor(255,255,255), 0 );
- if( aObject->initializeFromByteCopy( theArray ) )
- return aObject;
- }
- }
-
- return NULL;
-}
-
-/*!
- Creates list of objects by its representation (byte array)
- \param theArray - byte array
- \param theType - type of object
-*/
-QValueList<GLViewer_Object*> GLViewer_MimeSource::getObjects( QByteArray theArray, QString theType )
-{
- if( !theArray.isEmpty() )
- {
- int anISize = sizeof( int );
- if( theType == "GLViewer_Objects" )
- {
- QStringList aTypeList;
- QValueList<QByteArray> aObjects;
- QValueList<GLViewer_Object*> aObjectList;
-
- QValueList<int> aTypeSizeList;
- QValueList<int> aObjSizeList;
- int aObjNum = 0;
- char* aPointer = (char*)&aObjNum;
-
- int anIndex = 0, j = 0;
- for( anIndex = 0; anIndex < anISize; anIndex++, aPointer++ )
- *aPointer = theArray[anIndex];
-
- for( j = 0; j < aObjNum; j++ )
- {
- int aTempVal = 0;
- aPointer = (char*)&aTempVal;
- for( ; anIndex < anISize*(j+2); anIndex++, aPointer++ )
- *aPointer = theArray[anIndex];
- aTypeSizeList.append( aTempVal );
- }
-
- int aCurIndex = anIndex;
- for( j = 0; j < aObjNum; j++ )
- {
- QString aTempStr;
- for( ; anIndex < aCurIndex + aTypeSizeList[j]; anIndex++ )
- {
- char aLetter = theArray[anIndex];
- aTempStr.append( aLetter );
- }
- aTypeList.append( aTempStr );
- aCurIndex = anIndex;
- }
-
- for( j = 0; j < aObjNum; j++ )
- {
- int aTempVal = 0;
- aPointer = (char*)&aTempVal;
- for( ; anIndex < aCurIndex + anISize*(j+1); anIndex++, aPointer++ )
- *aPointer = theArray[anIndex];
- aObjSizeList.append( aTempVal );
- }
-
- aCurIndex = anIndex;
- for( j = 0; j < aObjNum; j++ )
- {
- QByteArray aTempArray(aObjSizeList[j]);
- for( ; anIndex < aCurIndex + aObjSizeList[j]; anIndex++ )
- aTempArray[anIndex-aCurIndex] = theArray[anIndex];
- aObjects.append( aTempArray );
- aCurIndex = anIndex;
- }
-
- for( j = 0; j < aObjNum; j++ )
- aObjectList.append( getObject( aObjects[j], aTypeList[j] ) );
-
- return aObjectList;
- }
- }
-
- return QValueList<GLViewer_Object*>();
-}
-
-/*!
- \return format by index
- \param theIndex - index
-*/
-const char* GLViewer_MimeSource::format( int theIndex ) const
-{
- switch( theIndex )
- {
- case 0: return "GLViewer_Objects";
- //case 1: return "GLViewer_MarkerSet";
- //case 2: return "GLViewer_Polyline";
- //case 3: return "GLViewer_TextObject";
- default: return 0;
- }
-
-}
-
-/*!
- \return internal byte array
-*/
-QByteArray GLViewer_MimeSource::encodedData( const char* theObjectType ) const
-{
- if( theObjectType == "GLViewer_Objects" )
- return myByteArray;
-
- return QByteArray();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_MimeSource.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_MIMESOURCE_H
-#define GLVIEWER_MIMESOURCE_H
-
-#ifdef WNT
-#include <windows.h>
-#endif
-
-#include "GLViewer.h"
-
-#include <qmime.h>
-#include <qvaluelist.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-class GLViewer_Object;
-
-/*!
- \class GLViewer_MimeSource
- Needs for a work with QClipboard
-*/
-class GLVIEWER_API GLViewer_MimeSource: public QMimeSource
-{
-public:
- GLViewer_MimeSource():QMimeSource(){};
- ~GLViewer_MimeSource();
-
- //! Translate objects to byte array
- bool setObjects( QValueList<GLViewer_Object*> );
- //! Gets objects from byte array
- /*If you want to use new class, following two method must be redefined*/
- static QValueList<GLViewer_Object*> getObjects( QByteArray, QString theType);
- //! Get object from byte array
- /*If you want to use new class, following two method must be redefined*/
- static GLViewer_Object* getObject( QByteArray, QString theType);
-
- // Redefined methods
- virtual const char* format( int theIndex = 0 ) const;
- virtual QByteArray encodedData( const char* ) const;
-
-private:
- QByteArray myByteArray;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Object.h"
-#include "GLViewer_Drawer.h"
-#include "GLViewer_AspectLine.h"
-#include "GLViewer_Geom.h"
-#include "GLViewer_Text.h"
-#include "GLViewer_Group.h"
-
-//#include <cmath>
-//using namespace std;
-
-/*!
- Default constructor
-*/
-GLViewer_Object::GLViewer_Object()
-{
- myXScale = 1.0;
- myYScale = 1.0;
- myXGap = 0;
- myYGap = 0;
- myZoom = 1.0;
-
- myIsHigh = GL_FALSE;
- myIsSel = GL_FALSE;
-
- myRect = new GLViewer_Rect();;
- myUpdateRect = new GLViewer_Rect();;
- myGLText = new GLViewer_Text( 0, 0, 0, QColor(0,0,0) );
-
- myAspectLine = new GLViewer_AspectLine();
- myType = "GLViewer_Object";
-
- myOwner = NULL;
- myDrawer = NULL;
-
- myIsVisible = true;
-
- isToolTipHTML = false;
-
- myGroup = NULL;
-}
-
-/*!
- Destructor
-*/
-GLViewer_Object::~GLViewer_Object()
-{
- if( myRect )
- delete myRect;
-
- if( myUpdateRect )
- delete myUpdateRect;
-
- if( myGLText )
- delete myGLText;
-
- if( myAspectLine )
- delete myAspectLine;
-}
-
-/*!
- \return priority of object
-*/
-int GLViewer_Object::getPriority() const
-{
- return myDrawer ? myDrawer->getPriority() : 0;
-}
-
-/*!
- \return true if object is inside rectangle
- \param theRect - rectangle
-*/
-GLboolean GLViewer_Object::isInside( GLViewer_Rect theRect )
-{
- return theRect.toQRect().contains( myRect->toQRect() );
-}
-
-/*!
- Sets zoom factor
- \param zoom - zoom factor
-*/
-GLboolean GLViewer_Object::setZoom( GLfloat zoom, bool, bool )
-{
- if( myZoom == zoom )
- return GL_FALSE;
-
- myZoom = zoom;
- return GL_TRUE;
-}
-
-/*!
- Performs zoom change by step
- \param zoomIn - to increase to decrease zoom
-*/
-GLboolean GLViewer_Object::updateZoom( bool zoomIn )
-{
- float newZoom;
- float step = zoomIn ? 1 : -1;
- double epsilon = 0.001;
-
- if( myZoom - 1 > epsilon )
- newZoom = ( myZoom * 2 + step ) / 2;
- else if( 1 - myZoom > epsilon )
- newZoom = 2 / ( 2 / myZoom - step );
- else
- newZoom = zoomIn ? 3./2. : 2./3.;
-
- if( newZoom < 0.01 || newZoom > 100.0 )
- return GL_FALSE;
-
- return setZoom( newZoom, true );
-}
-
-/*!
- Codes object as byte copy
- \return byte array
-*/
-QByteArray GLViewer_Object::getByteCopy()
-{
- int i = 0;
- int anISize = sizeof( int );
-
- const char* aTypeStr = myType.data();
- const char* aToolTipStr = myToolTipText.data();
-
- int aTypeLength = myType.length();
- int aToolTipLength = myToolTipText.length();
-
-
- QByteArray aGLText = myGLText->getByteCopy();
- QByteArray aAspect = myAspectLine->getByteCopy();
-
- float aRectData[8];
- aRectData[ 0 ] = myRect->left();
- aRectData[ 1 ] = myRect->top();
- aRectData[ 2 ] = myRect->right();
- aRectData[ 3 ] = myRect->bottom();
- aRectData[ 4 ] = myXScale;
- aRectData[ 5 ] = myYScale;
- aRectData[ 6 ] = myXGap;
- aRectData[ 7 ] = myYGap;
-
- int sizeOf8Float = sizeof( aRectData );
-
- QByteArray aResult( 2*anISize + sizeOf8Float +
- aTypeLength + aToolTipLength +
- aGLText.size() + aAspect.size() );
- // puts 8 float values into the byte array
- char* aPointer = (char*)&aRectData;
- for( i = 0; i < sizeOf8Float; i++, aPointer++ )
- aResult[i] = *aPointer;
- // puts length of type string
- aPointer = (char*)&aTypeLength;
- for( ; i < anISize + sizeOf8Float; i++, aPointer++ )
- aResult[i] = *aPointer;
- // puts type string
- for( ; i < anISize + sizeOf8Float + aTypeLength; i++ )
- aResult[i] = aTypeStr[i - anISize - sizeOf8Float ];
- // puts length of tooltiptext string
- aPointer = (char*)&aToolTipLength;
- for( ; i < 2*anISize + sizeOf8Float + aTypeLength; i++, aPointer++ )
- aResult[i] = *aPointer;
- // puts tooltiptext string
- for( ; i < 2*anISize + sizeOf8Float + aTypeLength + aToolTipLength; i++ )
- aResult[ i] = aToolTipStr[i - 2*anISize - sizeOf8Float - aTypeLength];
-
- int aCurPos = 2*anISize + sizeOf8Float + aTypeLength + aToolTipLength;
- // adds aspect byte array
- for ( i = aCurPos; i < (int)( aCurPos + aAspect.size() ); i++ )
- aResult[i] = aAspect[i - aCurPos];
-
- aCurPos = aCurPos + aAspect.size();
- // adds GL text byte array
- for ( i = aCurPos; i < (int)( aCurPos + aGLText.size() ); i++ )
- aResult[i] = aGLText[i - aCurPos];
-
- aCurPos += aGLText.size();
- aPointer = (char*)&myOwner;
- for( i = 0; i < sizeof( SUIT_DataOwner* ); i++, aPointer++ )
- aResult[ aCurPos + i ] = *aPointer;
-
- return aResult;
-}
-
-/*!
- Initialize object by byte array
- \param theArray - byte array
-*/
-bool GLViewer_Object::initializeFromByteCopy( QByteArray theArray )
-{
- int i = 0;
- int anISize = sizeof( int );
- int aFSize = sizeof( GLfloat );
-
- float aLeft = 0, aTop = 0, aRight = 0, aBottom = 0;
-
- //QString aTypeStr, aToolTipStr;
- int aTypeLength = 0, aToolTipLength = 0;
-
- int aSize = theArray.size();
-
- GLViewer_Text* aGLText = new GLViewer_Text( 0, 0, 0, QColor(255,255,255));
- int aGLTextMinSize = (aGLText->getByteCopy()).size();
- GLViewer_AspectLine* aAspectLine = new GLViewer_AspectLine();
- int aGLAspLineSize = (aAspectLine->getByteCopy()).size();
-
- QByteArray aGLTextArray, aAspect( aGLAspLineSize );
-
- if( aSize < 2*anISize + 8*aFSize + aGLTextMinSize + aGLAspLineSize )
- return false;
-
- char* aPointer = (char*)&aLeft;
- for( i = 0; i < aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&aTop;
- for( ; i < 2*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&aRight;
- for( ; i < 3*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&aBottom;
- for( ; i < 4*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
-
- //myRect = new QRect( aLeft, aTop, aRight - aLeft, aBottom - aTop );
- myRect = new GLViewer_Rect( aLeft, aRight, aTop, aBottom );
-
- aPointer = (char*)&myXScale;
- for( ; i < 5*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&myYScale;
- for( ; i < 6*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&myXGap;
- for( ; i < 7*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- aPointer = (char*)&myYGap;
- for( ; i < 8*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
-
- myIsHigh = false;
- myIsSel = false;
- myIsVisible = true;
-
- aPointer = (char*)&aTypeLength;
- for( ; i < anISize + 8*aFSize; i++, aPointer++ )
- *aPointer = theArray[i];
- myType = "";
- for( ; i < anISize + 8*aFSize + aTypeLength; i++ )
- {
- QChar aChar( theArray[i] );
- myType += aChar;
- }
-
- aPointer = (char*)&aToolTipLength;
- for( ; i < 2*anISize + 8*aFSize + aTypeLength; i++, aPointer++ )
- *aPointer = theArray[i];
- myToolTipText= "";
- for( ; i < 2*anISize + 8*aFSize + aTypeLength + aToolTipLength; i++ )
- {
- QChar aChar( theArray[i] );
- myToolTipText += aChar;
- }
-
- int aCurPos = 2*anISize + 8*aFSize + aTypeLength + aToolTipLength;
- if( aSize - aCurPos < aGLTextMinSize + aGLAspLineSize )
- return false;
-
- for( i = 0; i < aGLAspLineSize; i++ )
- aAspect[i] = theArray[ aCurPos + i ];
- myAspectLine = GLViewer_AspectLine::fromByteCopy( aAspect );
-
- aCurPos = aCurPos + aGLAspLineSize;
- aGLTextArray.resize( aSize - aCurPos );
- for( i = 0; i + aCurPos < aSize; i++ )
- aGLTextArray[i] = theArray[ aCurPos + i ];
- // replace gl_text pointer by other
- if ( myGLText )
- delete myGLText;
- myGLText = GLViewer_Text::fromByteCopy( aGLTextArray );
-
- return true;
-}
-
-/*!
- Sets object's group
- \param theGroup - group
-*/
-void GLViewer_Object::setGroup( GLViewer_Group* theGroup )
-{
- if ( myGroup == theGroup )
- return;
-
- if( myGroup )
- myGroup->removeObject( this );
-
- myGroup = theGroup;
- if( theGroup )
- myGroup->addObject( this );
-}
-
-/*!
- \return object's group
-*/
-GLViewer_Group* GLViewer_Object::getGroup() const
-{
- return myGroup;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Object.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_OBJECT_H
-#define GLVIEWER_OBJECT_H
-
-#ifdef WNT
-#include <windows.h>
-#endif
-
-#include "GLViewer.h"
-#include "GLViewer_Defs.h"
-#include "GLViewer_Geom.h"
-
-#include <SUIT_DataOwner.h>
-
-#include <GL/gl.h>
-
-#include <qfile.h>
-#include <qstring.h>
-#include <qrect.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-class GLViewer_Drawer;
-class GLViewer_AspectLine;
-class GLViewer_Group;
-class GLViewer_CoordSystem;
-class GLViewer_Text;
-//class GLViewer_Owner;
-
-/*!
- * Class GLViewer_Object
- * Base Object for all GLViewer objects
- */
-class GLVIEWER_API GLViewer_Object
-{
-public:
- //! A constructor
- GLViewer_Object();
- //! A destructor
- virtual ~GLViewer_Object();
-
- //! Main method. Computes all needed information about object for presentation in drawer
- virtual void compute() = 0;
- //! Creates correspond drawer
- virtual GLViewer_Drawer* createDrawer() = 0;
-
- //! Installing already exist drawer with same type
- virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
- //! Returns current drawer
- GLViewer_Drawer* getDrawer() const { return myDrawer; }
-
- //! Computes highlight presentation
- /*!
- *\param x - x coord
- *\param y - y coord
- *\param tol - tolerance of detecting
- *\param isCircle - = true if sensitive area of detection is round
- */
- virtual GLboolean highlight( GLfloat x,
- GLfloat y,
- GLfloat tol,
- GLboolean isCircle = GL_FALSE ) = 0;
- //! Clears all highlight information
- virtual GLboolean unhighlight() = 0;
-
- //! Computes select presentation
- /*!
- *\param x - x coord
- *\param y - y coord
- *\param tol - tolerance of detecting
- *\param rect - Non empty for rectangle selection
- *\param isFull - = true if
- *\param isCircle - = true if sensitive area of detection is round
- *\param isShift - = true if selection exec with append option
- */
- virtual GLboolean select( GLfloat x,
- GLfloat y,
- GLfloat tol,
- GLViewer_Rect rect,
- GLboolean isFull = GL_FALSE,
- GLboolean isCircle = GL_FALSE,
- GLboolean isShift = GL_FALSE ) = 0;
- //! Clears all select information
- virtual GLboolean unselect() = 0;
-
- //! Returns if theRect inside object
- virtual GLboolean isInside( GLViewer_Rect theRect);
-
- //!\warning It is for ouv
- virtual bool portContains( GLViewer_Pnt ) { return false; }
- //!\warning It is for ouv
- virtual bool startPulling( GLViewer_Pnt ) { return false; }
- //!\warning It is for ouv
- virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
- //!\warning It is for ouv
- virtual void finishPulling() {}
- //!\warning It is for ouv
- virtual bool isPulling() { return false; }
- //!\warning It is for ouv
- virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
- myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
-
- //! Installs object rectangle
- virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
- //! Returns object rectungle
- virtual GLViewer_Rect* getRect() const { return myRect; }
- //! Returns update object rectangle
- /*! Does not equal getRect() if object have a persistence to some viewer transformations*/
- virtual GLViewer_Rect* getUpdateRect() = 0;
-
- //! Installs scale factors
- virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
- //! Returns scale factors
- virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
-
- //!\warning It is for ouv
- virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
- //!\warning It is for ouv
- virtual GLfloat getZoom() const { return myZoom; }
- //!\warning It is for ouv
- virtual GLboolean updateZoom( bool zoomIn );
-
- //! Returns true if object is highlighted
- virtual GLboolean isHighlighted() const { return myIsHigh; }
- //! Returns true if object is selected
- virtual GLboolean isSelected() const { return myIsSel; }
- //! Installs select status to object
- virtual void setSelected( GLboolean state ) { myIsSel = state; }
-
- //! Installs GLText to object
- void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
- //! Returns object GLText
- GLViewer_Text* getGLText() const { return myGLText; }
-
- //! Installs acpect line for object presentation
- virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
- //! Returns acpect line of object presentation
- virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
-
- //! Returns object type
- /*! Needs for GLViewer_Drawer*/
- QString getObjectType() const { return myType; }
-
- //! Installs object name
- void setName( QString name ) { myName = name; }
- //! Returns object name
- QString getName() const { return myName; }
-
- //! Returns object priority
- virtual int getPriority() const;
-
- //! Moves object per by recomputing
- /*!
- *\param dx - moving along X coord
- *\param dy - moving along Y coord
- *\param fromGroup - = true if this method called from group
- */
- virtual void moveObject( float dx, float dy, bool fromGroup = false ) = 0;
- //! Finaly recomputing object after moving
- virtual bool finishMove() { return true; }
-
- //! Returns visible object status
- virtual bool getVisible() const { return myIsVisible; }
- //! Installs visible object status
- virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
-
- //! Installs onject tool tip text
- void setToolTipText( QString str ){ myToolTipText = str; }
- //! Returns onject tool tip text
- virtual QString getToolTipText(){ return myToolTipText; }
-
- //! Returns true if tool tip contains HTML tags
- bool isTooTipHTML() const { return isToolTipHTML; }
- //! Installs tool tip supporting of HTML tags
- void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
-
- //! A function for coding object to the byte copy
- /*! A function is used for copy-past technollogy in copy method */
- virtual QByteArray getByteCopy();
- //! A function for decoding object from the byte copy
- /*! A function is used for copy-past technollogy in past method */
- virtual bool initializeFromByteCopy( QByteArray );
-
- //! A function translate object in to PostScript file on disk
- /*!
- *\param hFile the name of PostScript file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aPSCS the GLViewer_CoordSystem of PostScript page
- */
- virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
- //! A function translate object in to HPGL file on disk
- /*!
- *\param hFile the name of PostScript file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aHPGLCS the GLViewer_CoordSystem of PostScript page
- */
- virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
-
-#ifdef WIN32
- //! A function translate object in to EMF file on disk
- /*!
- *\warning WIN32 only
- *
- *\param dc the name of HDC associated with file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aEMFCS the GLViewer_CoordSystem of EMF page
- */
- virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
-#endif
- //!\warning It is for ouv
- SUIT_DataOwner* owner() const { return myOwner; }
- //!\warning It is for ouv
- void setOwner( SUIT_DataOwner* owner ) { myOwner = owner; }
-
- //! Adds object to group theGroup
- void setGroup( GLViewer_Group* theGroup );
- //! Returns object group
- GLViewer_Group* getGroup() const;
-
- //!\warning It is for ouv
- virtual GLViewer_Object* getOwner() { return this; }
-
- //! Returns true if object can be selected
- virtual bool isSelectable() { return true; }
- //!\warning It is for ouv
- virtual bool isScalable() { return true; }
-
-protected:
- //! Object name
- QString myName;
- //! Object type
- QString myType;
-
- //! Object base rect
- GLViewer_Rect* myRect;
- //! Update object rect (after some viewer transformations)
- GLViewer_Rect* myUpdateRect;
- //! Object GLText
- GLViewer_Text* myGLText;
-
- //! X scale factor
- GLfloat myXScale;
- //! Y scale factor
- GLfloat myYScale;
- //! Gap for X direction of rect
- GLfloat myXGap;
- //! Gap for Y direction of rect
- GLfloat myYGap;
-
- //!\warning It is for ouv
- GLfloat myZoom;
-
- //! Highlight status
- /*! = true after right highlighting*/
- GLboolean myIsHigh;
- //! Selectt status
- /*! = true after right selection*/
- GLboolean myIsSel;
-
- //! Object drawer
- GLViewer_Drawer* myDrawer;
- //! Line aspect for object presentation
- GLViewer_AspectLine* myAspectLine;
-
- //! Objet tool tip text
- QString myToolTipText;
- //! HTML object tool tip status
- /*! = true if tool tip text contains HTML tags */
- bool isToolTipHTML;
-
- //! Object visibke status
- bool myIsVisible;
-
- //!\warning It is for ouv
- SUIT_DataOwner* myOwner;
-
- //! Object Group
- GLViewer_Group* myGroup;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Selector.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Selector.h"
-
-#include "GLViewer_Viewer.h"
-
-int GLViewer_Selector::apppendKey = Qt::ShiftButton;
-
-/*!
- Constructor
-*/
-GLViewer_Selector::GLViewer_Selector( GLViewer_Viewer* viewer )
-: QObject( 0 ),
-myViewer( viewer ),
-myLocked( false ),
-myMinRectSize( 1, 1 )
-{
-}
-
-/*!
- Destructor
-*/
-GLViewer_Selector::~GLViewer_Selector()
-{
-}
-
-/*!
- Sets the min size of rectangle to treat it as a rectangle for multiple
- selection( sensitivity ). If a rectangle size is less than that min size,
- the right-bottom point of the rectangle will be used for single selection.
- The default min size is ( 1,1 ). [ public ]
-*/
-void GLViewer_Selector::setMinRectSize( const QSize& minSize )
-{
- myMinRectSize = minSize;
-}
-
-/*!
- Locks / unlocks the selector. If locked, nothing can be selected
- regadless of the selection mode. [ public ]
-*/
-void GLViewer_Selector::lock( bool locked )
-{
- myLocked = locked;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Selector.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_SELECTOR_H
-#define GLVIEWER_SELECTOR_H
-
-#include "GLViewer.h"
-#include "GLViewer_Defs.h"
-
-#include <qsize.h>
-#include <qobject.h>
-
-#include <Quantity_NameOfColor.hxx>
-
-class GLViewer_Viewer;
-
-/*!
- \Class GLViewer_Selector
- Base class for object selection in SUIT-based application
-*/
-class GLVIEWER_API GLViewer_Selector : public QObject
-{
- Q_OBJECT
-
-public:
- GLViewer_Selector( GLViewer_Viewer* );
- ~GLViewer_Selector();
-
-public:
- //! Sets lock status (enable/disable interavtive)
- void lock( bool );
- void setMinRectSize( const QSize& minSize );
-
- //! Highlights in point (x,y)
- virtual void detect( int x, int y ) = 0;
- virtual void undetectAll() = 0;
-
- //! Selects highlight objects
- virtual void select( bool append = false ) = 0;
- //! Selects by rect
- virtual void select( const QRect&, bool append = false ) = 0;
- virtual void unselectAll() = 0;
- virtual int numSelected() const = 0;
-
- virtual void setHilightColor( Quantity_NameOfColor ) = 0;
- virtual void setSelectColor( Quantity_NameOfColor ) = 0;
- //!Checks selection state and emits 'selSelectionDone' or 'selSelectionCancel'
- /*!Should be called by after non-interactive selection. */
- virtual void checkSelection( int, bool, int ) = 0;
-
- /*! Sets/returns the key for appending selected objects ( SHIFT by default ) */
- static int appendKey() { return apppendKey; }
- static void setAppendKey( int k ) { apppendKey = k; }
-
-signals:
- void selSelectionCancel();
- void selSelectionDone( bool append, SelectionChangeStatus status );
-
-protected:
-// void setStatus( SelectionChangeStatus theStatus ){ myStatus = theStatus; }
-// SelectionChangeStatus status( return myStatus; }
-
- GLViewer_Viewer* myViewer;
- bool myLocked;
- QSize myMinRectSize;
-
-private:
-// SelectionChangeStatus myStatus;
- static int apppendKey;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Selector2d.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Selector2d.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_Context.h"
-#include "GLViewer_ViewPort2d.h"
-
-/*!
- Constructor
-*/
-GLViewer_Selector2d::GLViewer_Selector2d( GLViewer_Viewer2d* v2d, GLViewer_Context* glc ) :
-GLViewer_Selector( v2d ),
-myGLContext( glc )
-{
-// myGLContext->SetHighlightColor( Quantity_NOC_CYAN1 );
-// myGLContext->SetSelectionColor( Quantity_NOC_RED );
-}
-
-/*!
- Destructor
-*/
-GLViewer_Selector2d::~GLViewer_Selector2d()
-{
-}
-
-/*!
- Changes hilight color of context
- \param color - new hilight color
-*/
-void GLViewer_Selector2d::setHilightColor( Quantity_NameOfColor color )
-{
- myGLContext->SetHighlightColor( color );
-}
-
-/*!
- Changes selection color of context
- \param color - new selection color
-*/
-void GLViewer_Selector2d::setSelectColor( Quantity_NameOfColor color )
-{
- myGLContext->SetSelectionColor( color );
-}
-
-/*!
- Detects object at point
- \param x, y - point co-ordinates
-*/
-void GLViewer_Selector2d::detect( int x, int y )
-{
- //cout << "GLViewer_Selector2d : detect ( " << x << " , " << y << " )" << endl;
- if ( myLocked || !myGLContext || !myViewer || !myViewer->getActiveView() ||
- myViewer->getSelectionMode() == GLViewer_Viewer::NoSelection )
- return;
-
- GLViewer_ViewPort* vp = myViewer->getActiveView()->getViewPort();
- if( !vp->inherits( "GLViewer_ViewPort2d" ) )
- return;
-
- myGLContext->MoveTo( x, y );
-}
-
-/*!
- Undetects all objects
-*/
-void GLViewer_Selector2d::undetectAll()
-{
- if ( myLocked || !myGLContext || !myViewer || !myViewer->getActiveView() ||
- myViewer->getSelectionMode() == GLViewer_Viewer::NoSelection )
- return;
-
- GLViewer_ViewPort* vp = myViewer->getActiveView()->getViewPort();
- if( !vp->inherits( "GLViewer_ViewPort2d" ) )
- return;
-
- myGLContext->clearHighlighted( true );
-}
-
-/*!
- Selects previously hilighted objects
- \param append - append objects to selection
-*/
-void GLViewer_Selector2d::select( bool append )
-{
- //cout << "GLViewer_Selector2d : select ( " << (int)append << " )" << endl;
- GLViewer_Viewer::SelectionMode selMode = myViewer->getSelectionMode();
- if ( myLocked || !myGLContext || !myViewer || !myViewer->getActiveView() ||
- selMode == GLViewer_Viewer::NoSelection )
- return;
-
- int selBefore = numSelected();
- if ( selBefore && append && selMode != GLViewer_Viewer::Multiple )
- return;
-
- GLViewer_ViewPort* vp = myViewer->getActiveView()->getViewPort();
- if( !vp->inherits( "GLViewer_ViewPort2d" ) )
- return;
-
- int status = myGLContext->Select( append );
- checkSelection( selBefore, append, status );
-}
-
-/*!
- Selects objects in rectangle
- \param selRect - selection rectangle
- \param append - append objects to selection
-*/
-void GLViewer_Selector2d::select( const QRect& selRect, bool append )
-{
- GLViewer_Viewer::SelectionMode selMode = myViewer->getSelectionMode();
- if ( myLocked || !myGLContext || !myViewer || !myViewer->getActiveView() ||
- selMode == GLViewer_Viewer::NoSelection )
- return;
-
- int selBefore = numSelected();
- if ( selBefore && append && selMode != GLViewer_Viewer::Multiple )
- return;
-
- GLViewer_ViewPort* vp = myViewer->getActiveView()->getViewPort();
- if( !vp->inherits( "GLViewer_ViewPort2d" ) )
- return;
-
- int aStatus = myGLContext->SelectByRect( selRect, append );
- checkSelection( selBefore, append, aStatus );
-}
-
-/*!
- Unselects all objects
-*/
-void GLViewer_Selector2d::unselectAll()
-{
- if ( myLocked || !myViewer )
- return;
-
-// bool updateViewer = true;
- bool hadSelection = ( numSelected() > 0 );
-
-// bool lcOpen = ( myAISContext->IndexOfCurrentLocal() != -1 );
-// lcOpen ? myAISContext->ClearSelected( updateViewer ) :
-// myAISContext->ClearCurrent( updateViewer );
- if ( hadSelection ) emit selSelectionCancel();
-}
-
-/*!
- Checks selection state and emits 'selSelectionDone' or 'selSelectionCancel'
- Should be called by after non-interactive selection.
-*/
-void GLViewer_Selector2d::checkSelection( int selBefore, bool append, int aStatus )
-{
- int selAfter = numSelected();
- if ( selBefore > 0 && selAfter < 1 )
- emit selSelectionCancel();
- else if ( selAfter > 0 )
- {
- switch( aStatus )
- {
- case SS_LocalChanged:
- emit selSelectionDone( selAfter > 1, SCS_Local );
- break;
- case SS_GlobalChanged:
- emit selSelectionDone( selAfter > 1, SCS_Global );
- break;
- }
- }
-}
-
-/*!
- \return number of selected objects
-*/
-int GLViewer_Selector2d::numSelected() const
-{
- return myGLContext->NbSelected();
-}
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Selector2d.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_SELECTOR2D_H
-#define GLVIEWER_SELECTOR2D_H
-
-#ifdef WNT
-#include "windows.h"
-#endif
-
-#include "GLViewer_Selector.h"
-
-#include <Quantity_NameOfColor.hxx>
-
-class GLViewer_Viewer2d;
-class GLViewer_Context;
-
-/*!
- \class GLViewer_Selector2d
- 2D select manager for GLViewer
-*/
-class GLVIEWER_API GLViewer_Selector2d : public GLViewer_Selector
-{
- Q_OBJECT
-
-public:
- GLViewer_Selector2d( GLViewer_Viewer2d*, GLViewer_Context* );
- ~GLViewer_Selector2d();
-
-public:
- //! Sets context from Viewer2d
- void setContext( GLViewer_Context* glc ) { myGLContext = glc; }
- GLViewer_Context* getContext() const { return myGLContext; }
-
- // Redefined methods
- virtual void setHilightColor( Quantity_NameOfColor );
- virtual void setSelectColor( Quantity_NameOfColor );
-
- virtual void detect( int, int );
- virtual void undetectAll();
-
- virtual void select( bool append = false );
- virtual void select( const QRect&, bool append = false );
- virtual void unselectAll();
- virtual int numSelected() const;
-
- virtual void checkSelection( int, bool, int );
-
-protected:
- GLViewer_Context* myGLContext;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Text.h"
-
-/*!
- Constructor
-*/
-GLViewer_Text::GLViewer_Text( const QString& text, float xPos, float yPos, const QColor& color )
-{
- myText = text;
- myXPos = xPos;
- myYPos = yPos;
- myColor = color;
- myQFont = QFont::defaultFont();
- mySeparator = 2;
- myDTF = DTF_BITMAP;
-}
-
-/*!
- Constructor
-*/
-GLViewer_Text::GLViewer_Text( const QString& text, float xPos, float yPos, const QColor& color, QFont theFont, int theSeparator )
-{
- myText = text;
- myXPos = xPos;
- myYPos = yPos;
- myColor = color;
- myQFont = theFont;
- mySeparator = theSeparator;
- myDTF = DTF_BITMAP;
-}
-
-/*!
- Destructor
-*/
-GLViewer_Text::~GLViewer_Text()
-{
-}
-
-/*!
- \return width of text
-*/
-int GLViewer_Text::getWidth()
-{
- int aResult = 0;
- QFontMetrics aFM( myQFont );
- for( uint i = 0; i < myText.length(); i++ )
- aResult += aFM.width( myText.at(i) ) + mySeparator;
- return aResult;
-}
-
-/*!
- \return height of text
-*/
-int GLViewer_Text::getHeight()
-{
- QFontMetrics aFM( myQFont );
- return aFM.height();
-}
-
-/*!
- Codes object as byte copy
- \return byte array
-*/
-QByteArray GLViewer_Text::getByteCopy() const
-{
- int i;
- int aSize = 5*sizeof( int ) + myText.length();
-
- int aR = myColor.red();
- int aG = myColor.green();
- int aB = myColor.blue();
- const char* aStr = myText.data();
-
- int anISize = sizeof( int );
- QByteArray aResult( aSize );
-
- char* aPointer = (char*)&myXPos;
- for( i = 0; i < anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&myYPos;
- for( ; i < 2*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- aPointer = (char*)&aR;
- for( ; i < 3*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aG;
- for( ; i < 4*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
- aPointer = (char*)&aB;
- for( ; i < 5*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- int aTextSize = myText.length();
- aPointer = (char*)&aTextSize;
- for( ; i < 6*anISize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- for( i = 0; i < aTextSize; i++ )
- aResult[6*anISize + i] = aStr[i];
-
- aPointer = (char*)&mySeparator;
- for( ; i < 7*anISize + aTextSize; i++, aPointer++ )
- aResult[i] = *aPointer;
-
- const char* aFontStr = myQFont.toString().data();
- int aFontSize = myQFont.toString().length();
-
- for( i = 0; i < aFontSize; i++ )
- aResult[7*anISize + aTextSize + i] = aFontStr[i];
-
- return aResult;
-}
-
-/*!
- Initialize text from binary representation
- \param theBuf - byte array
-*/
-GLViewer_Text* GLViewer_Text::fromByteCopy( QByteArray theBuf )
-{
- int i = 0;
- int aSize = (int)theBuf.size();
- int aR = 0, aG = 0, aB = 0;
-
- int xPos = 0, yPos = 0;
-
- int anISize = sizeof( int );
- char* aPointer = (char*)&xPos;
- for ( i = 0; i < anISize; i++, aPointer++ )
- *aPointer = theBuf[i];
-
- aPointer = (char*)&yPos;
- for ( ; i < 2*anISize; i++, aPointer++ )
- *aPointer = theBuf[i];
-
- aPointer = (char*)&aR;
- for( ; i < 3*anISize; i++, aPointer++ )
- *aPointer = theBuf[i];
- aPointer = (char*)&aG;
- for( ; i < 4*anISize; i++, aPointer++ )
- *aPointer = theBuf[i];
- aPointer = (char*)&aB;
- for( ; i < 5*anISize; i++, aPointer++ )
- *aPointer = theBuf[i];
-
- int aTextSize = 0;
- aPointer = (char*)&aTextSize;
- for( ; i < 6*anISize; i++, aPointer++ )
- *aPointer = theBuf[i];
-
- QString aText;
- for( ; i < 6*anISize + aTextSize; i++ )
- {
- QChar aChar( theBuf[i] );
- aText += aChar;
- }
-
- int aSeparator = 0;
- aPointer = (char*)&aSeparator;
- for( ; i < 7*anISize + aTextSize; i++, aPointer++ )
- *aPointer = theBuf[i];
-
- QString aFontStr;
- for( ; i < aSize; i++ )
- {
- QChar aChar( theBuf[i] );
- aFontStr += aChar;
- }
- QFont aFont;
-
- if( !aFont.fromString( aFontStr ) )
- return NULL;
-
- GLViewer_Text* aGlText = new GLViewer_Text( aText, xPos, yPos, QColor( aR,aG,aB ), aFont, aSeparator );
-
- return aGlText;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Text.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_TEXT_H
-#define GLVIEWER_TEXT_H
-
-#ifdef WNT
-#include <windows.h>
-#endif
-
-#include "GLViewer.h"
-#include "GLViewer_Defs.h"
-
-#include <GL/gl.h>
-
-#include <qfont.h>
-#include <qstring.h>
-#include <qcolor.h>
-#include <qfontmetrics.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_Text
- Substitution of Prs3d_Text for OpenGL
-*/
-class GLVIEWER_API GLViewer_Text
-{
-public:
- GLViewer_Text( const QString&, float xPos = 0.0, float yPos = 0.0, const QColor& color = QColor( 0, 255, 0 ) );
- GLViewer_Text( const QString&, float xPos, float yPos, const QColor& , QFont theFont, int theSeparator);
- ~GLViewer_Text();
-
- //! Sets text
- void setText( const QString& text ) { myText = text; }
- //! Returns text
- QString getText() const { return myText; }
-
- //! Sets text position
- void setPosition( float xPos, float yPos ) { myXPos = xPos; myYPos = yPos; }
- //! Returns text position
- void getPosition( float& xPos, float& yPos ) { xPos = myXPos; yPos = myYPos; }
-
- //! Sets text color
- void setColor( const QColor& color ) { myColor = color; }
- //! Returns text color
- QColor getColor() const { return myColor; }
-
- //! Sets text font
- void setFont( const QFont theQFont) { myQFont = theQFont; }
- //! Returns text font
- QFont getFont() const { return myQFont; }
-
- //! Returns text separator
- int getSeparator(){ return mySeparator; }
- //! Sets text separator
- void setSeparator( int theSep ){ mySeparator = theSep; }
-
- //! Returns text width
- int getWidth();
- //! Returns text height
- int getHeight();
-
- //! A function for coding object to the byte copy
- /*! A function is used for copy-past technollogy in copy method */
- QByteArray getByteCopy() const;
-
- //! A function for decoding object from the byte copy
- /*! A function is used for copy-past technollogy in past method */
- static GLViewer_Text* fromByteCopy( QByteArray );
-
- //! Sets text format BITMAP or TEXTURE
- DisplayTextFormat getDisplayTextFormat() const { return myDTF; }
- //! Returns text format BITMAP or TEXTURE
- void setTextDisplayFormat( DisplayTextFormat theDTF ) { myDTF = theDTF; }
-
-protected:
- QString myText;
- float myXPos;
- float myYPos;
- QColor myColor;
- QFont myQFont;
- int mySeparator;
- DisplayTextFormat myDTF;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ToolTip.xx
-// Created: March, 2005
-
-//#include "GLViewerAfx.h"
-#include "GLViewer_Context.h"
-#include "GLViewer_ToolTip.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_ViewPort2d.h"
-
-#include <qlabel.h>
-#include <qtimer.h>
-#include <qbitmap.h>
-#include <qapplication.h>
-#include <qtooltip.h>
-
-/*!
- constructor
-*/
-GLViewer_ObjectTip::GLViewer_ObjectTip( GLViewer_ViewPort2d* theParent )
-:QObject(),
- myText(),
- myPoint( -1, -1 )
-{
- mypViewPort = theParent;
- //mypLabel = NULL;
- mypLabel = new QLabel( "Test", NULL, "ObjectTipText",
- WStyle_StaysOnTop | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM );
- mypLabel->setMargin( 1 );
- mypLabel->setAutoMask( FALSE );
- mypLabel->setFrameStyle( QFrame::Plain | QFrame::Box );
- mypLabel->setLineWidth( 1 );
- mypLabel->setAlignment( AlignAuto | AlignTop );
- mypLabel->setIndent( 0 );
- mypLabel->polish();
-
- //mypLabel->setPalette( QToolTip::palette() );
-
- mypTimer = new QTimer( this );
-
- connect( mypTimer, SIGNAL( timeout() ), this, SLOT( showTip() ) );
-}
-
-/*!
- destructor
-*/
-GLViewer_ObjectTip::~GLViewer_ObjectTip()
-{
-// delete mypRect;
- if( mypLabel )
- delete mypLabel;
-
- //if( mypPoint )
- // delete mypPoint;
-
- //if( mypTimer )
- // delete mypTimer;
-}
-
-
-/*!
- It is called when there is a possibility that a tool tip should be shown
- \param p - position of tooltip
-*/
-bool GLViewer_ObjectTip::maybeTip( const QPoint &p )
-{
-
-
- GLViewer_Context* aContext = ((GLViewer_Viewer2d*)mypViewPort->getViewFrame()->getViewer())->getGLContext();
-
- /*if( !aContext->currentObjectIsChanged() )
- return false;
- else
- return true;
- if( myPoint.x() == -1 && myPoint.y() == -1 || aContext->currentObjectIsChanged())
- {
- myPoint = p;
- }
- else/if( abs(myPoint.y() - p.y()) < 16 )
- {
- return;
- }
- else // > 16
- {
- myPoint = p;
- }
-*/
- GLViewer_Object* anObj = aContext->getCurrentObject();
- if( anObj )
- {
- setText( anObj->getName() );
- return true;
- }
-
- return false;
- /*if( anObj )
- {
- //GLViewer_Rect* aRect = anObj->getRect();
- //QRect aWinRect = mypViewPort->GLV2win( *aRect );
- tip( QRect( p.x(), p.y(), 1, 1 ), anObj->getName() );
- //QFontMetrics aFM( font() );
- //showTip( aWinRect, anObj->getName(), QRect( 0, 0, aFM.width( anObj->getName() + " " ), aFM.height()*1.5 ) );
- //tip( aWinRect, anObj->getName(), aWinRect( aFM.width( anObj->getName() + " " ), aFM.height()*1.5 ) );
- }
-// else
-// clear();
-
- //tip( QRect( 0, 0, mypViewPort->getGLWidget()->width(),mypViewPort->getGLWidget()->height() ) , "test Tool tip" );
- */
-}
-
-/*!
- Custom event filter
-*/
-bool GLViewer_ObjectTip::eventFilter( QObject* theObj, QEvent* e )
-{
- hideTipAndSleep();
- switch( e->type() )
- {
- /*case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- // input - turn off tool tip mode
- hideTipAndSleep();
- break;*/
- case QEvent::MouseMove:
- {
- //hideTipAndSleep();
- /*if( mypTimer->isActive() )
- {
- mypTimer->Stop();
- wakeUp();
- }*/
- QWidget* aWidget = (QWidget*) theObj;
- if( aWidget == mypViewPort->getGLWidget() )
- {
- wakeup();
- QMouseEvent* m = (QMouseEvent *)e;
- //if( !mypPoint )
- // mypPoint = new QPoint();
-
- myPoint.setX( m->x() );
- myPoint.setY( m->y() );
- }
- }
- }
- return false;
-}
-
-/*!
- Hides tooltip and stops timer
-*/
-void GLViewer_ObjectTip::hideTipAndSleep()
-{
- //if( mypPoint )
- // delete mypPoint;
- myPoint.setX(-1);
- myPoint.setY(-1);
-
- if( mypLabel )
- {
- mypLabel->hide();
- //delete mypLabel;
- }
- mypTimer->stop();
-}
-
-/*!
- Shows tooltip
-*/
-void GLViewer_ObjectTip::showTip()
-{
- if( maybeTip( myPoint ) )
- {
-
- mypLabel->setText( myText );
- mypLabel->adjustSize( );
-
- QPoint pos = mypViewPort->getGLWidget()->mapToGlobal( myPoint );
-
- //mypLabel->show();
- int cur_height = 24;
- QCursor* aCursor = QApplication::overrideCursor();
- if( aCursor )
- {
- const QBitmap* aBitmap = aCursor->bitmap();
- if( aBitmap )
- cur_height = aBitmap->height();
- }
- mypLabel->setGeometry( pos.x(), pos.y() + cur_height, mypLabel->width(), mypLabel->height() );
- mypLabel->setPalette( QToolTip::palette() );
-
- mypLabel->show();
-
- }
-}
-
-/*!
- Restarts timer
-*/
-void GLViewer_ObjectTip::wakeup( int theTime )
-{
- if( mypTimer->isActive() )
- mypTimer->stop();
- mypTimer->start( theTime );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ToolTip.h
-// Created: March, 2005
-
-#ifndef GLVIEWER_TOOLTIP_H
-#define GLVIEWER_TOOLTIP_H
-
-#include "GLViewer.h"
-
-//#include <qtooltip.h>
-//#include <QtxToolTip.h>
-#include <qobject.h>
-
-#define TIP_TIME 1000
-
-class GLViewer_ViewPort2d;
-class QLabel;
-/*!
- \class GLViewer_ObjectTip
- ToolTip of GLViewer_Objects
-*/
-class GLVIEWER_API GLViewer_ObjectTip: public QObject//QToolTip//QtxToolTip
-{
- Q_OBJECT
-public:
- GLViewer_ObjectTip( GLViewer_ViewPort2d* );
- ~GLViewer_ObjectTip();
-
-//protected:
-// virtual void maybeTip( const QPoint& p );
- virtual bool eventFilter( QObject*, QEvent* );
-
- virtual bool maybeTip( const QPoint&);
-
- void setText( const QString& theText ){ myText = theText; }
- QString getText() const { return myText; }
-
-protected:
- void timeIsOut();
-
-private:
-
- void hideTipAndSleep();
- void wakeup( int mseconds = TIP_TIME );
-
-private slots:
- void showTip();
-
-private:
- GLViewer_ViewPort2d* mypViewPort;
-
- QTimer* mypTimer;
- QPoint myPoint;
- QLabel* mypLabel;
-
- QString myText;
-};
-
-#endif //GLVIEWER_TOOLTIP_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Tools.cxx
-// Created: April, 2005
-
-#include "GLViewer_Tools.h"
-
-#include <GL/gl.h>
-
-#include <iostream>
-
-/*!
- Constructor
- \param size - size of internal array
-*/
-GLViewer_LineList::GLViewer_LineList( int size )
-{
- myRealSize = 2*size;
- mySegmentNumber = 0;
- myMainCoord = 0.0;
-
- myArray = new double[myRealSize];
-
- if( !myArray )
- {
- std::cout << "Can't allocate memory: " << size << std::endl;
- myRealSize = 0;
- }
- else
- memset( myArray, 0, myRealSize*sizeof(double) );
-}
-
-/*!
- Destructor
-*/
-GLViewer_LineList::~GLViewer_LineList()
-{
- delete myArray;
-}
-
-/*!
- Adds new line segment to list
- \param coord1, coord2 - co-ordinates of points
-*/
-bool GLViewer_LineList::addSegment( double coord1, double coord2 )
-{
- if( coord1 > coord2 )
- {
- double temp = coord1;
- coord1 = coord2;
- coord2 = temp;
- }
-
- if( 2*mySegmentNumber == myRealSize || !myArray )
- return false;
-
- int index = 0;
- double c1, c2;
- while( index < mySegmentNumber)
- {
- readSegment( index, c1, c2 );
- if( coord1 < c1 && coord2 < c1 )
- {
- for( int i = mySegmentNumber; i > index - 1; i--)
- {
- myArray[2*i] = myArray[2*i-2]; //2*(i-1)
- myArray[2*i+1] = myArray[2*i-1];//2*(i-1)+1
- }
- myArray[0] = coord1;
- myArray[1] = coord2;
- // mySegmentNumber; what is means ?
- return true;
- }
- else if( coord1 < c1 && coord2 < c2 )
- {
- myArray[index*2] = coord1;
- return true;
- }
- else if( c1 < coord1 && coord2 < c2 )
- {
- return true;
- }
- else if( coord1 < c2 && c2 < coord2 )
- {
- if( c1 > coord1 )
- myArray[2*index] = coord1;
-
- if( index != mySegmentNumber - 1 )
- {
- for( int i = index+1; i < mySegmentNumber; i++ )
- {
- if( coord2 < myArray[2*i] )
- {
- myArray[2*index+1] = coord2;
- if( index+1 != i )
- {
- for( int j = 0; i+j < mySegmentNumber;j++ )
- {
- myArray[2*(index+1+j)] = myArray[2*(i+j)];
- myArray[2*(index+1+j)+1] = myArray[2*(i+j)+1];
- }
- for( int k = 0; k < mySegmentNumber - i; k++ )
- {
- myArray[2*(mySegmentNumber - 1- k)] = 0.0;
- myArray[2*(mySegmentNumber - 1- k)+1] = 0.0;
- }
- mySegmentNumber -= i - index-1;
- }
- return true;
- }
- else if( coord2 < myArray[2*i+1] )
- {
- myArray[2*index+1] = myArray[2*i+1];
-
- for( int j = index+1; j < mySegmentNumber-1;j++ )
- {
- myArray[2*j] = myArray[2*(i+j-index)];
- myArray[2*j+1] = myArray[2*(i+j-index)+1];
- }
- for( int k = 0; k < mySegmentNumber - i-1; k++ )
- {
- myArray[2*(mySegmentNumber - 1- k)] = 0.0;
- myArray[2*(mySegmentNumber - 1- k)+1] = 0.0;
- }
- mySegmentNumber -= i - index;
- return true;
- }
- }
- }
- else
- {
- myArray[2*index+1] = coord2;
- return true;
- }
- }
- index++;
- }
-
- myArray[mySegmentNumber*2] = coord1;
- myArray[mySegmentNumber*2+1] = coord2;
- mySegmentNumber++;
-
- return true;
-}
-
-/*!
- Gets info about segment
- \param theIndex - index of segment
- \param coord1, coord2 - co-ordinates of points
-*/
-bool GLViewer_LineList::readSegment( int theIndex, double& coord1, double& coord2 )
-{
- if( theIndex > mySegmentNumber || !myArray)
- return false;
-
- coord1 = myArray[theIndex*2];
- coord2 = myArray[theIndex*2+1];
-
- return true;
-}
-
-/*!
- \return true if line list covers point
- \param thePoint - point co-ordinate
-*/
-int GLViewer_LineList::contains( double thePoint ) const
-{
- if( !myArray || mySegmentNumber == 0 )
- return -1;
-
- for( int i = 0; i < mySegmentNumber; i++ )
- if( myArray[2*i] <= thePoint && thePoint <= myArray[2*i+1] )
- return i;
-
- return -1;
-
-}
-
-/*!
- Removes segment
- \param theIndex - segment index
-*/
-bool GLViewer_LineList::removeSegment( int theIndex )
-{
- if( theIndex > mySegmentNumber || !myArray)
- return false;
-
- for( int i = theIndex; i < mySegmentNumber; i++ )
- {
- myArray[i*2] = myArray[(i+1)*2];
- myArray[i*2+1] = myArray[(i+1)*2+1];
- }
- mySegmentNumber--;
- myArray[mySegmentNumber*2] = 0.0;
- myArray[mySegmentNumber*2+1] = 0.0;
- return true;
-}
-
-/*!
- Removes segment from line list
- \param coord1, coord2 - co-ordinates of points
-*/
-bool GLViewer_LineList::removeSegment( double coord1, double coord2 )
-{
- if( coord1 > coord2 )
- {
- double temp = coord1;
- coord1 = coord2;
- coord2 = temp;
- }
-
- if( 2*mySegmentNumber == myRealSize || !myArray )
- return false;
-
- int index = 0;
- double c1, c2;
- while( index < mySegmentNumber)
- {
- readSegment( index, c1, c2 );
- if( coord1 < c1 && coord2 < c1 )
- {
- //nothing
- return true;
- }
- else if( coord1 < c1 && coord2 < c2 )
- {
- myArray[index*2] = coord2;
- return true;
- }
- else if( c1 < coord1 && coord2 < c2 )
- {
- if( 2*mySegmentNumber == myRealSize )
- return false;
- for( int i = mySegmentNumber; i > index + 1; i-- )
- {
- myArray[2*i] = myArray[2*(i-1)];
- myArray[2*i+1] = myArray[2*(i-1)+1];
- }
- myArray[2*(index+1)+1] = myArray[2*index+1];
- myArray[2*(index+1)] = coord2;
- myArray[2*index+1] = coord1;
- mySegmentNumber++;
- return true;
- }
- else if( coord1 < c2 && c2 < coord2 )
- {
- if( c1 < coord1 )
- {
- myArray[2*index+1] = coord1;
- }
-
- if( index != mySegmentNumber - 1 )
- {
- for( int i = index+1; i < mySegmentNumber; i++ )
- {
- if( coord2 < myArray[2*i] )
- {
- if( index+1 != i )
- {
- for( int j = 1; i+j-1 < mySegmentNumber;j++ )
- {
- myArray[2*(index+j)] = myArray[2*(i+j-1)];
- myArray[2*(index+j)+1] = myArray[2*(i+j-1)+1];
- }
- for( int k = 0; k < mySegmentNumber - i; k++ )
- {
- myArray[2*(mySegmentNumber - 1- k)] = 0.0;
- myArray[2*(mySegmentNumber - 1- k)+1] = 0.0;
- }
- mySegmentNumber -= i - index -1;
- }
- else
- {
- if( !(c1 < coord1) )
- {
- for( int j = 0; index + j + 1 < mySegmentNumber;j++ )
- {
- myArray[2*(index+j)] = myArray[2*(index+j+1)];
- myArray[2*(index+j)+1] = myArray[2*(index+j+1)+1];
- }
-
- myArray[2*(mySegmentNumber - 1)] = 0.0;
- myArray[2*(mySegmentNumber - 1)+1] = 0.0;
-
- mySegmentNumber --;
- }
-
- }
-
- return true;
-
- }
- else if( coord2 < myArray[2*i+1] )
- {
- if( index+1 != i )
- {
- if( c1 < coord1 )
- index++;
-
- myArray[2*index] = coord2;
- myArray[2*index+1] = myArray[2*i+1];
-
- for( int j = 1; i+j < mySegmentNumber;j++ )
- {
- myArray[2*(index+j)] = myArray[2*(i+j)];
- myArray[2*(index+j)+1] = myArray[2*(i+j)+1];
- }
- for( int k = 0; k < mySegmentNumber - i - 1; k++ )
- {
- myArray[2*(mySegmentNumber - 1- k)] = 0.0;
- myArray[2*(mySegmentNumber - 1- k)+1] = 0.0;
- }
- mySegmentNumber -= i - index;
- }
- else
- {
- if( c1 < coord1 )
- {
- myArray[2*(index+1)] = coord2;
- return true;
- }
- else
- {
- myArray[2*(index)] = coord2;
- myArray[2*(index)+1] = myArray[2*(index+1)+1];
- for( int j = index+1; j < mySegmentNumber-1; j++ )
- {
- myArray[2*j] = myArray[2*(j+1)];
- myArray[2*j+1] = myArray[2*(j+1)+1];
- }
- mySegmentNumber--;
- myArray[2*mySegmentNumber] = 0.0;
- myArray[2*mySegmentNumber+1] = 0.0;
- }
- }
- return true;
- }
- }
- }
- else
- {
- if( !(c1 < coord1) )
- {
- mySegmentNumber--;
- myArray[2*index] = 0.0;
- myArray[2*index+1] = 0.0;
- }
- }
- }
- index++;
- }
- return true;
-}
-
-/*!
- Clears line list
-*/
-void GLViewer_LineList::clear()
-{
- if( myArray )
- memset( myArray, 0, myRealSize*sizeof(double) );
-}
-
-/*!
- Prints debug info about line list
-*/
-void GLViewer_LineList::print()
-{
- std::cout << "MainCoord: " << myMainCoord <<" SIZE: " << myRealSize << " ENum: " << mySegmentNumber << " :::";
- for( int i = 0; i < mySegmentNumber; i++ )
- std::cout << " " << myArray[2*i] << " " << myArray[2*i+1] << " | ";
-
- std::cout << std::endl;
-}
-
-/*!
- Draws line list with help of OpenGL
- \param theDim - dimension
-*/
-void GLViewer_LineList::show( FieldDim theDim )
-{
- if( !myArray )
- return;
-
- glColor3f( 1.0, 0.0, 1.0 );
- if( theDim == FD_X )
- {
- glBegin( GL_LINES );
- for( int i = 0; i < mySegmentNumber; i++ )
- {
- glVertex2d( myArray[2*i], myMainCoord );
- glVertex2d( myArray[2*i+1], myMainCoord );
- }
- glEnd();
- }
- else if( theDim == FD_Y )
- {
- glBegin( GL_LINES );
- for( int i = 0; i < mySegmentNumber; i++ )
- {
- glVertex2d( myMainCoord, myArray[2*i] );
- glVertex2d( myMainCoord, myArray[2*i+1] );
- }
- glEnd();
- }
-}
-
-
-/*!
- Constructor
-*/
-GLViewer_LineField::GLViewer_LineField()
-{
- myCurArrayIndex = 0;
- myGraphArray1 = NULL;
- myGraphArray2 = NULL;
-
- myCurCount = 0;
-
- myXSize = 0;
- myYSize = 0;
- myXLineArray = NULL;
- myYLineArray = NULL;
-}
-
-/*!
- Constructor
-*/
-GLViewer_LineField::GLViewer_LineField( const int theMAXSize, const int theXN, const int theYN )
-{
- myCurArrayIndex = 0;
- myGraphArray1 = NULL;
- myGraphArray2 = NULL;
-
- myCurCount = 0;
-
- if( theXN <= 0 || theYN <= 0 )
- {
- myXSize = 0;
- myYSize = 0;
- myXLineArray = NULL;
- myYLineArray = NULL;
- }
- else
- {
- myXLineArray = new GLViewer_LineList*[theXN];
- myYLineArray = new GLViewer_LineList*[theYN];
-
- for( int i = 0; i < theXN; i++ )
- myXLineArray[i] = new GLViewer_LineList( theMAXSize );
-
- for( int j = 0; j < theYN; j++ )
- myYLineArray[j] = new GLViewer_LineList( theMAXSize );
-
- myXSize = theXN;
- myYSize = theYN;
- }
-}
-
-/*!
- Destructor
-*/
-GLViewer_LineField::~GLViewer_LineField()
-{
- if( myXLineArray )
- {
- for( int i = 0; i < myXSize; i++ )
- delete myXLineArray[i];
-
- delete myXLineArray;
- }
-
- if( myYLineArray )
- {
- for( int j = 0; j < myYSize; j++ )
- delete myYLineArray[j];
-
- delete myYLineArray;
- }
-
- if( myGraphArray1 )
- delete myGraphArray1;
-
- if( myGraphArray2 )
- delete myGraphArray2;
-}
-
-/*!
- Adds line
-*/
-void GLViewer_LineField::addLine( FieldDim theDim, GLViewer_LineList* )
-{
- //not implemented
-}
-
-/*!
- Adds line
- \param theDim - dimension
- \param theMC - main co-ordinate
- \param theBegin - start co-ordinate
- \param theEnd - end co-ordinate
-*/
-void GLViewer_LineField:: addLine( FieldDim theDim, double theMC, double theBegin, double theEnd )
-{
- GLViewer_LineList* aLL = new GLViewer_LineList( 1 );
- aLL->addSegment( theBegin, theEnd );
- aLL->setMainCoord( theMC );
- addLine( theDim, aLL );
-}
-
-/*!
- Adds line
- \param theDim - dimension
- \param theLL - main co-ordinate
- \param thePosition - index in list
-*/
-int GLViewer_LineField::insertLine( FieldDim theDim, GLViewer_LineList* theLL, int thePosition )
-{
- if( !myXLineArray || !myYLineArray )
- return -1;
-
- GLViewer_LineList** anArray = getLLArray( theDim );
- if( !anArray )
- return -1;
-
- int size = getDimSize( theDim );
-
- if( thePosition >= size )
- return -1;
- else if( thePosition < 0 )
- {
- if( anArray[size-1]->count() != 0 ) // no more space
- return -1;
-
- for( int i = 0; i < size; i++ )
- {
- if( anArray[i]->count() == 0 )
- {
- delete anArray[i];
- anArray[i] = theLL;
- return i;
- }
-
- double cur_mc = anArray[i]->mainCoord();
- if( theLL->mainCoord() < cur_mc )
- {
- for( int j = 0; j+i+1 < size; j++ )
- {
- delete anArray[size-j-1];
- anArray[size-j-1] = anArray[size-j-2];
- }
- delete anArray[i];
- anArray[i] = theLL;
- return i;
- }
- }
- }
- else
- {
- delete anArray[thePosition];
- anArray[thePosition] = theLL;
- return thePosition;
- }
-
- return -1;
-}
-
-/*!
- Adds line
- \param theDim - dimension
- \param theMainCoord - main co-ordinate
- \param theBegin - start co-ordinate
- \param theEnd - end co-ordinate
- \param thePosition - index in list
-*/
-int GLViewer_LineField::insertLine( FieldDim theDim, double theMainCoord, double theBegin, double theEnd, int thePosition )
-{
- GLViewer_LineList* aLL = new GLViewer_LineList( 1 );
- aLL->addSegment( theBegin, theEnd );
- aLL->setMainCoord( theMainCoord );
- return insertLine( theDim, aLL, thePosition );
-}
-
-/*!
- \return other dimension
-*/
-FieldDim GLViewer_LineField::invertDim( FieldDim theFD )
-{
- if( theFD == FD_X )
- return FD_Y;
- else
- return FD_X;
-}
-
-/*!
- \return line list
- \param theIndex - index in list
- \param tehFD - dimension
-*/
-GLViewer_LineList* GLViewer_LineField::getLine( int theIndex, FieldDim theFD )
-{
- if( !myXLineArray || !myYLineArray )
- return NULL;
-
- if( theFD == FD_X )
- {
- if( theIndex > myXSize )
- return NULL;
-
- return myXLineArray[theIndex];
- }
- else if( theFD == FD_Y )
- {
- if( theIndex > myYSize )
- return NULL;
-
- return myYLineArray[theIndex];
- }
-
- return NULL;
-}
-
-/*!
- Sets borders of field
- \param X1, X2 - minimal and maximal abscisses
- \param Y1, Y2 - minimal and maximal ordinates
-*/
-void GLViewer_LineField::setBorders( double X1, double X2, double Y1, double Y2 )
-{
- if( !myXLineArray || !myYLineArray )
- return;
-
- for( int i = 0; i < myXSize; i++ )
- {
- myXLineArray[i]->clear();
- myXLineArray[i]->addSegment( X1, X2 );
- myXLineArray[i]->setMainCoord( Y1 + (Y2-Y1)*(double(i)/(myXSize-1)) );
- }
-
- for( int j = 0; j < myYSize; j++ )
- {
- myYLineArray[j]->clear();
- myYLineArray[j]->addSegment( Y1, Y2 );
- myYLineArray[j]->setMainCoord( X1 + (X2-X1)*(double(j)/(myYSize-1)) );
- }
-}
-
-/*!
- Adds rectangle
- \param top, right - a corner of rectangle
- \param bottom, left - other corner of rectangle
-*/
-void GLViewer_LineField::addRectangle( double top, double right, double bottom, double left )
-{
- if( !myXLineArray || !myYLineArray )
- return;
- for( int i = 0; i < myXSize; i++ )
- {
- double mainCoord = myXLineArray[i]->mainCoord();
- if( mainCoord < top && mainCoord > bottom )
- myXLineArray[i]->removeSegment( left, right );
- }
-
- for( int j = 0; j < myYSize; j++ )
- {
- double mainCoord = myYLineArray[j]->mainCoord();
- if( mainCoord < right && mainCoord > left )
- myYLineArray[j]->removeSegment( bottom, top );
- }
-}
-
-/*!
- Prints debug info about line field
-*/
-void GLViewer_LineField::print()
-{
- std::cout << "My X matrix Number: " << myXSize << std::endl;
- for( int i = 0; i < myXSize; i++ )
- myXLineArray[i]->print();
-
- std::cout << "My Y matrix Number: " << myYSize << std::endl;
- for( int j = 0; j < myYSize; j++ )
- myYLineArray[j]->print();
-}
-
-/*!
- Draws field with help of OpenGL
-*/
-void GLViewer_LineField::show()
-{
- for( int i = 0; i < myXSize; i++ )
- getLine( i, FD_X )->show( FD_X );
-
- for( int j = 0; j < myYSize; j++ )
- getLine( j, FD_Y )->show( FD_Y );
- int count = 0;
- double* anArray = solution( count );
- glColor3f( 1.0, 0.0, 0.0 );
- glBegin( GL_LINES );
- for( int k = 0; k < count; k++ )
- {
- glVertex2d( anArray[4*k], anArray[4*k+1] );
- glVertex2d( anArray[4*k+2], anArray[4*k+3] );
- }
- glEnd();
- delete[] anArray;
- std::cout << "Show function" << std::endl;
-}
-
-/*!
- \return size
- \param theDim - dimension
-*/
-int GLViewer_LineField::getDimSize( FieldDim theDim )
-{
- if( theDim == FD_X )
- return myXSize;
- else if( theDim == FD_Y )
- return myYSize;
-
- return -1;
-}
-
-/*!
- \return array of intersected indexes
- \param theDim - dimension
- \param theIndex - index
- \param theLL - line with that intersection is checked
- \param theSize - to return value of array size
-*/
-int* GLViewer_LineField::intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL, int& theSize )
-{
- theSize = 0;
- if( !myXLineArray || !myYLineArray )
- return NULL;
-
- int aDimSize = getDimSize( theDim );
- int* anArray = new int[aDimSize*2 ];
-
- for( int i = 0; i < aDimSize; i++ )
- {
- GLViewer_LineList* aLL = getLine( i, theDim );
- int index = aLL->contains( theLL->mainCoord() );
- if( index != -1 && theLL->contains( aLL->mainCoord() ) == theIndex )
- {
- anArray[theSize*2] = i;
- anArray[theSize*2+1] = index;
- theSize++;
- }
- }
-
- return anArray;
-}
-
-/*!
- Sets start/end search point
- \param thePoint - type of point (start: FP_Start; end: FP_End )
- \param theX, theY - point co-ordinates
-*/
-bool GLViewer_LineField::setPoint( FieldPoint thePoint, double theX, double theY )
-{
- if( !myXLineArray || !myYLineArray )
- return false;
-
- int i = -1, j = -1;
- int xSeg = -1, ySeg = -1;
- for( i = 0; i < myXSize; i++ )
- {
- GLViewer_LineList* aLL = getLine( i, FD_X );
- if( aLL->mainCoord() == theY )
- {
- xSeg = aLL->contains( theX );
- break;
- }
- }
-
- for( j = 0; j < myYSize; j++ )
- {
- GLViewer_LineList* aLL = getLine( j, FD_Y );
- if( aLL->mainCoord() == theX )
- {
- ySeg = aLL->contains( theY );
- break;
- }
- }
-
- if( xSeg != -1 && ySeg != -1 )
- {
- if( thePoint == FP_Start )
- {
- myStartPoint.myXLineIndex = i;
- myStartPoint.myXSegmentIndex = xSeg;
- myStartPoint.myYLineIndex = j;
- myStartPoint.myYSegmentIndex = ySeg;
- myStartPoint.mySolveIndex = -1;
- }
- else
- {
- myEndPoint.myXLineIndex = i;
- myEndPoint.myXSegmentIndex = xSeg;
- myEndPoint.myYLineIndex = j;
- myEndPoint.myYSegmentIndex = ySeg;
- myEndPoint.mySolveIndex = -1;
- }
- return true;
- }
- else
- return false;
-}
-
-/*!
- \return number of segments
-*/
-int GLViewer_LineField::segmentNumber()
-{
- if( !(myXLineArray || myYLineArray) )
- return -1;
-
- int aNumber = 0;
- for( int aDim = 0; aDim < 2; aDim++ )
- for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
- aNumber += getLine( i, (FieldDim)aDim )->count();
-
- return aNumber;
-}
-
-/*!
- Removes all multiple segments
-*/
-void GLViewer_LineField::optimize()
-{
- if( !myXLineArray || !myYLineArray )
- return;
-
- for( int aDim = 0; aDim < 2; aDim++ )
- {
- for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
- {
- GLViewer_LineList* aLL = getLine( i, (FieldDim)aDim );
- for( int k =0, aSegNum = aLL->count(); k < aSegNum; k++ )
- {
- // int index = i; unused
- double a1, a2;
- aLL->readSegment( k, a1, a2 );
- for( int l = i+1, m = getDimSize( (FieldDim)aDim ); l < m; l++ )
- {
- int end = -1;
- GLViewer_LineList* aCurLL = getLine( l, (FieldDim)aDim );
- for( int j = 0, count = aCurLL->count(); j < count; j++ )
- {
- double c1, c2;
- aCurLL->readSegment( j, c1, c2 );
- if( a1 == c1 && a2 == c2 )
- {
- if( !(aDim == 0 && myStartPoint.myXLineIndex == l && myStartPoint.myXSegmentIndex == j) &&
- !(aDim == 0 && myEndPoint.myXLineIndex == l && myEndPoint.myXSegmentIndex == j) &&
- !(aDim == 1 && myStartPoint.myYLineIndex == l && myStartPoint.myYSegmentIndex == j) &&
- !(aDim == 1 && myEndPoint.myYLineIndex == l && myEndPoint.myYSegmentIndex == j) )
- aCurLL->removeSegment( j );
- end = 0;
- break;
- }
- if( a1 < c1 )
- {
- end = 1;
- break;
- }
- }
- if( end == -1 || end == 1)
- break;
- }
- }
- }
- }
-}
-
-/*!
- Some prepare actions
- Needs call setPoint before
-*/
-void GLViewer_LineField::initialize()
-{
- if( !myXLineArray || !myYLineArray )
- return;
-
- int size = segmentNumber();
-
- myCurArrayIndex = 0;
- myCurCount = 0;
-
- myGraphArray1 = new GraphNode[size];
- myGraphArray2 = new GraphNode[size];
-
- int index = 0;
- bool isXSet = false,
- isYSet = false;
- for( int aDim = 0; aDim < 2; aDim++ )
- {
- for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
- {
- GLViewer_LineList* aLL = getLine( i, (FieldDim)aDim );
- for( int k =0, aSegNum = aLL->count(); k < aSegNum; k++ )
- {
- myGraphArray1[index].myCount = size;
- myGraphArray1[index].myDim = (FieldDim)aDim;
- myGraphArray1[index].myLineIndex = i;
- myGraphArray1[index].mySegmentindex = k;
- myGraphArray1[index].prevNodeIndex = -1;
-
- myGraphArray2[index].myCount = size;
- myGraphArray2[index].myDim = (FieldDim)aDim;
- myGraphArray2[index].myLineIndex = i;
- myGraphArray2[index].mySegmentindex = k;
- myGraphArray2[index].prevNodeIndex = -1;
-
- if( !isXSet && aDim == FD_X && myStartPoint.myXLineIndex == i && myStartPoint.myXSegmentIndex == k )
- {
- myGraphArray1[index].myCount = 0;
- isXSet = true;
- }
-
- if( aDim == FD_Y && !isYSet && myStartPoint.myYLineIndex == i && myStartPoint.myYSegmentIndex == k )
- {
- myGraphArray1[index].myCount = 0;
- isYSet = true;
- }
-
- index++;
- }
- }
- }
-}
-
-/*!
- One iteration of algorithm
-*/
-void GLViewer_LineField::iteration()
-{
- int aParam = myCurCount;
- myCurCount++;
-
- int* aNodes = findByCount( aParam );
- GraphNode* aCurArray = getCurArray();
-
- for( int i = 0; i < aParam; i++ )
- {
- GraphNode aCurNode = aCurArray[aNodes[i]];
- int aSize = 0;
- int* aInterNodes = intersectIndexes( invertDim( aCurNode.myDim ), aCurNode.mySegmentindex,
- getLine( aCurNode.myLineIndex, aCurNode.myDim ), aSize );
- for( int j = 0; j < aSize; j++ )
- {
- int index = findBySegment( invertDim( aCurNode.myDim ), aInterNodes[2*j], aInterNodes[2*j+1], false );
- if( index != -1 )
- if( aCurArray[index].myCount > myCurCount )
- {
- aCurArray[index].myCount = myCurCount;
- aCurArray[index].prevNodeIndex = aNodes[i];
- }
- }
-
- delete[] aInterNodes;
- }
-
- delete[] aNodes;
-}
-
-/*!
- Checks for complete status
-*/
-GLViewer_LineField::IterationStatus GLViewer_LineField::checkComplete()
-{
- if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
- return IS_ERROR;
-
- int count = 0;
- GraphNode* aCurArray = getCurArray(),
- * aSecArray = getSecArray();
-
- for( int i = 0, n = segmentNumber(); i < n; i++ )
- {
- if( aCurArray[i].myCount != aSecArray[i].myCount )
- {
- if( aCurArray[i].myDim == FD_X &&
- aCurArray[i].myLineIndex == myEndPoint.myXLineIndex &&
- aCurArray[i].mySegmentindex == myEndPoint.myXSegmentIndex )
- {
- std::cout << "Algorithm complete X!!!!!!!" << std::endl;
- myEndPoint.mySolveIndex = i;
- return IS_SOLVED;
- }
- else if( aCurArray[i].myDim == FD_Y &&
- aCurArray[i].myLineIndex == myEndPoint.myYLineIndex &&
- aCurArray[i].mySegmentindex == myEndPoint.myYSegmentIndex )
- {
- std::cout << "Algorithm complete Y!!!!!!!" << std::endl;
- myEndPoint.mySolveIndex = i;
- return IS_SOLVED;
- }
- else
- {
- count++;
- aSecArray[i].myCount = aCurArray[i].myCount;
- aSecArray[i].prevNodeIndex = aCurArray[i].prevNodeIndex;
- }
- }
- }
-
- if( myCurArrayIndex == 0)
- myCurArrayIndex = 1;
- else
- myCurArrayIndex = 0;
-
- std::cout << "Number of ways: " << count << std::endl;
- if( count == 0 )
- return IS_LOOP;
-
- return IS_NOT_SOLVED;
-}
-
-/*!
- Finds LineList by counts and returns indexes
-*/
-int* GLViewer_LineField::findByCount( int& theParam )
-{
- if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
- return NULL;
-
- int count = segmentNumber();
- int* anArray = new int[count];
- int aSize = 0;
-
- GraphNode* aCurArray = getCurArray();
- for( int i = 0; i < count; i++ )
- {
- GraphNode aCurNode = aCurArray[i];
- if( aCurNode.myCount == theParam )
- {
- anArray[aSize] = i;
- aSize++;
- }
- }
-
- theParam = aSize;
- return anArray;
-}
-
-/*!
- Finds LineList by segment and dimension
-*/
-int GLViewer_LineField::findBySegment( FieldDim theDim, int theLineIndex, int theSegment, bool inCurArray )
-{
- if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 || getDimSize( theDim ) <= theLineIndex )
- return -1;
-
- GraphNode* aCurArray;
- if( inCurArray )
- aCurArray = getCurArray();
- else
- aCurArray = getSecArray();
-
- for( int i = 0, n = segmentNumber(); i < n; i++ )
- {
- GraphNode aCurNode = aCurArray[i];
- if( aCurNode.myDim == theDim && aCurNode.myLineIndex == theLineIndex && aCurNode.mySegmentindex == theSegment )
- return i;
- }
-
- return -1;
-}
-
-/*!
- Main method, performs algorithm execution
-*/
-GLViewer_LineField::EndStatus GLViewer_LineField::startAlgorithm()
-{
- if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
- return ES_ERROR;
-
- while( true )
- {
- std::cout << "-----------Iteration #" << myCurCount << "-------------" << std::endl;
- iteration();
-
- IterationStatus is = checkComplete();
- if( is == IS_ERROR )
- return ES_ERROR;
- else if( is == IS_LOOP )
- return ES_LOOP;
- else if( is == IS_SOLVED )
- return ES_SOLVED;
- }
- return ES_SOLVED;
-}
-
-/*!
- \return solution and size of solution
-*/
-double* GLViewer_LineField::solution( int& theSize )
-{
- if( !myXLineArray || !myYLineArray || !myGraphArray1 || !myGraphArray2 )
- return NULL;
-
- if( myEndPoint.mySolveIndex == -1 )
- return NULL;
-
- theSize = myCurCount+1;
- double* anArray = new double[theSize*4];
-
- GraphNode* aCurArray = getCurArray();
-
- int index = myEndPoint.mySolveIndex;
- for( int i = 0; i <= myCurCount; i++ )
- {
- if( index == -1 )
- break;
- double c1, c2;
- GLViewer_LineList* aLL = getLine( aCurArray[index].myLineIndex, aCurArray[index].myDim );
- aLL->readSegment( aCurArray[index].mySegmentindex, c1, c2 );
-
- if( aCurArray[index].myDim == FD_X )
- {
- anArray[i*4] = c1;
- anArray[i*4+1] = aLL->mainCoord();
- anArray[i*4+2] = c2;
- anArray[i*4+3] = aLL->mainCoord();
- }
- else
- {
- anArray[i*4] = aLL->mainCoord();
- anArray[i*4+1] = c1;
- anArray[i*4+2] = aLL->mainCoord();
- anArray[i*4+3] = c2;
- }
-
- index = aCurArray[index].prevNodeIndex;
- }
-
- return anArray;
-}
-
-/*!
- \return current solution array
-*/
-GraphNode* GLViewer_LineField::getCurArray()
-{
- if( !myGraphArray1 || !myGraphArray2 )
- return NULL;
-
- if( myCurArrayIndex == 0)
- return myGraphArray1;
- else
- return myGraphArray2;
-}
-
-/*!
- \return other solution array
-*/
-GraphNode* GLViewer_LineField::getSecArray()
-{
- if( !myGraphArray1 || !myGraphArray2 )
- return NULL;
-
- if( myCurArrayIndex == 0)
- return myGraphArray2;
- else
- return myGraphArray1;
-}
-
-/*!
- \return maximum segment number
-*/
-int GLViewer_LineField::maxSegmentNum()
-{
- if( !myXLineArray || !myYLineArray )
- return -1;
-
- int max_num = -1;
- for( int aDim = 0; aDim < 2; aDim++ )
- {
- for( int i = 0, n = getDimSize( (FieldDim)aDim ); i < n; i++ )
- {
- int count = getLine( i, (FieldDim)aDim )->count();
- if( count > max_num )
- max_num = count;
- }
- }
-
- return max_num;
-}
-
-/*!
- \return list of LileList by dimension
- \param theDim - dimension
-*/
-GLViewer_LineList** GLViewer_LineField::getLLArray( FieldDim theDim )
-{
- if( theDim == FD_X )
- return myXLineArray;
- else if( theDim == FD_Y )
- return myYLineArray;
- else
- return NULL;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Tools.h
-// Created: April, 2005
-
-#ifndef GLVIEWER_TOOLS_H
-#define GLVIEWER_TOOLS_H
-
-#ifdef WNT
-#include "windows.h"
-#endif
-
-#include "GLViewer.h"
-#include "GLViewer_Defs.h"
-
-class GLViewer_LineField;
-
-/*!
- \class GLViewer_Tools
- Tools for Viewer
-*/
-class GLVIEWER_API GLViewer_Tools
-{
-public:
- //GLViewer_Tools();
- //virtual ~GLViewer_Tools();
- //static
-
-};
-
-//! Dimension of line
-enum FieldDim
-{
- FD_X = 0, /*along x axis*/
- FD_Y /*along y axis*/
-};
-
-/*!
- \class GLViewer_LineList
- Tools for distinct line
- This class implmented interface for segment operations:
- add, cut, remove and etc.
- Memory does not changed and allocated only one time
-*/
-class GLViewer_LineList
-{
-public:
- GLViewer_LineList( int );
- virtual ~GLViewer_LineList();
-
- //! Returns number of segments
- int count() const { return mySegmentNumber; }
- //! Returns real size
- int size() const { return myRealSize; }
-
- bool addSegment( double coord1, double coord2 );
- bool removeSegment( int index );
- bool removeSegment( double coord1, double coord2 );
-
- bool readSegment( int index, double& coord1, double& coord2 );
-
- //! Returns index of segment, else -1
- int contains( double thePoint ) const;
-
- //! Sets level of segments
- void setMainCoord( double theVal ) { myMainCoord = theVal; }
- double mainCoord() const { return myMainCoord; }
-
- void clear();
- void print();
-
- void show( FieldDim );
-
- GLViewer_LineList& operator = ( GLViewer_LineList );
-
-private:
- double* myArray;
- int myRealSize;
- int mySegmentNumber;
-
- double myMainCoord;
-};
-
-/*! struct GraphNode describe node in algorithm on rare grid*/
-struct GraphNode
-{
- int myCount;
- FieldDim myDim;
- int myLineIndex;
- int mySegmentindex;
- int prevNodeIndex; //feedback for searching for solution
-};
-
-/*! struct SearchPoint describe node for solving algorithm*/
-struct SearchPoint
-{
- int myXLineIndex;
- int myXSegmentIndex;
- int myYLineIndex;
- int myYSegmentIndex;
- int mySolveIndex;
-};
-
-/*!
- \class GLViewer_LineField
- Tools for solving algorithm of finding shortest path on rare grid with minimum of
- line turns number
-*/
-class GLViewer_LineField
-{
-public:
- //!Searched point
- enum FieldPoint
- {
- FP_Start = 0,
- FP_End = 1
- };
-
- //! Status of interation
- enum IterationStatus
- {
- IS_ERROR = 0,
- IS_LOOP,
- IS_NOT_SOLVED,
- IS_SOLVED
- };
-
- //! Final status of solving
- enum EndStatus
- {
- ES_ERROR = 0,
- ES_LOOP,
- ES_SOLVED
- };
-
- GLViewer_LineField();
- GLViewer_LineField( const int theMAXSize, const int xn, const int yn );
- virtual ~GLViewer_LineField();
-
- //! Adds new line
- /*!best way, if line is already sorted*/
- void addLine( FieldDim, GLViewer_LineList* );
- //! Calls previous
- void addLine( FieldDim theDim, double theMC, double theBegin, double theEnd );
-
- //! Adds new line and sorted field
- /*! Returns position*/
- int insertLine( FieldDim theDim, GLViewer_LineList*, int thePosition );
- //! Calls previous
- int insertLine( FieldDim theDim, double theMC, double theBegin, double theEnd, int thePosition );
-
- //! Returns other dimension
- static FieldDim invertDim( FieldDim );
-
- //! Returns line by index and dimension
- GLViewer_LineList* getLine( int index, FieldDim );
-
- //! Nullifys field and sets same continued segments
- void setBorders( double X1, double X2, double Y1, double Y2 );
- //! Cut rectangle in grid
- void addRectangle( double top, double right, double bottom, double left );
-
- //! returns arrey of intersects indexes with \param theLL
- int* intersectIndexes( FieldDim theDim, int theIndex, const GLViewer_LineList* theLL , int& theSize );
-
- void print();
-
- void show();
-
- int getDimSize( FieldDim );
- //! Returns number of segment
- int segmentNumber();
-
- //! Sets start/end search point
- bool setPoint( FieldPoint, double x, double y );
-
- //! Optimize field
- /*! Removes all multiple segments*/
- void optimize();
- //! Some prepare actions
- /*! Needs call setPoint before*/
- void initialize();
- //! Main method
- EndStatus startAlgorithm();
-
- //! Returns solution and size of solution
- double* solution( int& size );
-
-protected:
- //! One iteration of algorithm
- void iteration();
- //! Checks for complete status
- IterationStatus checkComplete();
-
- //! Finds LineList by counts and returns indexes
- int* findByCount( int& theParam );
- //! Finds LineList by segment and dimension
- int findBySegment( FieldDim, int coord1, int coord2, bool inCurArray = true );
-
- //! Returns current solution array
- GraphNode* getCurArray();
- //! Returns
- GraphNode* getSecArray();
-
- //! Returns maximum segment number
- int maxSegmentNum();
-
- //! Returns list of LileList by dimension
- GLViewer_LineList** getLLArray( FieldDim );
-
-private:
- GLViewer_LineList** myXLineArray,
- ** myYLineArray;
-
- int myXSize,
- myYSize;
-
- GraphNode* myGraphArray1,
- * myGraphArray2;
- int myCurArrayIndex;
-
- SearchPoint myStartPoint,
- myEndPoint;
- int myCurCount;
-};
-
-#endif //GLVIEWER_TOOLS_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewFrame.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_ViewFrame.h"
-#include "GLViewer_Viewer.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_ViewPort2d.h"
-
-#include <SUIT_Desktop.h>
-#include <SUIT_Session.h>
-#include <SUIT_ToolButton.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_MessageBox.h>
-
-#include <qcolor.h>
-#include <qfiledialog.h>
-#include <qimage.h>
-#include <qlayout.h>
-#include <qstring.h>
-
-/*!
- Constructor
-*/
-GLViewer_ViewFrame::GLViewer_ViewFrame( SUIT_Desktop* d, GLViewer_Viewer* vw )
-: SUIT_ViewWindow( d ),
-myViewer( vw ),
-myVP( 0 )
-{
- QFrame* client = new QFrame( this );
- setCentralWidget( client );
-
- QBoxLayout* layout = new QHBoxLayout( client, 1, 1 );
- layout->setAutoAdd( true );
-
- GLViewer_ViewPort2d* vp = new GLViewer_ViewPort2d( client, this );
- //vp->turnGrid( true );
- //vp->turnCompass( true );
- //vp->enablePopup( false );
- setViewPort( vp );
- setBackgroundColor( Qt::white );
-
- myToolBar = new QToolBar(this);
- myToolBar->setCloseMode(QDockWindow::Undocked);
- myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
- createActions();
- createToolBar();
-}
-
-/*!
- Destructor
-*/
-GLViewer_ViewFrame::~GLViewer_ViewFrame()
-{
-}
-
-/*!
- Creates actions of GL view frame
-*/
-void GLViewer_ViewFrame::createActions()
-{
- if (!myActionsMap.isEmpty()) return;
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QAction* aAction;
-
- // Dump view
- aAction = new QAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
- tr( "MNU_DUMP_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump()));
- myActionsMap[ DumpId ] = aAction;
-
- // FitAll
- aAction = new QAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ),
- tr( "MNU_FITALL" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITALL"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitAll()));
- myActionsMap[ FitAllId ] = aAction;
-
- // FitRect
- aAction = new QAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ),
- tr( "MNU_FITRECT" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITRECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitArea()));
- myActionsMap[ FitRectId ] = aAction;
-
- // FitSelect
- aAction = new QAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ),
- tr( "MNU_FITSELECT" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITSELECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitSelect()));
- myActionsMap[ FitSelectId ] = aAction;
-
- // Zoom
- aAction = new QAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ),
- tr( "MNU_ZOOM_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewZoom()));
- myActionsMap[ ZoomId ] = aAction;
-
- // Panning
- aAction = new QAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ),
- tr( "MNU_PAN_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
- myActionsMap[ PanId ] = aAction;
-
- // Global Panning
- aAction = new QAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ),
- tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewGlobalPan()));
- myActionsMap[ GlobalPanId ] = aAction;
-
- aAction = new QAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ),
- tr( "MNU_RESET_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_RESET_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
- myActionsMap[ ResetId ] = aAction;
-}
-
-/*!
- Creates toolbar of GL view frame
-*/
-void GLViewer_ViewFrame::createToolBar()
-{
- myActionsMap[DumpId]->addTo(myToolBar);
-
- SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
- aScaleBtn->AddAction(myActionsMap[FitAllId]);
- aScaleBtn->AddAction(myActionsMap[FitRectId]);
- aScaleBtn->AddAction(myActionsMap[FitSelectId]);
- aScaleBtn->AddAction(myActionsMap[ZoomId]);
-
- SUIT_ToolButton* aPanBtn = new SUIT_ToolButton(myToolBar);
- aPanBtn->AddAction(myActionsMap[PanId]);
- aPanBtn->AddAction(myActionsMap[GlobalPanId]);
-
- myActionsMap[ResetId]->addTo(myToolBar);
-}
-
-/*!
- Sets the viewport for this frame
-*/
-void GLViewer_ViewFrame::setViewPort( GLViewer_ViewPort* vp )
-{
- if ( myVP == vp )
- return;
-
- if ( myVP )
- {
- disconnect( myVP, SIGNAL( vpDrawExternal( QPainter* ) ), this, SIGNAL( vfDrawExternal( QPainter* ) ) );
- disconnect( myVP, SIGNAL( vpMouseEvent( QMouseEvent* ) ), this, SLOT( mouseEvent( QMouseEvent* ) ) );
- disconnect( myVP, SIGNAL( vpKeyEvent( QKeyEvent* ) ), this, SLOT( keyEvent( QKeyEvent* ) ) );
- disconnect( myVP, SIGNAL( vpWheelEvent( QWheelEvent* ) ), this, SLOT( wheelEvent( QWheelEvent* ) ) );
- disconnect( myVP, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ),
- this, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ) );
- }
- myVP = vp;
- if ( myVP )
- {
- connect( myVP, SIGNAL( vpDrawExternal( QPainter* ) ), this, SIGNAL( vfDrawExternal( QPainter* ) ) );
- connect( myVP, SIGNAL( vpMouseEvent( QMouseEvent* ) ), this, SLOT( mouseEvent( QMouseEvent* ) ) );
- connect( myVP, SIGNAL( vpKeyEvent( QKeyEvent* ) ), this, SLOT( keyEvent( QKeyEvent* ) ) );
- connect( myVP, SIGNAL( vpWheelEvent( QWheelEvent* ) ), this, SLOT( wheelEvent( QWheelEvent* ) ) );
- connect( myVP, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ),
- this, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ) );
- }
-}
-
-/*!
- Returns the viewport of this frame. [ public ]
-*/
-GLViewer_ViewPort* GLViewer_ViewFrame::getViewPort() const
-{
- return myVP;
-}
-
-/*!
- Set background of the viewport. [ public ]
-*/
-void GLViewer_ViewFrame::setBackgroundColor( const QColor& color )
-{
- if ( myVP )
- myVP->setBackgroundColor( color );
-}
-
-/*!
- Returns background of the viewport. [ public ]
-*/
-QColor GLViewer_ViewFrame::backgroundColor() const
-{
- if ( myVP )
- return myVP->backgroundColor();
- return QMainWindow::backgroundColor();
-}
-
-/*!
- Sets the viewer for this view. [ public ]
-*/
-void GLViewer_ViewFrame::setViewer( GLViewer_Viewer* v )
-{
- myViewer = v;
-}
-
-/*!
- Returns the viewer of this view. [ public ]
-*/
-GLViewer_Viewer* GLViewer_ViewFrame::getViewer() const
-{
- return myViewer;
-}
-
-/*!
- Returns the preferred view size. [ virtual public ]
-*/
-QSize GLViewer_ViewFrame::sizeHint() const
-{
- QWidget* p = parentWidget();
- if ( p && p->inherits( "QWorkspaceChild" ) )
- p = p->parentWidget();
- if ( !p )
- return QMainWindow::sizeHint();
- return QSize( 9 * p->width() / 10 , 9 * p->height() / 10 );
-}
-
-/*!
- Called by viewer's 'update()' method. Does nothing by default [ virtual public ]
-*/
-void GLViewer_ViewFrame::onUpdate( int )
-{
-}
-
-//#include <windows.h>
-
-/*!
- SLOT: called on dump view operation is activated, stores scene to raster file
-*/
-void GLViewer_ViewFrame::onViewDump()
-{
- GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
- int width, height;
- width = aWidget->width();
- height = aWidget->height();
-
- int imageSize = width*height*3;
- unsigned char* imageBits = NULL;
-
- int reserve_bytes = width % 4; //32 bits platform
- imageSize = (width+reserve_bytes)*height*3;
- imageBits = new unsigned char[imageSize];
-
-
-#ifdef WNT
-
- int num;
- HBITMAP hBmp;
- HDC hdc_old, hdc;
- HGLRC hglrc_old, hglrc;
-
- BITMAPINFO bi;
-
- hglrc_old = wglGetCurrentContext();
- hdc_old = wglGetCurrentDC();
-
- hdc = CreateCompatibleDC( hdc_old );
- if( !hdc )
- {
- cout << "Can't create compatible DC. Last Error Code: " << GetLastError() << endl;
- return;
- }
-
- int sizeBmi = Standard_Integer( sizeof(BITMAPINFO) + sizeof(RGBQUAD)*3 );
- PBITMAPINFO pBmi = (PBITMAPINFO)( new char[sizeBmi] );
- ZeroMemory( pBmi, sizeBmi );
-
- pBmi->bmiHeader.biSize = sizeof( BITMAPINFOHEADER ); //sizeBmi
- pBmi->bmiHeader.biWidth = width;
- pBmi->bmiHeader.biHeight = height;
- pBmi->bmiHeader.biPlanes = 1;
- pBmi->bmiHeader.biBitCount = 24;
- pBmi->bmiHeader.biCompression = BI_RGB;
-
- LPVOID ppvBits;
- hBmp = CreateDIBSection ( hdc, pBmi, DIB_RGB_COLORS, &ppvBits, NULL, 0 );
- SelectObject ( hdc, hBmp );
- delete[] pBmi;
-
- PIXELFORMATDESCRIPTOR pfd;
- ZeroMemory( &pfd, sizeof( PIXELFORMATDESCRIPTOR ) );
- pfd.nSize = sizeof( PIXELFORMATDESCRIPTOR );
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
- pfd.cDepthBits = 32;
- pfd.iLayerType = PFD_MAIN_PLANE;
-
- int iPf = ChoosePixelFormat( hdc, &pfd);
- if( iPf == 0 )
- {
- if ( !DescribePixelFormat ( hdc, iPf, sizeof(PIXELFORMATDESCRIPTOR), &pfd ) )
- {
- cout << "Can't describe Pixel Format. Last Error Code: " << GetLastError() << endl;
- }
- }
- if ( !SetPixelFormat(hdc, iPf, &pfd) )
- {
- cout << "Can't set Pixel Format. Last Error Code: " << GetLastError() << endl;
- }
-
- hglrc = wglCreateContext( hdc );
- if( !hglrc )
- {
- cout << "Can't create new GL Context. Last Error Code: " << GetLastError() << endl;
- return;
- }
- if( !wglMakeCurrent( hdc, hglrc) )
- {
- cout << "Can't make current new context!" << endl;
- return;
- }
-
- glViewport( 0, 0, width, height );
-
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- GLfloat w_c = width / 2., h_c = height / 2.;
-
- gluOrtho2D( -w_c, w_c, -h_c, h_c );
-
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-
- //set background
- QColor aColor = ((GLViewer_ViewPort2d*)myVP)->backgroundColor();
- glClearColor( ( GLfloat )aColor.red() / 255,
- ( GLfloat )aColor.green() / 255,
- ( GLfloat )aColor.blue() / 255,
- 1.0 );
-
- aWidget->exportRepaint();
-
- memset(&bi, 0, sizeof(BITMAPINFOHEADER));
- bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bi.bmiHeader.biPlanes = 1;
- bi.bmiHeader.biBitCount = 24;
- bi.bmiHeader.biHeight = -height;
- bi.bmiHeader.biWidth = width;
- bi.bmiHeader.biCompression = BI_RGB;
-
- num = GetDIBits(hdc, hBmp, 0, height, imageBits, &bi, DIB_RGB_COLORS);
-
- wglMakeCurrent( hdc_old, hglrc_old );
- wglDeleteContext( hglrc );
-
-
-#else //XWindows
-#endif
-
- unsigned int* aPix = NULL;
- QImage anImage( width, height, 32 );
- for( int i = 0; i < height; i++ )
- {
- memset( anImage.scanLine( i ), 0, sizeof(unsigned int)*width );
- unsigned char* pos;
- for( int j = 0; j < width; j++ )
- {
- pos = imageBits + i*width*3 + j*3 + reserve_bytes*i;
- aPix = (unsigned int*)anImage.scanLine(i)+j;
- *aPix = qRgb( *pos, *(pos+1), *(pos+2) );
- }
- }
-
- delete [] imageBits;
-
- QString aFilter( "*.bmp\n*.png" );
-
- QFileDialog aFileDlg( QDir::current().absPath(), aFilter, this );
- aFileDlg.setCaption( tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ) );
- aFileDlg.setMode( QFileDialog::AnyFile );
-
- if( !aFileDlg.exec() )
- return;
-
- QString aFileName = aFileDlg.selectedFile();
- QString aFileExt = aFileDlg.selectedFilter();
-
- if( aFileName.isEmpty() )
- {
- SUIT_MessageBox::error1( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
- tr( "BUT_OK" ) );
- }
-
- QString aSaveOp = "BMP";
- QString aTypedFileExt = QFileInfo( aFileName ).extension( false ).lower();
-
- if( aFileExt == "*.bmp" )
- {
- if( aTypedFileExt.isEmpty() )
- aFileName += ".bmp";
- aSaveOp = "BMP";
- }
- else if( aFileExt == "*.png" )
- if( aTypedFileExt.isEmpty() )
- aFileName += ".png";
- aSaveOp = "PNG";
-
-//#ifdef WNT
-// if( !anImage.save( aFileName, aSaveOp ) )
-//#else
- if( !aWidget->grabFrameBuffer().save( aFileName, aSaveOp ) )
-//#endif
- {
- SUIT_MessageBox::error1( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
- tr( "BUT_OK" ) );
- }
-}
-
-/*!
- Start panning
-*/
-void GLViewer_ViewFrame::onViewPan()
-{
- myViewer->activateTransform( GLViewer_Viewer::Pan );
-}
-
-/*!
- Start zooming
-*/
-void GLViewer_ViewFrame::onViewZoom()
-{
- myViewer->activateTransform( GLViewer_Viewer::Zoom );
-}
-
-/*!
- Start fit all
-*/
-void GLViewer_ViewFrame::onViewFitAll()
-{
- myViewer->activateTransform( GLViewer_Viewer::FitAll );
-}
-
-/*!
- Start fit area
-*/
-void GLViewer_ViewFrame::onViewFitArea()
-{
- myViewer->activateTransform( GLViewer_Viewer::FitRect );
-}
-
-/*!
- Start fit selected
-*/
-void GLViewer_ViewFrame::onViewFitSelect()
-{
- myViewer->activateTransform( GLViewer_Viewer::FitSelect );
-}
-
-/*!
- Start global panning
-*/
-void GLViewer_ViewFrame::onViewGlobalPan()
-{
- myViewer->activateTransform( GLViewer_Viewer::PanGlobal );
-}
-
-/*!
- Start rotating
-*/
-void GLViewer_ViewFrame::onViewRotate()
-{
- //myViewer->activateTransform( GLViewer_Viewer::Rotate );
-}
-
-/*!
- Start reset default view aspects
-*/
-void GLViewer_ViewFrame::onViewReset()
-{
- myViewer->activateTransform( GLViewer_Viewer::Reset );
-}
-
-/*!
- Dispatches mouse events
-*/
-void GLViewer_ViewFrame::mouseEvent( QMouseEvent* e )
-{
- switch ( e->type() )
- {
- case QEvent::MouseButtonPress:
- emit mousePressed( this, e );
- break;
- case QEvent::MouseButtonRelease:
- emit mouseReleased( this, e );
- break;
- case QEvent::MouseButtonDblClick:
- emit mouseDoubleClicked( this, e );
- break;
- case QEvent::MouseMove:
- emit mouseMoving( this, e );
- break;
- default:
- break;
- }
-}
-
-/*!
- Dispatches key events
-*/
-void GLViewer_ViewFrame::keyEvent( QKeyEvent* e )
-{
- switch ( e->type() )
- {
- case QEvent::KeyPress:
- emit keyPressed( this, e );
- break;
- case QEvent::KeyRelease:
- emit keyReleased( this, e );
- break;
- default:
- break;
- }
-}
-
-/*!
- Dispatches wheel events
-*/
-void GLViewer_ViewFrame::wheelEvent( QWheelEvent* e )
-{
- switch ( e->type() )
- {
- case QEvent::Wheel:
- emit wheeling( this, e );
- break;
- default:
- break;
- }
-}
-
-/*!
- \return the visual parameters of this view as a formated string
-*/
-QString GLViewer_ViewFrame::getVisualParameters()
-{
- QString retStr;
- if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) ) {
- GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP;
- GLfloat xSc, ySc, xPan, yPan;
- vp2d->getScale( xSc, ySc );
- vp2d->getPan( xPan, yPan );
- retStr.sprintf( "%.12e*%.12e*%.12e*%.12e", xSc, ySc, xPan, yPan );
- }
- return retStr;
-}
-
-/*!
- The method restores visual parameters of this view from a formated string
-*/
-void GLViewer_ViewFrame::setVisualParameters( const QString& parameters )
-{
- QStringList paramsLst = QStringList::split( '*', parameters, true );
- if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 4) {
- GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP;
-
- GLfloat xSc, ySc, xPan, yPan;
- xSc = paramsLst[0].toDouble();
- ySc = paramsLst[1].toDouble();
- xPan = paramsLst[2].toDouble();
- yPan = paramsLst[3].toDouble();
-
- vp2d->getGLWidget()->setScale( xSc, ySc, 1. );
- vp2d->getGLWidget()->setPan( xPan, yPan, 0. );
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewFrame.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_VIEWFRAME_H
-#define GLVIEWER_VIEWFRAME_H
-
-#include "SUIT_ViewWindow.h"
-#include "GLViewer.h"
-
-class QColor;
-
-class SUIT_Desktop;
-
-class GLViewer_Viewer;
-class GLViewer_ViewPort;
-
-#include <qaction.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_ViewFrame
- Frame window for viewport in QAD-based application
-*/
-
-class GLVIEWER_API GLViewer_ViewFrame: public SUIT_ViewWindow
-{
- Q_OBJECT
-
-public:
- GLViewer_ViewFrame( SUIT_Desktop* , GLViewer_Viewer* );
- ~GLViewer_ViewFrame();
-
-public:
- void setViewer( GLViewer_Viewer* );
- GLViewer_Viewer* getViewer() const;
-
- void setViewPort( GLViewer_ViewPort* );
- GLViewer_ViewPort* getViewPort() const;
-
- void setBackgroundColor( const QColor& );
- QColor backgroundColor() const;
-
- QSize sizeHint() const;
-
- virtual void onUpdate( int );
-
- virtual QString getVisualParameters();
- virtual void setVisualParameters( const QString& parameters );
-
-signals:
- void vfDrawExternal( QPainter* );
- void vfViewClosing( QCloseEvent* );
-
-protected:
- GLViewer_Viewer* myViewer;
- GLViewer_ViewPort* myVP;
-
-public:
- //ViewType getTypeView() const { return VIEW_GL; };
- QWidget* getViewWidget() { return ( QWidget* )getViewPort(); };
-
-protected slots:
- void onViewDump();
- void onViewPan();
- void onViewZoom();
- void onViewFitAll();
- void onViewFitArea();
- void onViewFitSelect();
- void onViewGlobalPan();
- void onViewRotate();
- void onViewReset();
- void onViewFront() {};
- void onViewBack() {};
- void onViewRight() {};
- void onViewLeft() {};
- void onViewBottom() {};
- void onViewTop() {};
- void onViewTrihedron() {};
-
-private slots:
- void keyEvent( QKeyEvent* );
- void mouseEvent( QMouseEvent* );
- void wheelEvent( QWheelEvent* );
-
-private:
- void createActions();
- void createToolBar();
-
-private:
- //! Actions ID
- enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId };
- typedef QMap<int, QAction*> ActionsMap;
-
-private:
- ActionsMap myActionsMap;
- QToolBar* myToolBar;
-};
-
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewManager.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_ViewManager.h"
-#include "GLViewer_ViewFrame.h"
-#include "GLViewer_Viewer2d.h"
-#include "SUIT_Desktop.h"
-
-/*!Constructor.*/
-GLViewer_ViewManager::GLViewer_ViewManager( SUIT_Study* theStudy, SUIT_Desktop* theDesktop )
-: SUIT_ViewManager( theStudy, theDesktop, new GLViewer_Viewer2d( "GLViewer" ) )
-{
- setTitle( tr( "GL_VIEW_TITLE" ) );
-}
-
-/*!Destructor.*/
-GLViewer_ViewManager::~GLViewer_ViewManager()
-{
-}
-
-/*!Context menu popup for \a popup.*/
-void GLViewer_ViewManager::contextMenuPopup( QPopupMenu* popup )
-{
- SUIT_ViewManager::contextMenuPopup( popup );
- // if it is necessary invoke method CreatePopup of ViewPort
- // be sure that existing QPopupMenu menu is used for that.
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewManager.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_VIEWMANAGER_H
-#define GLVIEWER_VIEWMANAGER_H
-
-#include "GLViewer.h"
-#include "SUIT_ViewManager.h"
-#include "GLViewer_Viewer.h"
-
-class SUIT_Desktop;
-
-class GLVIEWER_API GLViewer_ViewManager : public SUIT_ViewManager
-{
- Q_OBJECT
-public:
- GLViewer_ViewManager( SUIT_Study* theStudy, SUIT_Desktop* theDesktop );
- virtual ~GLViewer_ViewManager();
-
- GLViewer_Viewer* getGLViewer() { return (GLViewer_Viewer*) myViewModel; }
-
- virtual void contextMenuPopup( QPopupMenu* );
-};
-
-#endif // GLVIEWER_VIEWMANAGER_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewPort.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-
-#if !(defined WNT) && !(defined QT_CLEAN_NAMESPACE)
-#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */
-#endif
-
-#include "GLViewer_ViewPort.h"
-
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_Session.h"
-
-#include <qrect.h>
-#include <qcursor.h>
-#include <qpixmap.h>
-#include <qpainter.h>
-#include <qintdict.h>
-#include <qpopupmenu.h>
-#include <qcolordialog.h>
-
-#include <stdlib.h>
-
-#if !defined WNT
-#include <GL/glx.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-#include <X11/Xmu/StdCmap.h>
-#undef QT_CLEAN_NAMESPACE
-#include <Xw_Window.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
-
-/*!
- \struct CMapEntry
- Map of indexed colors
- For internal purposes
-*/
-struct CMapEntry
-{
- CMapEntry();
- ~CMapEntry();
- Colormap cmap;
- bool alloc;
- XStandardColormap scmap;
-};
-
-/*!
- Constructor
-*/
-CMapEntry::CMapEntry()
-{
- cmap = 0;
- alloc = false;
- scmap.colormap = 0;
-}
-
-/*!
- Destructor
-*/
-CMapEntry::~CMapEntry()
-{
- if ( alloc )
- XFreeColormap( QPaintDevice::x11AppDisplay(), cmap );
-}
-
-static QIntDict<CMapEntry> *cmap_dict = 0;
-static bool mesa_gl = false;
-
-static void cleanup_cmaps()
-{
- if ( !cmap_dict )
- return;
- cmap_dict->setAutoDelete( true );
- delete cmap_dict;
- cmap_dict = 0;
-}
-
-static Colormap choose_cmap( Display *dpy, XVisualInfo *vi )
-{
- if ( !cmap_dict )
- {
- cmap_dict = new QIntDict<CMapEntry>;
- const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION );
- mesa_gl = strstr( v,"Mesa" ) != 0;
- qAddPostRoutine( cleanup_cmaps );
- }
-
- CMapEntry *x = cmap_dict->find( (long)vi->visualid );
- if ( x ) // found colormap for visual
- return x->cmap;
-
- x = new CMapEntry();
-
- XStandardColormap *c;
- int n, i;
-
-#ifdef DEBUG
- cout << "Choosing cmap for vID = " << vi->visualid << endl;
-#endif
-
- if ( vi->visualid == XVisualIDFromVisual( (Visual*)QPaintDevice::x11AppVisual() ) )
- {
-#ifdef DEBUG
- cout << "Using x11AppColormap" << endl;
-#endif
- return QPaintDevice::x11AppColormap();
- }
-
- if ( mesa_gl )
- {
- Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true );
- if ( hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8 )
- {
- if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, hp_cmaps ) )
- {
- i = 0;
- while ( i < n && x->cmap == 0 )
- {
- if ( c[i].visualid == vi->visual->visualid )
- {
- x->cmap = c[i].colormap;
- x->scmap = c[i];
- }
- i++;
- }
- XFree( (char*)c );
- }
- }
- }
-#if !defined( _OS_SOLARIS_ )
- if ( !x->cmap )
- {
- if ( XmuLookupStandardColormap( dpy, vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP, false, true ) )
- {
- if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, XA_RGB_DEFAULT_MAP ) )
- {
- i = 0;
- while ( i < n && x->cmap == 0 )
- {
- if ( c[i].visualid == vi->visualid )
- {
- x->cmap = c[i].colormap;
- x->scmap = c[i];
- }
- i++;
- }
- XFree( (char *)c );
- }
- }
- }
-#endif
- if ( !x->cmap )
- {
- // no shared cmap found
- x->cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone );
- x->alloc = true;
- }
-
- cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid
- return x->cmap;
-}
-#endif
-
-int GLViewer_ViewPort::nCounter = 0;
-QCursor* GLViewer_ViewPort::defCursor = 0;
-QCursor* GLViewer_ViewPort::panglCursor = 0;
-QCursor* GLViewer_ViewPort::handCursor = 0;
-QCursor* GLViewer_ViewPort::panCursor = 0;
-QCursor* GLViewer_ViewPort::zoomCursor = 0;
-QCursor* GLViewer_ViewPort::rotCursor = 0;
-QCursor* GLViewer_ViewPort::sketchCursor = 0;
-
-/*!
- Creates the necessary viewport cursors. [ static ]
-*/
-void GLViewer_ViewPort::createCursors ()
-{
- defCursor = new QCursor( ArrowCursor );
- panglCursor = new QCursor( CrossCursor );
- handCursor = new QCursor( PointingHandCursor );
- panCursor = new QCursor( SizeAllCursor );
-
- SUIT_ResourceMgr* rmgr = SUIT_Session::session()->resourceMgr();
- zoomCursor = new QCursor( rmgr->loadPixmap( "GLViewer", tr( "ICON_GL_CURSOR_ZOOM" ) ) );
- rotCursor = new QCursor( rmgr->loadPixmap( "GLViewer", tr( "ICON_GL_CURSOR_ROTATE" ) ) );
- sketchCursor = new QCursor( rmgr->loadPixmap( "GLViewer", tr( "ICON_GL_CURSOR_SKETCH" ) ) );
-}
-
-/*!
- Destroys the viewport cursors. [ static ]
-*/
-void GLViewer_ViewPort::destroyCursors()
-{
- delete defCursor; defCursor = 0;
- delete panglCursor; panglCursor = 0;
- delete handCursor; handCursor = 0;
- delete panCursor; panCursor = 0;
- delete zoomCursor; zoomCursor = 0;
- delete rotCursor; rotCursor = 0;
- delete sketchCursor; sketchCursor = 0;
-}
-
-/*!
- Sets new default cursor. [ static ]
-*/
-void GLViewer_ViewPort::setDefaultCursor( const QCursor& newCursor )
-{
- if ( !defCursor )
- defCursor = new QCursor();
- *defCursor = newCursor;
-}
-
-/*!
- Sets new cursor for drawing rectangle in the viewport. [ static ]
-*/
-void GLViewer_ViewPort::setHandCursor( const QCursor& newCursor )
-{
- if ( !handCursor )
- handCursor = new QCursor();
- *handCursor = newCursor;
-}
-
-/*!
- Sets new cursor for panning. [ static ]
-*/
-void GLViewer_ViewPort::setPanCursor( const QCursor& newCursor )
-{
- if ( !panCursor )
- panCursor = new QCursor();
- *panCursor = newCursor;
-}
-
-/*!
- Sets new cursor for global panning. [ static ]
-*/
-void GLViewer_ViewPort::setPanglCursor( const QCursor& newCursor )
-{
- if ( !panglCursor )
- panglCursor = new QCursor();
- *panglCursor = newCursor;
-}
-
-/*!
- Sets new cursor for zooming. [ static ]
-*/
-void GLViewer_ViewPort::setZoomCursor( const QCursor& newCursor )
-{
- if ( !zoomCursor )
- zoomCursor = new QCursor();
- *zoomCursor = newCursor;
-}
-
-/*!
- Sets new cursor for rotating. [ static ]
-*/
-void GLViewer_ViewPort::setRotCursor( const QCursor& newCursor )
-{
- if ( !rotCursor )
- rotCursor = new QCursor();
- *rotCursor = newCursor;
-}
-
-/*!
- Sets new cursor for rotating. [ static ]
-*/
-void GLViewer_ViewPort::setSketchCursor( const QCursor& newCursor )
-{
- if ( !rotCursor )
- sketchCursor = new QCursor();
- *sketchCursor = newCursor;
-}
-
-/*!
- Constructor
-*/
-GLViewer_ViewPort::GLViewer_ViewPort( QWidget* parent )
-: QWidget( parent, 0, WRepaintNoErase | WResizeNoErase )
-{
- initialize();
-}
-
-/*!
- Destructor
-*/
-GLViewer_ViewPort::~GLViewer_ViewPort()
-{
- cleanup();
-}
-
-/*!
- Initializes viewport. [ private ]
-*/
-void GLViewer_ViewPort::initialize()
-{
- if ( nCounter++ == 0 )
- createCursors();
-
- //myPopupActions.setAutoDelete( true );
- myPaintersRedrawing = false;
- myEnableSketching = false;
- myEnableTransform = true;
-
- setMouseTracking( true );
- setBackgroundMode( NoBackground );
-
- setFocusPolicy( StrongFocus );
-}
-
-/*!
- Cleans up the viewport. [ private ]
-*/
-void GLViewer_ViewPort::cleanup()
-{
- if ( --nCounter == 0 )
- destroyCursors();
-}
-
-/*!
- Selects visual ID for OpenGL window ( X11 specific ). [ protected ]
-*/
-void GLViewer_ViewPort::selectVisualId( ViewType type )
-{
-#if !defined WNT
- XVisualInfo* pVisualInfo;
- if ( x11Display() )
- {
- /* Initialization with the default VisualID */
- //Visual *v = DefaultVisual( x11Display(), DefaultScreen( x11Display() ) );
- // int visualID = XVisualIDFromVisual( v ); unused
-
- /* Here we use the settings from Optimizer_ViewInfo::TxglCreateWindow() */
- int visualAttr[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None };
-
- pVisualInfo = ::glXChooseVisual( x11Display(), DefaultScreen( x11Display() ), visualAttr );
-
- if ( isVisible() )
- hide();
-
- XSetWindowAttributes a;
-
- a.colormap = choose_cmap( x11Display(), pVisualInfo ); /* find best colormap */
- a.background_pixel = backgroundColor().pixel();
- a.border_pixel = black.pixel();
- Window p = RootWindow( x11Display(), DefaultScreen( x11Display() ) );
- if ( parentWidget() )
- p = parentWidget()->winId();
-
- Window w;
- if ( type == Type2D ) // creating simple X window for 2d
- {
- unsigned long xbackground =
- BlackPixel( x11Display(), DefaultScreen( x11Display() ) );
- unsigned long xforeground =
- WhitePixel( x11Display(), DefaultScreen( x11Display() ) );
-
- w = XCreateSimpleWindow ( x11Display(), p, x(), y(), width(),
- height(), 0, xforeground, xbackground );
- }
- else if ( type == Type3D )
- {
- w = XCreateWindow( x11Display(), p, x(), y(), width(), height(),
- 0, pVisualInfo->depth, InputOutput, pVisualInfo->visual,
- CWBackPixel | CWBorderPixel | CWColormap, &a );
- }
- else
- return;
-
- Window *cmw;
- Window *cmwret;
- int count;
- if ( XGetWMColormapWindows( x11Display(), topLevelWidget()->winId(), &cmwret, &count ) )
- {
- cmw = new Window[count+1];
- memcpy( (char*)cmw, (char*)cmwret, sizeof(Window) * count );
- XFree( (char*)cmwret );
- int i;
-
- for ( i = 0; i < count; i++ )
- {
- if ( cmw[i] == winId() ) /* replace old window */
- {
- cmw[i] = w;
- break;
- }
- }
-
- if ( i >= count ) /* append new window */
- cmw[count++] = w;
- }
- else
- {
- count = 1;
- cmw = new Window[count];
- cmw[0] = w;
- }
-
- /* Creating new window (with good VisualID) for this widget */
- create(w);
- XSetWMColormapWindows( x11Display(), topLevelWidget()->winId(), cmw, count );
- delete[] cmw;
-
- if ( isVisible() )
- show();
-
- if ( pVisualInfo )
- {
- XFree( (char *)pVisualInfo );
- }
- XFlush( x11Display() );
- }
-#endif
-}
-
-/*!
- Sets the background 'color'. [ virtual ]
-*/
-void GLViewer_ViewPort::setBackgroundColor( const QColor& color )
-{
- QPalette pal = palette();
- pal.setColor( QColorGroup::Background, color );
- setPalette( pal );
- repaint();
-}
-
-/*!
- Returns the background color. [ virtual ]
-*/
-QColor GLViewer_ViewPort::backgroundColor() const
-{
- return palette().active().background();
-}
-
-/*!
- Returns 'true' if sketching is enabled in this viewport. [ public ]
-*/
-bool GLViewer_ViewPort::isSketchingEnabled() const
-{
- return myEnableSketching;
-}
-
-/*!
- Enables / disables sketching [ public ]
-*/
-void GLViewer_ViewPort::setSketchingEnabled( bool enable )
-{
- myEnableSketching = enable;
-}
-
-/*!
- Returns 'true' if transformations ( rotation, zoom etc. )
- are enabled in this viewport. [ public ]
-*/
-bool GLViewer_ViewPort::isTransformEnabled() const
-{
- return myEnableTransform;
-}
-
-/*!
- Enables / disables transformations. [ public ]
-*/
-void GLViewer_ViewPort::setTransformEnabled( bool enable )
-{
- myEnableTransform = enable;
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::mousePressEvent( QMouseEvent *e )
-{
- emit vpMouseEvent( e );
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::mouseMoveEvent( QMouseEvent* e )
-{
- emit vpMouseEvent( e );
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::mouseReleaseEvent( QMouseEvent *e )
-{
- emit vpMouseEvent( e );
-
- /* show popup menu */
- if ( e->button() == Qt::RightButton )
- {
- //QPopupMenu* popup = createPopup();
- //if ( popup && popup->count() )
- // popup->exec( QCursor::pos() );
- //destroyPopup( /*popup*/ );
- }
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::mouseDoubleClickEvent( QMouseEvent *e )
-{
- emit vpMouseEvent( e );
-}
-
-/*!
- Emits 'keyEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::keyPressEvent( QKeyEvent *e )
-{
- emit vpKeyEvent( e );
-}
-
-/*!
- Emits 'keyEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::keyReleaseEvent( QKeyEvent *e )
-{
- emit vpKeyEvent( e );
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort::wheelEvent( QWheelEvent *e )
-{
- emit vpWheelEvent( e );
-}
-
-/*!
- Repaints the viewport. [ virtual protected ]
-*/
-void GLViewer_ViewPort::paintEvent( QPaintEvent* )
-{
- if ( myPaintersRedrawing )
- {
- QPainter p( this );
- emit vpDrawExternal( &p );
- myPaintersRedrawing = false;
- }
-}
-
-/*!
- Forces to redraw the viewport by an external painter. [ public ]
-*/
-void GLViewer_ViewPort::redrawPainters()
-{
- myPaintersRedrawing = true;
- repaint();
-}
-
-/*!
- Updates this view. Does nothing by default. [ virtual public ]
-*/
-void GLViewer_ViewPort::onUpdate()
-{
-}
-
-/*!
- Sets the background color with color selection dialog. [ virtual protected slot ]
-*/
-void GLViewer_ViewPort::onChangeBgColor()
-{
- QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
- if ( selColor.isValid() )
- setBackgroundColor( selColor );
-}
-
-/*!
- Custom context menu event handler
-*/
-void GLViewer_ViewPort::contextMenuEvent( QContextMenuEvent* e )
-{
- //if ( e->reason() != QContextMenuEvent::Mouse )
- emit contextMenuRequested( e );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewPort.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_VIEWPORT_H
-#define GLVIEWER_VIEWPORT_H
-
-#include "GLViewer.h"
-
-#include <qlist.h>
-#include <qcolor.h>
-#include <qaction.h>
-#include <qwidget.h>
-
-#include <Aspect_Window.hxx>
-
-class QRect;
-class QCursor;
-class QPainter;
-class GLViewer_ViewSketcher;
-class GLViewer_ViewTransformer;
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-enum BlockStatus
-{
- BS_NoBlock = 0x0000,
- BS_Highlighting = 0x0001,
- BS_Selection = 0x0002,
- BS_Dragging = 0x0004
-};
-
-/*!
- \class GLViewer_ViewPort
- Visualisation canvas of GLViewer
-*/
-class GLVIEWER_API GLViewer_ViewPort: public QWidget
-{
- Q_OBJECT
- friend class GLViewer_ViewSketcher;
- friend class GLViewer_ViewTransformer;
-
-public:
- GLViewer_ViewPort( QWidget* parent );
- ~GLViewer_ViewPort();
-
-public:
- //! Activates/deactivates sketching
- void setSketchingEnabled( bool );
- //! Checks active status of sketcher
- bool isSketchingEnabled() const;
- //! Activates/deactivates transformer
- void setTransformEnabled( bool );
- //! Checks active status of transformer
- bool isTransformEnabled() const;
-
- //! Returns background color
- virtual QColor backgroundColor() const;
- //! Sets background color
- virtual void setBackgroundColor( const QColor& );
-
- //! Redraw external pa inters
- void redrawPainters();
-
- //! Updates view
- virtual void onUpdate();
-
- //! Returns blocking status for current started operations
- virtual BlockStatus currentBlock(){ return BS_NoBlock; }
-
-protected:
- enum ViewType { Type2D, Type3D };
- void selectVisualId( ViewType );
-
- virtual QPaintDevice* getPaintDevice() { return this; }
- virtual void contextMenuEvent( QContextMenuEvent * e );
-
-//! STATICS
- static void createCursors();
- static void destroyCursors();
- static QCursor* getHandCursor() { return handCursor; }
- static void setHandCursor( const QCursor& newCursor );
- static QCursor* getPanCursor() { return panCursor; }
- static void setPanCursor( const QCursor& newCursor );
- static QCursor* getPanglCursor() { return panglCursor; }
- static void setPanglCursor( const QCursor& newCursor );
- static QCursor* getZoomCursor() { return zoomCursor; }
- static void setZoomCursor( const QCursor& newCursor );
-
-public://ouv
- static QCursor* getDefaultCursor() { return defCursor; }
- static void setDefaultCursor( const QCursor& newCursor );
- static QCursor* getRotCursor() { return rotCursor; }
- static void setRotCursor( const QCursor& newCursor );
- static QCursor* getSketchCursor() { return sketchCursor; }
- static void setSketchCursor( const QCursor& newCursor );
-
-protected:
-//! EVENTS
- virtual void paintEvent( QPaintEvent *);
- virtual void mouseMoveEvent( QMouseEvent *);
- virtual void mouseReleaseEvent( QMouseEvent *);
- virtual void mousePressEvent( QMouseEvent *);
- virtual void mouseDoubleClickEvent( QMouseEvent *);
- virtual void keyPressEvent( QKeyEvent *);
- virtual void keyReleaseEvent( QKeyEvent *);
- virtual void wheelEvent( QWheelEvent *);
-
-//! TO BE REDEFINED
- virtual void reset() = 0;
- virtual void pan( int, int ) = 0;
- virtual void setCenter( int, int ) = 0;
- virtual void zoom( int, int, int, int ) = 0;
- virtual void fitRect( const QRect& ) = 0;
- virtual void fitSelect() = 0;
- virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
-
-protected slots:
- virtual void onChangeBgColor();
-
-signals:
- void vpKeyEvent( QKeyEvent* );
- void vpMouseEvent( QMouseEvent* );
- void vpWheelEvent( QWheelEvent* );
- void vpDrawExternal( QPainter* );
-
- void contextMenuRequested( QContextMenuEvent* );
-
-private:
- void initialize();
- void cleanup();
-
-protected:
- //Handle(Aspect_Window) myWindow;
- bool myEnableSketching;
- bool myEnableTransform;
- bool myPaintersRedrawing; /* set to draw externally */
- //QList<QAction> myPopupActions;
-
-private:
- static int nCounter; /* objects counter */
- static QCursor* defCursor;
- static QCursor* panglCursor;
- static QCursor* handCursor;
- static QCursor* panCursor;
- static QCursor* zoomCursor;
- static QCursor* rotCursor;
- static QCursor* sketchCursor;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewPort2d.cxx
-// Created: November, 2004
-
-/* GLViewer_ViewPort2d Source File */
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_ViewPort2d.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_ViewFrame.h"
-#include "GLViewer_MimeSource.h"
-#include "GLViewer_Context.h"
-#include "GLViewer_Compass.h"
-#include "GLViewer_Grid.h"
-
-#include <QtxToolTip.h>
-
-#include <qlayout.h>
-#include <qevent.h>
-#include <qrect.h>
-#include <qpopupmenu.h>
-#include <qtooltip.h>
-#include <qapplication.h>
-#include <qclipboard.h>
-#include <qpainter.h>
-#include <qbitmap.h>
-#include <qlabel.h>
-
-#define WIDTH 640
-#define HEIGHT 480
-#define MARGIN 100
-
-#define GRID_XSIZE 100
-#define GRID_YSIZE 100
-
-int static aLastViewPostId = 0;
-
-void rotate_point( float& theX, float& theY, float theAngle )
-{
- float aTempX = theX * cos(theAngle) - theY * sin(theAngle);
- float aTempY = theX * sin(theAngle) + theY * cos(theAngle);
- theX = aTempX;
- theY = aTempY;
-}
-
-/*!
- Constructor
-*/
-GLViewer_ViewPort2d::GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame ) :
- GLViewer_ViewPort( parent ),
- myMargin( MARGIN ), myWidth( WIDTH ), myHeight( HEIGHT ),
- myXScale( 1.0 ), myYScale( 1.0 ), myXOldScale( 1.0 ), myYOldScale( 1.0 ),
- myXPan( 0.0 ), myYPan( 0.0 ),
- myIsMouseReleaseBlock( false )
-{
- if( theViewFrame == NULL )
- myViewFrame = ( GLViewer_ViewFrame* )parent;
- else
- myViewFrame = theViewFrame;
-
- myGrid = 0;
- myCompass = 0;
- myBorder = new GLViewer_Rect();
-
- QBoxLayout* qbl = new QHBoxLayout( this );
- myGLWidget = new GLViewer_Widget( this, 0 ) ;
- qbl->addWidget( myGLWidget );
- myGLWidget->setFocusProxy( this );
- setMouseTracking( TRUE );
-
- myIsDragProcess = noDrag;
- //myCurDragMousePos = QPoint();
- myCurDragPosX = NULL;
- myCurDragPosY = NULL;
-
- myIsPulling = false;
-
- myViewPortId = aLastViewPostId;
- aLastViewPostId++;
-
- mypFirstPoint = NULL;
- mypLastPoint = NULL;
-
- myObjectTip = new QtxToolTip( myGLWidget );///GLViewer_ObjectTip( this );
- myObjectTip->setShowDelayTime( 60000 );
- connect( myObjectTip, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),
- this, SLOT( onMaybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );
-// myGLWidget->installEventFilter( myObjectTip );
-}
-
-/*!
- Destructor
-*/
-GLViewer_ViewPort2d::~GLViewer_ViewPort2d()
-{
- if( myCompass )
- delete myCompass;
-
- if( myGrid )
- delete myGrid;
-
- delete myBorder;
- delete myGLWidget;
-}
-
-/*!
- SLOT: initializes drag process
-*/
-void GLViewer_ViewPort2d::onStartDragObject( )
-{
- if( myIsDragProcess == noDrag )
- {
- myIsDragProcess = initDrag;
- QCursor::setPos( (int)(*myCurDragPosX), (int)(*myCurDragPosY) );
- //myCurDragMousePos = QPoint( 0, 0 );
- delete myCurDragPosX;
- delete myCurDragPosY;
- myCurDragPosX = NULL;
- myCurDragPosY = NULL;
- return;
- }
-}
-
-/*!
- SLOT: cuts object to clipboard
-*/
-void GLViewer_ViewPort2d::onCutObject()
-{
- /*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
- if( aMovingObject )
- {
- GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
- aMimeSource->setObject( aMovingObject );
-
- QClipboard *aClipboard = QApplication::clipboard();
- aClipboard->clear();
- aClipboard->setData( aMimeSource );
-
- ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->deleteObject( aMovingObject );
- }*/
- GLViewer_Context* aContext = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext();
- int aObjNum = aContext->NbSelected();
- if( aObjNum > 0 )
- {
- QValueList<GLViewer_Object*> aObjects;
- GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
- aContext->InitSelected();
- for( ; aContext->MoreSelected(); aContext->NextSelected() )
- aObjects.append( aContext->SelectedObject() );
-
- //aMimeSource->setObjects( aObjects ); ouv 6.05.04
-
- QClipboard *aClipboard = QApplication::clipboard();
- aClipboard->clear();
- aClipboard->setData( aMimeSource );
-
- for( int i = 0; i < aObjNum; i++ )
- aContext->deleteObject( aObjects[i] );
- }
-}
-
-/*!
- SLOT: copies object to clipboard
-*/
-void GLViewer_ViewPort2d::onCopyObject()
-{
- /*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
- if( aMovingObject )
- {
- GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
- aMimeSource->setObject( aMovingObject );
-
- QClipboard *aClipboard = QApplication::clipboard();
- aClipboard->clear();
- aClipboard->setData( aMimeSource );
- }
- */
- GLViewer_Context* aContext = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext();
- int aObjNum = aContext->NbSelected();
- if( aObjNum > 0 )
- {
- QValueList<GLViewer_Object*> aObjects;
- GLViewer_MimeSource* aMimeSource = new GLViewer_MimeSource();
- aContext->InitSelected();
- for( ; aContext->MoreSelected(); aContext->NextSelected() )
- aObjects.append( aContext->SelectedObject() );
-
- //aMimeSource->setObjects( aObjects ); ouv 6.05.04
-
- QClipboard *aClipboard = QApplication::clipboard();
- aClipboard->clear();
- aClipboard->setData( aMimeSource );
- }
-}
-
-/*!
- SLOT: pastes object from clipboard
-*/
-void GLViewer_ViewPort2d::onPasteObject()
-{
- /*QClipboard *aClipboard = QApplication::clipboard();
- QMimeSource* aMimeSource = aClipboard->data();
- if( aMimeSource->provides( "GLViewer_Object" ) )
- {
- const char* aType;
- int i = 1;
- QByteArray anArray;
- do
- {
- aType = aMimeSource->format( i );
- anArray = aMimeSource->encodedData( aType );
- if( anArray.size() != 0 )
- break;
- i++;
- }
- while( aType != 0 );
- if( anArray.size() == 0 )
- return;
-
- GLViewer_Object* aObject = GLViewer_MimeSource::getObject( anArray, aType );
- if( !aObject )
- return;
-
- ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->insertObject( aObject, true );
- }
- */
- /* ouv 6.05.04
- QClipboard *aClipboard = QApplication::clipboard();
-
- QMimeSource* aMimeSource = aClipboard->data();
- if( aMimeSource->provides( "GLViewer_Objects" ) )
- {
- QByteArray anArray = aMimeSource->encodedData( "GLViewer_Objects" );
- QValueList<GLViewer_Object*> aObjects = GLViewer_MimeSource::getObjects( anArray, "GLViewer_Objects" );
- if( aObjects.empty() )
- return;
- GLViewer_Context* aContext = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext();
- for( int i = 0; i < aObjects.count(); i++ )
- aContext->insertObject( aObjects[i], true );
- }
- */
-}
-
-/*!
- SLOT: called when object is being dragged
-*/
-void GLViewer_ViewPort2d::onDragObject( QMouseEvent* e )
-{
- //cout << "---GLViewer_ViewPort2d::onDragObject()---" << endl;
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
- GLViewer_Object* anObject = aContext->getCurrentObject();
-
- if( !aContext )
- return;
-
- float aX = e->pos().x();
- float anY = e->pos().y();
- aViewer->transPoint( aX, anY );
-
- if( myCurDragPosX == NULL && myCurDragPosY == NULL )
- {
- myCurDragPosX = new float(aX);
- myCurDragPosY = new float(anY);
- return;
- }
-
- //QPoint aNewPos = e->pos();
- //GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
-
- if( anObject && (e->state() & LeftButton ) )
- {
- if( aContext->isSelected( anObject ) )
- {
- for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
- {
- GLViewer_Object* aMovingObject = aContext->SelectedObject();
- if( aMovingObject )
- aMovingObject->moveObject( aX - *myCurDragPosX, anY - *myCurDragPosY);
- }
- }
- else
- anObject->moveObject( aX - *myCurDragPosX, anY - *myCurDragPosY);
- }
- else if( aContext->NbSelected() && (e->state() & MidButton ) )
- for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
- (aContext->SelectedObject())->moveObject( aX - *myCurDragPosX, anY - *myCurDragPosY);
-
- delete myCurDragPosX;
- delete myCurDragPosY;
- myCurDragPosX = new float(aX);
- myCurDragPosY = new float(anY);
-
- myGLWidget->updateGL();
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort2d::mousePressEvent( QMouseEvent* e )
-{
- emit vpMouseEvent( e );
-
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
-
- GLViewer_Object* anObject = NULL;
- if( aContext )
- anObject = aContext->getCurrentObject();
-
- bool accel = e->state() & GLViewer_ViewTransformer::accelKey();
- if( ( anObject && !( accel || e->button() == Qt::RightButton ) ) ||
- ( aContext->NbSelected() && !accel && e->button() == Qt::MidButton ) )
- {
- myIsDragProcess = inDrag;
- }
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort2d::mouseMoveEvent( QMouseEvent* e )
-{
- emit vpMouseEvent( e );
-
- if( myIsDragProcess == inDrag )
- onDragObject( e );
-
- /*GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
-
- GLViewer_Object* anObj = aContext->getCurrentObject();
- if( anObj && aContext->currentObjectIsChanged() )
- {
- //cout << "GLViewer_ViewPort2d::mouseMoveEvent{QToolTip::add}" << endl;
- //QToolTip::remove( myGLWidget );
- QRect* aRect = (aViewer->getWinObjectRect(anObj));
- //QToolTip::add( myGLWidget, *aRect, anObj->getToolTipText() );
- myGLWidget->addToolTip( anObj->getToolTipText(), *aRect );
- }
- if(!anObj)
- {
- //cout << "GLViewer_ViewPort2d::mouseMoveEvent{QToolTip::remove}" << endl;
- //QRect* aRect = (aViewer->getWinObjectRect(anObj));
- //QToolTip::remove( myGLWidget, *aRect );
- myGLWidget->removeToolTip();
- }*/
-}
-
-/*!
- Emits 'mouseEvent' signal. [ virtual protected ]
-*/
-void GLViewer_ViewPort2d::mouseReleaseEvent( QMouseEvent* e )
-{
- if ( myIsMouseReleaseBlock )
- {
- // skip mouse release after double click
- myIsMouseReleaseBlock = false;
- return;
- }
-
- /* show popup menu */
- if ( e->button() == Qt::RightButton )
- {
- //QPopupMenu* popup = createPopup();
- //if ( popup && popup->count() )
- // popup->exec( QCursor::pos() );
- //destroyPopup( /*popup*/ );
- }
- emit vpMouseEvent( e );
-
- if( myIsDragProcess == inDrag )
- {
- bool isAnyMoved = false;
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
- GLViewer_Object* aMovingObject;
- for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
- {
- aMovingObject = aContext->SelectedObject();
- if( aMovingObject )
- isAnyMoved = aMovingObject->finishMove() || isAnyMoved;
- }
-
- aMovingObject = aContext->getCurrentObject();
- if( aMovingObject )
- isAnyMoved = aMovingObject->finishMove() || isAnyMoved;
-
- myIsDragProcess = noDrag;
- //myCurDragMousePos.setX( 0 );
- //myCurDragMousePos.setY( 0 );
- delete myCurDragPosX;
- delete myCurDragPosY;
- myCurDragPosX = NULL;
- myCurDragPosY = NULL;
-
- if( isAnyMoved )
- {
- emit objectMoved();
- aViewer->updateBorders();
- }
- }
-}
-
-/*!
- Custom mouse double click event handler
-*/
-void GLViewer_ViewPort2d::mouseDoubleClickEvent( QMouseEvent * e )
-{
- //redefined to block mouse release after mouse double click
- myIsMouseReleaseBlock = true;
- // invoke base implementation
- GLViewer_ViewPort::mouseDoubleClickEvent( e );
-}
-
-/*!
- Creates or deletes compass
- \param on - if it is true, then to create
-*/
-void GLViewer_ViewPort2d::turnCompass( GLboolean on )
-{
- if( on )
- myCompass = new GLViewer_Compass( Qt::green, 30, GLViewer_Compass::TopRight, 10, 5, 12, 3 );
- else if( myCompass )
- delete myCompass;
-}
-
-/*!
- Creates or deletes grid
- \param on - if it is true, then to create
-*/
-void GLViewer_ViewPort2d::turnGrid( GLboolean on )
-{
- if( on )
- {
- myGrid = new GLViewer_Grid( 2*WIDTH, 2*HEIGHT,
- 2*WIDTH, 2*HEIGHT,
- GRID_XSIZE, GRID_YSIZE,
- myXPan, myYPan,
- myXScale, myYScale );
- }
- else if( myGrid )
- delete myGrid;
-}
-
-/*!
- Changes grid color
- \param gridColor - new grid color
- \param axisColor - new axis color
-*/
-void GLViewer_ViewPort2d::setGridColor( const QColor gridColor, const QColor axisColor )
-{
- if( myGrid )
- {
- myGrid->setGridColor( ( GLfloat )gridColor.red() / 255,
- ( GLfloat )gridColor.green() / 255,
- ( GLfloat )gridColor.blue() / 255 );
- myGrid->setAxisColor( ( GLfloat )axisColor.red() / 255,
- ( GLfloat )axisColor.green() / 255,
- ( GLfloat )axisColor.blue() / 255 );
- }
-}
-
-/*!
- Changes background color
- \param color - new background color
-*/
-void GLViewer_ViewPort2d::setBackgroundColor( const QColor& color )
-{
- GLViewer_ViewPort::setBackgroundColor( color );
- myGLWidget->makeCurrent();
- glClearColor( ( GLfloat )color.red() / 255,
- ( GLfloat )color.green() / 255,
- ( GLfloat )color.blue() / 255, 1.0 );
- myGLWidget->repaint();
-}
-
-/*!
- \return background color
-*/
-QColor GLViewer_ViewPort2d::backgroundColor() const
-{
- return GLViewer_ViewPort::backgroundColor();
-}
-
-/*!
- Resize view
-*/
-void GLViewer_ViewPort2d::initResize( int x, int y )
-{
- float xa, xb, ya, yb;
- xa = myBorder->left() - myMargin;
- xb = myBorder->right() + myMargin;
- ya = myBorder->top() - myMargin;
- yb = myBorder->bottom() + myMargin;
-
- GLfloat zoom, xzoom, yzoom;
- GLfloat w = x;
- GLfloat h = y;
- bool max = FALSE;
-
- xzoom = (GLfloat)x / myWidth;
- yzoom = (GLfloat)y / myHeight;
-
- if ( ( xzoom < yzoom ) && ( xzoom < 1 ) )
- zoom = xzoom;
- else if ( ( yzoom < xzoom ) && ( yzoom < 1 ) )
- zoom = yzoom;
- else
- {
- max = TRUE;
- zoom = xzoom > yzoom ? xzoom : yzoom;
- }
-
- if ( !max && ( ! ( ( ( myXPan + w/2 ) < xb * myXScale * zoom ) ||
- ( ( myXPan - w/2 ) > xa * myXScale * zoom ) ||
- ( ( myYPan + h/2 ) < yb * myYScale * zoom ) ||
- ( ( myYPan - h/2 ) > ya * myYScale * zoom ) ) ) )
- zoom = 1;
-
- if ( max && ( ( ( myXPan + w/2 ) < xb * myXScale * zoom ) ||
- ( ( myXPan - w/2 ) > xa * myXScale * zoom ) ||
- ( ( myYPan + h/2 ) < yb * myYScale * zoom ) ||
- ( ( myYPan - h/2 ) > ya * myYScale * zoom ) ) )
- zoom = 1;
-
- myWidth = x;
- myHeight = y;
-
- myXScale *= zoom;
- myYScale = myXScale;
-
- if ( myGrid )
- myGrid->setResize( 2*x, 2*y, zoom );
-
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
-}
-
-/*!
- Custom paint event handler
-*/
-void GLViewer_ViewPort2d::paintEvent( QPaintEvent* e )
-{
- //cout << "GLViewer_ViewPort2d::paintEvent" << endl;
- myGLWidget->updateGL();
- GLViewer_ViewPort::paintEvent( e );
-}
-
-/*!
- Custom resize event handler
-*/
-void GLViewer_ViewPort2d::resizeEvent( QResizeEvent* e )
-{
- //cout << "GLViewer_ViewPort2d::resizeEvent" << endl;
- GLViewer_ViewPort::resizeEvent( e );
-}
-
-/*!
- Resets view to start state
-*/
-void GLViewer_ViewPort2d::reset()
-{
- //cout << "GLViewer_ViewPort2d::reset" << endl;
-
- GLint val[4];
- GLint vpWidth, vpHeight;
-
- myGLWidget->makeCurrent();
- glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
-
- GLint w = myGLWidget->getWidth();
- GLint h = myGLWidget->getHeight();
- GLfloat zoom = vpWidth / ( GLfloat )w < vpHeight / ( GLfloat )h ?
- vpWidth / ( GLfloat )w : vpHeight / ( GLfloat )h;
-
- if( myGrid )
- {
- myGrid->setPan( 0.0, 0.0 );
- myGrid->setZoom( zoom / myXScale );
- }
-
- myXPan = 0.0;
- myYPan = 0.0;
- myXScale = zoom;
- myYScale = zoom;
-
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->setRotationAngle( 0.0 );
- myGLWidget->setRotation( 0.0, 0.0, 0.0, 1.0 );
- myGLWidget->updateGL();
-}
-
-/*!
- Sets offset to view
- \param dx - X offset
- \param dy - Y offset
-*/
-void GLViewer_ViewPort2d::pan( int dx, int dy )
-{
- //cout << "GLViewer_ViewPort2d::pan " << dx << " " << dy << endl;
-
- /*myXPan += dx / myXScale;
- myYPan += dy / myYScale;
-
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- GLfloat angle = ra * PI / 180.;
-
- if( myGrid )
- myGrid->setPan( myXPan*cos(angle) + myYPan*sin(angle),
- -myXPan*sin(angle) + myYPan*cos(angle) );
-
- */
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- GLfloat angle = ra * PI / 180.;
-
- myXPan += (dx*cos(angle) + dy*sin(angle)) / myXScale;
- myYPan += (-dx*sin(angle) + dy*cos(angle)) / myXScale;
-
- if( myGrid )
- myGrid->setPan( myXPan, myYPan );
-
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->updateGL();
-}
-
-/*!
- Sets view center in global coords
- \param x, y - global co-ordinates of center
-*/
-void GLViewer_ViewPort2d::setCenter( int x, int y )
-{
- //cout << "GLViewer_ViewPort2d::setCenter" << endl;
-
- GLint val[4];
- GLint vpWidth, vpHeight;
-
- myGLWidget->makeCurrent();
- glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
-
- myXPan -= ( x - vpWidth/2 ) / myXScale;
- myYPan += ( y - vpHeight/2 ) / myYScale;
-
- if( myGrid )
- {
- myGrid->setPan( myXPan, myYPan );
- myGrid->setZoom( myXOldScale / myXScale );
- }
-
- myXScale = myXOldScale;
- myYScale = myYOldScale;
-
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->updateGL();
-}
-
-/*!
- Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 )
-*/
-void GLViewer_ViewPort2d::zoom( int x0, int y0, int x, int y )
-{
- //cout << "GLViewer_ViewPort2d::zoom" << endl;
-
- float dx, dy, zm;
- dx = x - x0;
- dy = y - y0;
-
- if ( dx == 0. && dy == 0. )
- return;
-
- zm = sqrt(dx * dx + dy * dy) / 100. + 1;
- zm = (dx > 0.) ? zm : 1. / zm;
-
- //backup values
- float bX = myXScale;
- float bY = myYScale;
- myXScale *= zm;
- myYScale *= zm;
-
- if( myGrid )
- {
- if( myGrid->setZoom( zm ) )
- {
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->updateGL();
- }
- else
- {// undo
- myXScale = bX;
- myYScale = bY;
- }
- }
- else
- {
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->updateGL();
- }
-}
-
-/*!
- Transforms view by rectangle
- \param rect - rectangle
-*/
-void GLViewer_ViewPort2d::fitRect( const QRect& rect )
-{
- float x0, x1, y0, y1;
- float dx, dy, zm, centerX, centerY;
-
- GLint val[4];
- GLint vpWidth, vpHeight;
-
- myGLWidget->makeCurrent();
- glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
-
- x0 = rect.left();
- x1 = rect.right();
- y0 = rect.top();
- y1 = rect.bottom();
-
- dx = fabs( x1 - x0 );
- dy = fabs( y1 - y0 );
- centerX = ( x0 + x1 ) / 2.;
- centerY = ( y0 + y1 ) / 2.;
-
- if ( dx == 0. || dy == 0. )
- return;
-
- zm = vpWidth / dx < vpHeight / dy ? vpWidth / dx : vpHeight / dy;
-
- float aDX = ( vpWidth / 2. - centerX ) / myXScale;
- float aDY = ( vpHeight / 2. - centerY ) / myYScale;
-
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- GLfloat angle = ra * PI / 180.;
-
- myXPan += (aDX*cos(angle) - aDY*sin(angle));
- myYPan -= (aDX*sin(angle) + aDY*cos(angle));
-
- if( myGrid )
- myGrid->setPan( myXPan, myYPan );
-
- myXScale *= zm;
- myYScale = myXScale;
-
- if( myGrid )
- myGrid->setZoom( zm );
-
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->updateGL();
-}
-
-/*!
- Transforms view by selection
-*/
-void GLViewer_ViewPort2d::fitSelect()
-{
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
- if( !aContext )
- return;
-
- QRect aSelRect;
- for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
- aSelRect |= *(aViewer->getWinObjectRect( aContext->SelectedObject() ));
-
- if( aSelRect.isValid() )
- {
- aSelRect.setTop( aSelRect.top() - SELECTION_RECT_GAP );
- aSelRect.setBottom( aSelRect.bottom() + SELECTION_RECT_GAP );
- aSelRect.setLeft( aSelRect.left() - SELECTION_RECT_GAP );
- aSelRect.setRight( aSelRect.right() + SELECTION_RECT_GAP );
- fitRect( aSelRect );
- }
-}
-
-/*!
- Transform view by view borders
- \param keepScale - if it is true, zoom does not change
-*/
-void GLViewer_ViewPort2d::fitAll( bool keepScale, bool withZ )
-{
- //cout << "GLViewer_ViewPort2d::fitAll" << endl;
-
- float xa, xb, ya, yb;
- float dx, dy, zm;
- float xScale, yScale;
-
- myMargin = QMAX( myBorder->width(), myBorder->height() ) / 5;
-
- xa = myBorder->left() - myMargin;
- xb = myBorder->right() + myMargin;
- ya = myBorder->bottom() - myMargin;
- yb = myBorder->top() + myMargin;
-
- float aPoints[8] = { xa, ya, xb, ya, xa, yb, xb, yb };
-
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- float angle = ra * PI / 180.;
-
- int i;
- for( i = 0; i < 7; i = i + 2 )
- rotate_point( aPoints[i], aPoints[i+1], angle );
-
- float aBorders[4] = { aPoints[0], aPoints[0], aPoints[1], aPoints[1] };
-
- for( i = 2; i < 7; i = i + 2 )
- {
- if( aBorders[0] < aPoints[i] )
- aBorders[0] = aPoints[i];
- if( aBorders[1] > aPoints[i] )
- aBorders[1] = aPoints[i];
-
- if( aBorders[2] < aPoints[i+1] )
- aBorders[2] = aPoints[i+1];
- if( aBorders[3] > aPoints[i+1] )
- aBorders[3] = aPoints[i+1];
- }
-
- GLint val[4];
- GLint vpWidth, vpHeight;
-
- myGLWidget->makeCurrent();
- glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
-
- dx = fabs( aBorders[1] - aBorders[0] );
- dy = fabs( aBorders[3] - aBorders[2] );
-
- myXPan = -( aBorders[0] + aBorders[1] ) / 2;
- myYPan = -( aBorders[2] + aBorders[3] ) / 2;
-
-
- if( keepScale )
- {
- myXOldScale = myXScale;
- myYOldScale = myYScale;
- }
-
- xScale = myXScale;
- yScale = myYScale;
- if( dx && dy )
- zm = vpWidth / dx < vpHeight / dy ? vpWidth / dx : vpHeight / dy;
- else
- zm = 1.0;
- myXScale = zm;
- myYScale = zm;
-
-
- if( myGrid )
- {
- myGrid->setPan( myXPan, myYPan );
- if( dx > dy )
- myGrid->setZoom( zm / xScale );
- else
- myGrid->setZoom( zm / yScale );
- }
-
- myGLWidget->setPan( myXPan, myYPan, 0.0 );
- myGLWidget->setScale( myXScale, myYScale, 1.0 );
- myGLWidget->updateGL();
-
- if( keepScale )
- emit vpUpdateValues();
-}
-
-/*!
- Begins rotation
- \param x, y - start point
-*/
-void GLViewer_ViewPort2d::startRotation( int x, int y )
-{
- myGLWidget->setRotationStart( x, y, 1.0 );
-}
-
-/*!
- Performs rotation
- \param intX, intY - current point
-*/
-void GLViewer_ViewPort2d::rotate( int intX, int intY )
-{
- GLint val[4];
- GLint vpWidth, vpHeight;
-
- myGLWidget->makeCurrent();
- glGetIntegerv( GL_VIEWPORT, val );
- vpWidth = val[2];
- vpHeight = val[3];
-
- float x = intX, y = intY;
- float x0 = vpWidth/2;
- float y0 = vpHeight/2;
-
- float xs, ys, zs, dx, dy;
- myGLWidget->getRotationStart( xs, ys, zs );
-
- xs = xs - x0;
- x = x - x0;
- dx = x - xs;
- ys = y0 - ys;
- y = y0 - y;
- dy = y - ys;
-
- float l1 = pow( double( xs*xs + ys*ys ), 0.5 );
- float l2 = pow( double( x*x + y*y ), 0.5 );
- float l = pow( double( dx*dx + dy*dy ), 0.5 );
-
- double mult = xs * y - x * ys;
- short sign;
- if( mult > 0 ) sign = 1;
- else if( mult < 0 ) sign = -1;
- else sign = 0;
-
- float anglePrev = myGLWidget->getRotationAngle();
- float angleNew = sign * acos( ( l1*l1 + l2*l2 - l*l ) / ( 2 * l1 * l2 )) * 180. / PI;
- float angle = anglePrev + angleNew;
-
- // GLfloat anAngle = angle * PI / 180.; unused
-
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- myGLWidget->setRotation( angle, rx, ry, rz );
- myGLWidget->updateGL();
-}
-
-/*!
- Finishes rotation
-*/
-void GLViewer_ViewPort2d::endRotation()
-{
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- myGLWidget->setRotationAngle( ra );
-}
-
-/*!
- Draws compass
-*/
-void GLViewer_ViewPort2d::drawCompass()
-{
- if( !myCompass->getVisible() )
- return;
-
- GLfloat xScale, yScale, xPan, yPan;
-
- int xPos = getWidth();
- int yPos = getHeight();
-
- int cPos = myCompass->getPos();
- int cSize = myCompass->getSize();
- QColor cCol = myCompass->getColor();
- int cWidthTop = myCompass->getArrowWidthTop();
- int cWidthBot = myCompass->getArrowWidthBottom();
- int cHeightTop = myCompass->getArrowHeightTop();
- int cHeightBot = myCompass->getArrowHeightBottom();
-
- GLfloat colorR = (cCol.red())/255;
- GLfloat colorG = (cCol.green())/255;
- GLfloat colorB = (cCol.blue())/255;
-
- float delX = cSize * 0.5;
- float delY = cSize * 0.5;
-
- getScale( xScale, yScale );
- getPan( xPan, yPan);
-
- float centerX = (xPos/2 - delX - cSize)/xScale;
- float centerY = (yPos/2 - delY - cSize)/yScale;
-
- switch ( cPos )
- {
- case GLViewer_Compass::TopLeft:
- centerX = -centerX;
- break;
- case GLViewer_Compass::BottomLeft:
- centerX = -centerX;
- centerY = -centerY;
- break;
- case GLViewer_Compass::BottomRight:
- centerY = -centerY;
- break;
- default: break;
- }
-
- float ra, rx, ry, rz;
- myGLWidget->getRotation( ra, rx, ry, rz );
- GLfloat angle = ra * PI / 180.;
- GLfloat /*r = 0.0,*/ x = 0.0 , y = 0.0;
-
- rotate_point( centerX, centerY, -angle );
-
- centerX -= xPan;
- centerY -= yPan;
-
- glColor3f( colorR, colorG, colorB );
- glBegin( GL_POLYGON );
- //arrow
- x = centerX; y = centerY + cSize / yScale;
- glVertex2f( x, y );
- //point #2
- x = centerX + cWidthTop / xScale; y = centerY + ( cSize - cHeightTop ) / yScale ;
- glVertex2f( x, y );
- //point #3
- x = centerX + cWidthBot / xScale; y = centerY + ( cSize - cHeightTop ) / yScale ;
- glVertex2f( x, y );
- //point #4
- x = centerX + cWidthBot / xScale; y = centerY - cSize/yScale;
- glVertex2f( x, y );
- //point #5
- x = centerX; y = centerY - (cSize - cHeightBot) / yScale ;
- glVertex2f( x, y );
- //point #6
- x = centerX - cWidthBot / xScale; y = centerY - cSize/yScale;
- glVertex2f( x, y );
- //point #7
- x = centerX - cWidthBot / xScale; y = centerY + ( cSize - cHeightTop ) / yScale ;
- glVertex2f( x, y );
- //point #8
- x = centerX - cWidthTop / xScale; y = centerY + ( cSize - cHeightTop ) / yScale ;
- glVertex2f( x, y );
- glEnd();
- glLineWidth( 2.0 );
- glEnable( GL_LINE_SMOOTH );
- glBegin(GL_LINE_LOOP);
- //circle
- float aCircAngle = 0;
- for ( int i = 0; i < 20 * SEGMENTS + 1; i++ )
- {
- x = centerX + cos(aCircAngle) * cSize / xScale;
- y = centerY + sin(aCircAngle) * cSize / yScale;
- glVertex2f( x, y );
- aCircAngle += float( STEP ) / 2;
- }
- glEnd();
-
- GLdouble modelMatrix[16], projMatrix[16];
- GLint viewport[4];
- GLdouble winxN, winyN, winz;
- GLdouble winxE, winyE;
- GLdouble winxS, winyS;
- GLdouble winxW, winyW;
- GLuint aTextList;
-
- GLViewer_TexFont* aFont = myCompass->getFont();
- float widN = (float)aFont->getStringWidth( "N" );
- float widW = (float)aFont->getStringWidth( "W" );
- float widS = (float)aFont->getStringWidth( "S" );
- float widE = (float)aFont->getStringWidth( "E" );
- float heightL = (float)aFont->getStringHeight();
-
- float xGapN = - widN/2 *( 1.0 + sin(angle) );
- float xGapS = - widS/2 *( 1.0 - sin(angle) );
- float xGapW = - widW/2 *( 1.0 + cos(angle) );
- float xGapE = - widE/2 *( 1.0 - cos(angle) );
-
- float yGapN = - heightL/2 *( 1.0 - cos(angle) ) * 0.75;
- float yGapS = - heightL/2 *( 1.0 + cos(angle) ) * 0.75;
- float yGapW = - heightL/2 *( 1.0 + sin(angle) ) * 0.75;
- float yGapE = - heightL/2 *( 1.0 - sin(angle) ) * 0.75;
-
- glGetIntegerv (GL_VIEWPORT, viewport);
- glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
- glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
-
- gluProject (centerX, centerY + cSize / yScale, 0, modelMatrix, projMatrix, viewport, &winxN, &winyN, &winz);
- gluProject (centerX + cSize / xScale, centerY, 0, modelMatrix, projMatrix, viewport, &winxE, &winyE, &winz);
- gluProject (centerX, centerY - cSize / yScale, 0, modelMatrix, projMatrix, viewport, &winxS, &winyS, &winz);
- gluProject (centerX - cSize / xScale, centerY, 0, modelMatrix, projMatrix, viewport, &winxW, &winyW, &winz);
-
- glColor3f( 1.0, 1.0, 1.0 );
-
- aTextList = glGenLists( 1 );
- glNewList( aTextList, GL_COMPILE );
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0,viewport[2],0,viewport[3],-100,100);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- aFont->drawString( "N", winxN + xGapN, winyN + yGapN );
- aFont->drawString( "E", winxE + xGapE, winyE + yGapE );
- aFont->drawString( "S", winxS + xGapS, winyS + yGapS );
- aFont->drawString( "W", winxW + xGapW, winyW + yGapW );
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-
- glEndList();
-
- if ( aTextList != -1 )
- glCallList( aTextList );
-}
-
-/*!
- \return blocking status for current started operations
-*/
-BlockStatus GLViewer_ViewPort2d::currentBlock()
-{
- if( myIsDragProcess == inDrag && myCurDragPosX != NULL && myCurDragPosY != NULL)
- return BlockStatus(BS_Highlighting | BS_Selection);
-
- if( mypFirstPoint && mypLastPoint )
- return BlockStatus(BS_Highlighting | BS_Selection);
-
- return BS_NoBlock;
-}
-
-/*!
- Initializes rectangle selection
- \param x, y - start point
-*/
-void GLViewer_ViewPort2d::startSelectByRect( int x, int y )
-{
- if( !mypFirstPoint && !mypLastPoint )
- {
- mypFirstPoint = new QPoint( x, y );
- mypLastPoint = new QPoint( x, y );
- }
-}
-
-/*!
- Draws rectangle selection
- \param x, y - current point
-*/
-void GLViewer_ViewPort2d::drawSelectByRect( int x, int y )
-{
- if( mypFirstPoint && mypLastPoint )
- {
-
- QPainter p( getPaintDevice() );
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
-
- p.drawRect( selectionRect() ); /* erase */
-
- mypLastPoint->setX( x );
- mypLastPoint->setY( y );
-
- p.drawRect( selectionRect() ); /* draw */
- }
-
-}
-
-/*!
- Finishes rectangle selection
-*/
-void GLViewer_ViewPort2d::finishSelectByRect()
-{
- if( mypFirstPoint && mypLastPoint )
- {
-
- QPainter p( getPaintDevice() );
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
-
- p.drawRect( selectionRect() ); /* erase */
-
- delete mypFirstPoint;
- delete mypLastPoint;
-
- mypFirstPoint = NULL;
- mypLastPoint = NULL;
- }
-}
-
-/*!
- \return rectangle selection
-*/
-QRect GLViewer_ViewPort2d::selectionRect()
-{
- QRect aRect;
- if( mypFirstPoint && mypLastPoint )
- {
- aRect.setLeft( QMIN( mypFirstPoint->x(), mypLastPoint->x() ) );
- aRect.setTop( QMIN( mypFirstPoint->y(), mypLastPoint->y() ) );
- aRect.setRight( QMAX( mypFirstPoint->x(), mypLastPoint->x() ) );
- aRect.setBottom( QMAX( mypFirstPoint->y(), mypLastPoint->y() ) );
- }
-
- return aRect;
-}
-
-/*!
-*/
-bool GLViewer_ViewPort2d::startPulling( GLViewer_Pnt point )
-{
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
- ObjList anObjects = aContext->getObjects();
-
- for( ObjList::Iterator it = anObjects.begin(); it != anObjects.end(); ++it )
- {
- GLViewer_Object* anObject = *it;
- GLViewer_Rect aRect = anObject->getPullingRect();
-
- if( aRect.contains( point ) && anObject->startPulling( point ) )
- {
- myIsPulling = true;
- myPullingObject = anObject;
- setCursor( *getHandCursor() );
- return true;
- }
- }
-
- return false;
-}
-
-/*!
-*/
-void GLViewer_ViewPort2d::drawPulling( GLViewer_Pnt point )
-{
- GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
- GLViewer_Context* aContext = aViewer->getGLContext();
- ObjList anObjects = aContext->getObjects();
-
- GLViewer_Object* aLockedObject = 0;
- for( ObjList::Iterator it = anObjects.begin(); it != anObjects.end(); ++it )
- {
- GLViewer_Object* anObject = *it;
- if( !anObject->getVisible() )
- continue;
-
- GLViewer_Rect aRect = anObject->getPullingRect();
-
- if( aRect.contains( point ) && anObject->portContains( point ) )
- {
- aLockedObject = anObject;
- break;
- }
- }
-
- myPullingObject->pull( point, aLockedObject );
-}
-
-/*!
-*/
-void GLViewer_ViewPort2d::finishPulling()
-{
- myIsPulling = false;
- myPullingObject->finishPulling();
- setCursor( *getDefaultCursor() );
-}
-
-/*!
- Convert rectangle in window co-ordinates to GL co-ordinates
- \return converted rectangle
-*/
-GLViewer_Rect GLViewer_ViewPort2d::win2GLV( const QRect& theRect ) const
-{
- GLViewer_Rect aRect;
-
- GLdouble modelMatrix[16], projMatrix[16];
- GLint viewport[4];
-
- GLdouble objx1, objy1;
- GLdouble objx2, objy2;
- GLdouble objz;
-
- glGetIntegerv (GL_VIEWPORT, viewport);
- glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
- glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
-
- gluUnProject( theRect.left(), viewport[3] - theRect.top(), 0, modelMatrix, projMatrix, viewport, &objx1, &objy1, &objz );
- gluUnProject( theRect.right(), viewport[3] - theRect.bottom(), 0, modelMatrix, projMatrix, viewport, &objx2, &objy2, &objz );
-
- aRect.setLeft( objx1 );
- aRect.setTop( objy1 );
- aRect.setRight( objx2 );
- aRect.setBottom( objy2 );
-
- return aRect;
-}
-
-/*!
- Convert rectangle in GL co-ordinates to window co-ordinates
- \return converted rectangle
-*/
-QRect GLViewer_ViewPort2d::GLV2win( const GLViewer_Rect& theRect ) const
-{
- QRect aRect;
-
- GLdouble modelMatrix[16], projMatrix[16];
- GLint viewport[4];
-
- GLdouble winx1, winy1;
- GLdouble winx2, winy2;
- GLdouble winz;
-
- glGetIntegerv (GL_VIEWPORT, viewport);
- glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix);
- glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
-
- gluProject( theRect.left(), theRect.top(), 0, modelMatrix, projMatrix, viewport, &winx1, &winy1, &winz );
- gluProject( theRect.right(), theRect.bottom(), 0, modelMatrix, projMatrix, viewport, &winx2, &winy2, &winz );
-
- aRect.setLeft( (int)winx1 );
- aRect.setTop( viewport[3] - (int)winy1 );
- aRect.setRight( (int)winx2 );
- aRect.setBottom( viewport[3] - (int)winy2 );
-
- return aRect;
-}
-
-/*!
- SLOT: called when tooltip should be shown
-*/
-void GLViewer_ViewPort2d::onMaybeTip( QPoint thePoint, QString& theText, QFont& theFont, QRect& theTextReg, QRect& theRegion )
-{
- GLViewer_Context* aContext = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext();
-
- GLViewer_Object* anObj = aContext->getCurrentObject();
- if( anObj )
- {
- theText = anObj->getToolTipText();
- if( theText.isEmpty() )
- theText = anObj->getName();
-
- QStringList aList;
- if( anObj->isTooTipHTML() )
- aList = QStringList::split( "<br>", theText );
- else
- aList = QStringList::split( "\n", theText );
-
- if( !aList.isEmpty() )
- {
- int index = 0;
- int str_size = aList.first().length();
- for( int i = 1, size = aList.count(); i < size; i++ )
- {
- if ( str_size < (int)aList[i].length() )
- {
- index = i;
- str_size = aList[i].length();
- }
- }
- theFont = font();
- int cur_height = 24;
- QCursor* aCursor = QApplication::overrideCursor();
- if( aCursor )
- {
- const QBitmap* aBitmap = aCursor->bitmap();
- if( aBitmap )
- cur_height = aBitmap->height();
- }
-
- //temp
- QSize aSize = QLabel( theText, 0 ).sizeHint();
- theTextReg = QRect( thePoint.x(), thePoint.y() + cur_height,
- aSize.width(), aSize.height() );
- theRegion = QRect( thePoint.x(), thePoint.y(), 1, 1 );
- }
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_ViewPort2d.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_VIEWPORT2D_H
-#define GLVIEWER_VIEWPORT2D_H
-
-#ifdef WNT
-#include <windows.h>
-#endif
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-
-#include "GLViewer_ViewPort.h"
-#include "GLViewer_Widget.h"
-#include "GLViewer_Geom.h"
-
-#include <qgl.h>
-#include <qcolor.h>
-#include <qwidget.h>
-#include <qpaintdevice.h>
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-class GLViewer_Compass;
-class GLViewer_Grid;
-class GLViewer_Object;
-class GLViewer_ViewFrame;
-
-class QtxToolTip;
-/*!
- * Class GLViewer_ViewPort
- * 2D visualisation canvas of GLViewer
- */
-class GLViewer_ViewPort2d: public GLViewer_ViewPort
-{
- Q_OBJECT
-
- //! Dragging states
- enum vpDragState{ noDrag, initDrag, inDrag };
-
-public:
- GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL );
- ~GLViewer_ViewPort2d();
-
- //! On/off rectangular grid
- void turnGrid( GLboolean on );
- //! Returns rectangular grid
- GLViewer_Grid* getGrid() const { return myGrid; }
- //! Returns grid color
- void setGridColor( const QColor gridColor, const QColor axisColor );
-
- //! Returns parent window
- GLViewer_ViewFrame* getViewFrame() const { return myViewFrame; }
- //! Returns painted widget
- GLViewer_Widget* getGLWidget() const { return myGLWidget; }
- virtual QPaintDevice* getPaintDevice() { return myGLWidget; }
-
- //! Sets background color
- void setBackgroundColor( const QColor& color);
- //! Returns background color
- QColor backgroundColor() const;
-
- //! Sets borders of scene
- void setBorder( GLViewer_Rect* border ) { myBorder = border; }
- //! Get current borders of scene
- GLViewer_Rect* getBorder() const { return myBorder; }
-
- //! Sets margin of borders
- void setMargin( GLfloat margin ) { myMargin = margin; }
- //! Returns margin of borders
- GLfloat getMargin() const { return myMargin; }
-
- //! Returns width of view
- int getWidth() const { return myWidth; }
- //! Returns height of view
- int getHeight() const { return myHeight; }
-
-
- //! Returns scale factors
- void getScale( GLfloat& xSc, GLfloat& ySc ) const { xSc = myXScale; ySc = myYScale; }
- //! returns offsets
- void getPan( GLfloat& xPan, GLfloat& yPan ) const { xPan = myXPan; yPan = myYPan; }
-
- //! Resize view
- void initResize( int width, int height );
-
- //! Begins rotation
- void startRotation( int, int );
- //! Process rotation
- void rotate( int, int );
- //! Completes rotation
- void endRotation();
-
- //! Checks of dragging process state
- bool isDragProcess(){ return myIsDragProcess; }
-
- //! On/off compass
- void turnCompass( GLboolean on );
- //! Draws compass
- void drawCompass();
-
- //! Returns unique ID of ViewPort
- int getViewPortId(){ return myViewPortId; }
-
- //! Redefined method
- virtual BlockStatus currentBlock();
-
- //! Initializes before selecting by rect
- void startSelectByRect( int x, int y );
- //! Draw selecting rectandle
- void drawSelectByRect( int x, int y );
- //! Pass rect into selector and update
- void finishSelectByRect();
-
- //! \warnign It is for ouv
- bool startPulling( GLViewer_Pnt );
- //! \warnign It is for ouv
- void drawPulling( GLViewer_Pnt );
- //! \warnign It is for ouv
- void finishPulling();
- //! \warnign It is for ouv
- bool isPulling() const { return myIsPulling; }
-
- //! Returns selection by rect
- QRect selectionRect();
-
- //! Transforms window rect to global rect
- GLViewer_Rect win2GLV( const QRect& ) const;
- //! Transforms global rect to window rect
- QRect GLV2win( const GLViewer_Rect& ) const;
-
-signals:
- //! Emits after any transformation
- void vpUpdateValues();
-
- void objectMoved();
-
-protected:
- void onDragObject( QMouseEvent* );
-
- virtual void mouseMoveEvent( QMouseEvent *);
- virtual void mousePressEvent( QMouseEvent *);
- virtual void mouseReleaseEvent( QMouseEvent *);
- virtual void mouseDoubleClickEvent( QMouseEvent *);
-
- virtual void paintEvent( QPaintEvent* );
- virtual void resizeEvent( QResizeEvent* );
-
- //! Returns view to begin state
- virtual void reset();
- //! Sets offset to view
- virtual void pan( int dx, int dy );
- //! Sets view center in global coords
- virtual void setCenter( int x, int y );
- //! Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 )
- virtual void zoom( int x0, int y0, int x1, int y1 );
- //! Transforms view by rectangle
- virtual void fitRect( const QRect& );
- //! Transforms view by selection
- virtual void fitSelect();
- //! Transform view by view borders ( if \param keepScale = true, zoom does not change )
- virtual void fitAll( bool keepScale = false, bool withZ = true );
-
-protected slots:
- //! Initializes drag process
- void onStartDragObject();
- //! Pastes object from clipboard
- void onPasteObject();
- //! Cuts object to clipboard
- void onCutObject();
- //! Copies object to clipboard
- void onCopyObject();
-
- //! Sets tool tip with \param text to \param theTextReg and on \param theViewReg whan mouse is on \param thePoint
- void onMaybeTip( QPoint thePoint, QString& text, QFont& font, QRect& theTextReg, QRect& theViewReg );
-
-protected:
- GLViewer_ViewFrame* myViewFrame;
- GLViewer_Widget* myGLWidget;
- GLViewer_Rect* myBorder;
- QColor myBackgroundColor;
-
- GLfloat myMargin;
- int myHeight;
- int myWidth;
-
- GLfloat myXScale;
- GLfloat myYScale;
- GLfloat myXOldScale;
- GLfloat myYOldScale;
- GLfloat myXPan;
- GLfloat myYPan;
-
- GLViewer_Grid* myGrid;
- GLViewer_Compass* myCompass;
-
- //dragging
- int myIsDragProcess;
- float* myCurDragPosX;
- float* myCurDragPosY;
-
- //selection by rect
- QPoint* mypFirstPoint;
- QPoint* mypLastPoint;
-
- //pulling
- bool myIsPulling;
- GLViewer_Object* myPullingObject;
-
- int myViewPortId;
-
- //GLViewer_ObjectTip* myObjectTip;
- QtxToolTip* myObjectTip;
- //! flag to block mouse release event just after mouse double-click
- bool myIsMouseReleaseBlock;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Viewer.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Viewer.h"
-#include "GLViewer_Selector.h"
-#include "GLViewer_ViewPort.h"
-#include "GLViewer_ViewFrame.h"
-
-#include "SUIT_Desktop.h"
-#include "SUIT_ViewWindow.h"
-
-#include <qapplication.h>
-#include <qpainter.h>
-#include <qpopupmenu.h>
-#include <qcolordialog.h>
-
-/* used for sketching */
-static QEvent* l_mbPressEvent = 0;
-
-/*!
- Constructor
-*/
-GLViewer_Viewer::GLViewer_Viewer( const QString& title )
-: SUIT_ViewModel(),
-mySelector( 0 ),
-mySketcher( 0 ),
-myTransformer( 0 ),
-mySelMode( NoSelection )
-{
-}
-
-/*!
- Destructor
-*/
-GLViewer_Viewer::~GLViewer_Viewer()
-{
- delete mySelector;
-}
-
-/*!
- Sets new view manager
- \param theViewManager - new view manager
-*/
-void GLViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
-{
- SUIT_ViewModel::setViewManager(theViewManager);
- if (theViewManager)
- {
- connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
- this, SLOT(onMouseEvent(SUIT_ViewWindow*, QMouseEvent*)));
-
- connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
- this, SLOT(onMouseEvent(SUIT_ViewWindow*, QMouseEvent*)));
-
- connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
- this, SLOT(onMouseEvent(SUIT_ViewWindow*, QMouseEvent*)));
-
- connect(theViewManager, SIGNAL(wheel(SUIT_ViewWindow*, QWheelEvent*)),
- this, SLOT(onWheelEvent(SUIT_ViewWindow*, QWheelEvent*)));
- }
-}
-
-/*!
- Builds popup for GL viewer
-*/
-void GLViewer_Viewer::contextMenuPopup( QPopupMenu* thePopup )
-{
- if( thePopup->count() > 0 )
- thePopup->insertSeparator();
-
- thePopup->insertItem( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
-}
-
-/*!
- Sets the background color with color selection dialog. [ virtual protected slot ]
-*/
-void GLViewer_Viewer::onChangeBgColor()
-{
- GLViewer_ViewPort* vp = getActiveView()->getViewPort();
- QColor selColor = QColorDialog::getColor( vp->backgroundColor() );
-
- if( selColor.isValid() )
- vp->setBackgroundColor( selColor );
-}
-
-/*!
- Returns the active view. [ public ]
-*/
-GLViewer_ViewFrame* GLViewer_Viewer::getActiveView() const
-{
- SUIT_ViewManager* aMgr = getViewManager();
- return (GLViewer_ViewFrame*)( aMgr != 0 ? aMgr->getActiveView() : 0 );
-}
-
-
-/*!
- Sets the selection mode for this viewer. [ public ]
-*/
-void GLViewer_Viewer::setSelectionMode( GLViewer_Viewer::SelectionMode mode )
-{
- if ( mySelMode != mode )
- {
- mySelMode = mode;
- onSelectionModeChanged();
- }
-}
-
-/*!
- Returns selector of this viewer. [ public ]
-*/
-GLViewer_Selector* GLViewer_Viewer::getSelector() const
-{
- if ( !mySelector )
- {
- GLViewer_Viewer* mthis = (GLViewer_Viewer*)this;
- mthis->mySelector = mthis->createSelector();
- if ( mySelector )
- {
- connect( mySelector, SIGNAL( selSelectionDone( bool, SelectionChangeStatus ) ), SLOT( onSelectionDone( bool, SelectionChangeStatus ) ) );
- connect( mySelector, SIGNAL( selSelectionCancel() ), SLOT( onSelectionCancel() ) );
- }
- }
- return mySelector;
-}
-
-/*!
- Returns the selection mode of this viewer. [ public ]
-*/
-GLViewer_Viewer::SelectionMode GLViewer_Viewer::getSelectionMode() const
-{
- return mySelMode;
-}
-
-/*!
- Handles requests for sketching in the active view. [ virtual public ]
-*/
-void GLViewer_Viewer::activateSketching( int type )
-{
- GLViewer_ViewPort* vp = 0;
- if ( !getActiveView() || !( vp = getActiveView()->getViewPort() ) )
- return;
-
- if ( !vp->isSketchingEnabled() )
- return;
-
- /* Finish current sketching */
- if ( type == NoSketching )
- {
- if ( mySketcher )
- {
- onSketchingFinished();
- delete mySketcher;
- mySketcher = 0;
- }
- }
- /* Activate new sketching */
- else
- {
- activateSketching( NoSketching ); /* concurrency not suported */
- mySketcher = createSketcher( type );
- onSketchingStarted();
- }
-}
-
-/*!
- Handles requests for transformations in the active view. [ virtual public ]
-*/
-void GLViewer_Viewer::activateTransform( int type )
-{
- GLViewer_ViewPort* vp = 0;
- if ( !getActiveView() || !( vp = getActiveView()->getViewPort() ) )
- return;
-
- if ( !vp->isTransformEnabled() )
- return;
-
- /* Finish current transform */
- if ( type == NoTransform )
- {
- if ( myTransformer )
- {
- onTransformationFinished();
- delete myTransformer;
- myTransformer = 0;
- }
- }
- /* Activate new transform */
- else
- {
- activateTransform( NoTransform ); /* concurrency not suported */
- myTransformer = createTransformer( type );
- onTransformationStarted();
- myTransformer->exec();
- }
-}
-
-/*!
- Creates default transformer. [ virtual protected ]
-*/
-GLViewer_ViewTransformer* GLViewer_Viewer::createTransformer( int type )
-{
- return new GLViewer_ViewTransformer( this, type );
-}
-
-/*!
- Creates default sketcher. [ virtual protected ]
-*/
-GLViewer_ViewSketcher* GLViewer_Viewer::createSketcher( int type )
-{
- return new GLViewer_ViewSketcher( this, type );
-}
-
-/*!
- Returns null by default. [ virtual protected ]
-*/
-GLViewer_Selector* GLViewer_Viewer::createSelector()
-{
- return 0;
-}
-
-/*!
- Unhilights detected entities, lock selection, sets event filter
- on the whole application. [ virtual protected ]
-*/
-void GLViewer_Viewer::onTransformationStarted()
-{
- unhilightDetected();
- if ( getSelector() )
- getSelector()->lock( true ); /* disable selection */
-
- /* Watch events: any mouse/key event outside the
- viewport will be considered as the end of
- transform */
- if( !myTransformer )
- return;
- qApp->installEventFilter( this );
-}
-
-/*!
- Unlock selection, removes event filter. [ virtual protected ]
-*/
-void GLViewer_Viewer::onTransformationFinished()
-{
- if ( getSelector() )
- getSelector()->lock( false ); /* enable selection */
-
- /* Stop watch events */
- if( !myTransformer )
- return;
- qApp->removeEventFilter( this );
-}
-
-/*!
- Unhilights detected entities. [ virtual protected ]
-*/
-void GLViewer_Viewer::onSketchingStarted()
-{
- unhilightDetected();
-}
-
-/*!
- Selection by rectangle. [ virtual protected ]
-*/
-void GLViewer_Viewer::onSketchingFinished()
-{
- if ( !getSelector() )
- return;
-
- if( !mySketcher )
- return;
- if ( mySketcher->type() == Rect )
- {
- QRect* selRect = (QRect*)mySketcher->data();
- if ( selRect )
- {
- bool append = bool( mySketcher->buttonState() & GLViewer_Selector::appendKey() );
- getSelector()->select( *selRect, append );
- }
- }
-}
-
-/*!
- Installed while 'fit area' and 'global panning' operations are active. [ virtual protected ]
-*/
-bool GLViewer_Viewer::eventFilter( QObject* o, QEvent* e )
-{
- if( !getActiveView() )
- return false;
-
- if( getActiveView()->getViewPort() == o->parent() )
- o = o->parent();
-
- bool mouseClickedOutside = ( e->type() == QEvent::MouseButtonPress &&
- o != getActiveView()->getViewPort() );
- bool anyKeyPressed = ( e->type() == QEvent::KeyPress );
- if ( mouseClickedOutside || anyKeyPressed )
- { /* terminate all */
- activateTransform( NoTransform );
- activateSketching( NoSketching );
- //cout << "mouseClickedOutside || anyKeyPressed" << endl;
- }
- return QObject::eventFilter( o, e );
-}
-
-/*!
- Called when smth is selected in this viewer. [ virtual protected slot ]
-*/
-void GLViewer_Viewer::onSelectionDone( bool bAdded, SelectionChangeStatus status )
-{
- emit selectionChanged( status );
-}
-
-/*!
- Called when selection is cleared in this viewer. [ virtual protected slot ]
-*/
-void GLViewer_Viewer::onSelectionCancel()
-{
- emit selectionChanged( SCS_Invalid );
-}
-
-/*!
- Listens to key events of the active view. [ virtual protected slot ]
-*/
-void GLViewer_Viewer::onKeyEvent( SUIT_ViewWindow*, QKeyEvent* )
-{
-}
-
-/*!
- Listens to mouse events of the active view. [ virtual protected slot ]
-*/
-void GLViewer_Viewer::onMouseEvent( SUIT_ViewWindow*, QMouseEvent* e )
-{
- //cout << "GLViewer_Viewer::onMouseEvent" << endl;
- switch( e->type() )
- {
- case QEvent::MouseButtonPress:
- handleMousePress( e );
- break;
- case QEvent::MouseMove:
- handleMouseMove( e );
- break;
- case QEvent::MouseButtonRelease:
- handleMouseRelease( e );
- break;
- default: break;
- }
-}
-
-/*!
- Listens to mouse events of the active view. [ virtual protected slot ]
-*/
-void GLViewer_Viewer::onWheelEvent( SUIT_ViewWindow*, QWheelEvent* e )
-{
- //cout << "GLViewer_Viewer::onMouseEvent" << endl;
- switch( e->type() )
- {
- case QEvent::Wheel:
- handleWheel( e );
- break;
- default: break;
- }
-}
-
-/*!
- Enables / disables rectangle sketching. [ virtual protected ]
-*/
-void GLViewer_Viewer::onSelectionModeChanged()
-{
- bool enable = ( mySelMode == Multiple );
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
- for ( int i = 0, n = views.count(); i < n; i++ )
- {
- GLViewer_ViewPort* vp = ((GLViewer_ViewFrame*)views[i])->getViewPort();
- if ( vp )
- vp->setSketchingEnabled( enable );
- }
-}
-
-/*!
- Updates all views of this viewer. Use 'flags' to customize update process. [ virtual public ]
-*/
-void GLViewer_Viewer::update( int flags )
-{
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
- for ( int i = 0, n = views.count(); i < n; i++ )
- ((GLViewer_ViewFrame*)views[i])->onUpdate( flags );
-}
-
-/*!
- Unhilights the currect detected objects. [ virtual private ]
-*/
-void GLViewer_Viewer::unhilightDetected()
-{
- if ( getSelector() )
- getSelector()->undetectAll();
-}
-
-/*!
- Mouse press handler. If 'accelKey()' is pressed, activates default
- transformations( Zoom or Pan ) in the active viewport. [ private ]
-*/
-void GLViewer_Viewer::handleMousePress( QMouseEvent* e )
-{
- /* test accel for transforms */
- if ( e->state() & GLViewer_ViewTransformer::accelKey() )
- {
- ButtonState bs = e->button();
- if ( bs == GLViewer_ViewTransformer::zoomButton() )
- activateTransform( Zoom );
- else if ( bs == GLViewer_ViewTransformer::panButton() )
- activateTransform( Pan );
- }
- else
- {
- //checking for other operations before selection in release event
- startOperations( e );
- }
-
- /* we may need it for sketching... */
- l_mbPressEvent = new QMouseEvent( *e );
-
- //checking for other operations before selection in release event
-// startOperations( e );
-
- /*e->button() == LeftButton && getSelector() )
- {
- bool append = bool ( e->state() & GLViewer_Selector::appendKey() );
- getSelector()->select( append );
- }*/
-}
-
-/*!
- Mouse move handler. If dragged with MB1, activates rectangle sketching in
- the active viewport, otherwise highlights the selectable entities. [ private ]
-*/
-void GLViewer_Viewer::handleMouseMove( QMouseEvent* e )
-{
- /* Highlight for selection */
- bool dragged = ( e->state() & ( LeftButton | MidButton | RightButton ) );
- if ( !dragged )
- {
- if ( getSelector() )
- getSelector()->detect( e->x(), e->y() );
- }
- /* Try to activate default sketching
- */
- else if ( e->state() == GLViewer_ViewSketcher::sketchButton() )
- {
- activateSketching( Rect );
- if ( mySketcher )
- {
- /* Activated OK. We should not forget initial mousepress
- event and this mousemove event to start sketching from
- the point of initial click */
- if ( l_mbPressEvent )
- {
- QApplication::sendEvent( getActiveView()->getViewPort(), l_mbPressEvent );
- delete l_mbPressEvent;
- l_mbPressEvent = 0;
- }
- QApplication::sendEvent( getActiveView()->getViewPort(), e );
- }
- }
-
- //Try to activate other operations
- updateOperations( e );
-}
-
-/*!
- Mouse move handler. Activates popup of the active view. [ private ]
-*/
-void GLViewer_Viewer::handleMouseRelease( QMouseEvent* e )
-{
- /* selection */
- /* tmp - in handleMousePress*/
- if( e->button() == LeftButton && !(getActiveView()->getViewPort()->currentBlock() & BS_Selection) )
- {
- if ( getSelector() )
- {
- bool append = bool ( e->state() & GLViewer_Selector::appendKey() );
- getSelector()->select( append );
- }
- }
-
- //Try to done active operations
- finishOperations( e );
-
- if ( l_mbPressEvent )
- {
- delete l_mbPressEvent;
- l_mbPressEvent = 0;
- }
-}
-
-/*!
- Wheel rolling handler
-*/
-void GLViewer_Viewer::handleWheel( QWheelEvent* e )
-{
- startOperations( e );
-}
-
-int GLViewer_ViewTransformer::panBtn = Qt::MidButton;
-int GLViewer_ViewTransformer::zoomBtn = Qt::LeftButton;
-int GLViewer_ViewTransformer::fitRectBtn = Qt::LeftButton;
-int GLViewer_ViewTransformer::panGlobalBtn = Qt::LeftButton;
-int GLViewer_ViewTransformer::acccelKey = Qt::ControlButton;
-
-/*!
- Constructor
-*/
-GLViewer_ViewTransformer::GLViewer_ViewTransformer( GLViewer_Viewer* v, int type )
-: QObject( 0 ),
-myViewer( v ),
-myType( type ),
-myMajorBtn( NoButton ),
-myButtonState( 0 )
-{
- if ( myType == GLViewer_Viewer::Pan ||
- myType == GLViewer_Viewer::Zoom ||
- myType == GLViewer_Viewer::PanGlobal ||
- myType == GLViewer_Viewer::FitRect )
- {
- /* 'long' transforms need this */
- initTransform( true );
- }
-}
-
-/*!
- Destructor
-*/
-GLViewer_ViewTransformer::~GLViewer_ViewTransformer()
-{
- if ( myType == GLViewer_Viewer::Pan ||
- myType == GLViewer_Viewer::Zoom ||
- myType == GLViewer_Viewer::PanGlobal ||
- myType == GLViewer_Viewer::FitRect )
- {
- /* 'long' transforms need this */
- initTransform( false );
- }
-
- //QAD_Application::getDesktop()->clearInfo();
-}
-
-/*!
- Inits long transformations ( Zoom, Pan etc ) [ protected ]
-
- Saves viewport state( cursor etc ) and installs event filter to process
- mouse events if 'init' is true. Restores viewport state if 'init' is false.
-*/
-void GLViewer_ViewTransformer::initTransform( bool init )
-{
- GLViewer_ViewPort* avp = myViewer->getActiveView()->getViewPort();
- if ( init )
- {
- mySavedCursor = avp->cursor();
- mySavedMouseTrack = avp->hasMouseTracking();
- avp->setMouseTracking( false );
- avp->installEventFilter( this );
- }
- else
- {
- avp->removeEventFilter( this );
- avp->setMouseTracking( mySavedMouseTrack );
- avp->setCursor( mySavedCursor );
- }
-}
-
-/*!
- Runs transfomation. Redefine to add your own 'instant' transforms
- ( for ex., 'FitAll' is an instant transform ). [ virtual public ]
-*/
-void GLViewer_ViewTransformer::exec()
-{
- GLViewer_ViewPort* avp = myViewer->getActiveView()->getViewPort();
- if( !avp )
- return;
-
- switch( myType )
- {
- case GLViewer_Viewer::Zoom:
- myMajorBtn = zoomButton();
- avp->setCursor( *avp->getZoomCursor() );
- break;
- case GLViewer_Viewer::Pan:
- myMajorBtn = panButton();
- avp->setCursor( *avp->getPanCursor() );
- break;
- case GLViewer_Viewer::PanGlobal:
- myMajorBtn = panGlobalButton();
- avp->setCursor( *avp->getPanglCursor() );
- avp->fitAll( true, false ); /* view is ready now */
- break;
- case GLViewer_Viewer::FitRect:
- myMajorBtn = fitRectButton();
- avp->setCursor( *avp->getHandCursor() );
- break;
- case GLViewer_Viewer::Reset:
- avp->reset(); onTransform( Fin );
- break;
- case GLViewer_Viewer::FitAll:
- avp->fitAll(); onTransform( Fin );
- break;
- case GLViewer_Viewer::FitSelect:
- avp->fitSelect(); onTransform( Fin );
- break;
- default: break;
- }
-}
-
-/*!
- Catches mouse events for the viewport. [ virtual protected ]
-*/
-bool GLViewer_ViewTransformer::eventFilter( QObject* o, QEvent* e )
-{
- switch ( e->type() )
- {
- case QEvent::MouseMove:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- {
- TransformState state = EnTrain;
- QMouseEvent* me = ( QMouseEvent* )e;
-
- myButtonState = me->state();
- if ( e->type() == QEvent::MouseButtonPress )
- myButtonState |= me->button(); /* add pressed button */
-
- int mouseOnlyState = ( myButtonState & ( LeftButton | MidButton | RightButton ) );
- if ( myStart.isNull() )
- {
- state = Debut;
- myStart = me->pos();
- myMajorBtn = mouseOnlyState;
- }
-
- if ( e->type() == QEvent::MouseButtonRelease && mouseOnlyState == myMajorBtn )
- {
- state = Fin;
- }
- myCurr = me->pos();
- onTransform( state );
- return true;
- }
- default: break;
- }
- return QObject::eventFilter( o, e );
-}
-
-/*!
- Transforms the viewport. Used for 'non-instant' transforms
- only( ex. Rotate, Pan etc ). [ virtual protected ]
-*/
-void GLViewer_ViewTransformer::onTransform( TransformState state )
-{
- GLViewer_ViewPort* avp = myViewer->getActiveView()->getViewPort();
- bool doTrsf = ( myButtonState & myMajorBtn );
- switch ( myType )
- {
- case GLViewer_Viewer::Zoom:
- if ( state != Fin && doTrsf )
- {
- avp->zoom( myStart.x(), myStart.y(), myCurr.x(), myCurr.y() );
- myStart = myCurr;
- }
- break;
- case GLViewer_Viewer::Pan:
- if ( state != Fin && doTrsf )
- {
- avp->pan( myCurr.x() - myStart.x(), myStart.y() - myCurr.y() );
- myStart = myCurr;
- }
- break;
- case GLViewer_Viewer::PanGlobal:
- {
- if ( state == Fin )
- avp->setCenter( myCurr.x(), myCurr.y() );
- break;
- }
- case GLViewer_Viewer::FitRect:
- {
- if ( doTrsf )
- {
- QRect rect( QMIN( myStart.x(), myCurr.x() ), QMIN( myStart.y(), myCurr.y() ),
- QABS( myStart.x() - myCurr.x() ), QABS( myStart.y() - myCurr.y() ) );
- if ( !rect.isEmpty() )
- {
- switch ( state )
- {
- case Fin:
- avp->fitRect( rect );
- break;
- default:
- {
- QPainter p( avp->getPaintDevice() ); // for QAD_GLWidget
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
- if ( !myDrawRect.isEmpty() )
- p.drawRect( myDrawRect ); /* erase */
- p.drawRect( rect );
- myDrawRect = rect;
- break;
- }
- }
- }
- }
- break;
- }
- default:
- break;
- }
-
- if ( state == Fin )
- myViewer->activateTransform( GLViewer_Viewer::NoTransform );
-}
-
-/*!
- Returns the type of the transformer. [ public ]
-*/
-int GLViewer_ViewTransformer::type() const
-{
- return myType;
-}
-
-
-int GLViewer_ViewSketcher::sketchBtn = LeftButton;
-
-/*!
- Constructor
-*/
-GLViewer_ViewSketcher::GLViewer_ViewSketcher( GLViewer_Viewer* viewer, int type )
-: QObject( 0 ),
-myViewer( viewer ),
-myData( 0 ),
-myType( type )
-{
- if( !myViewer )
- return;
- GLViewer_ViewPort* avp = myViewer->getActiveView()->getViewPort();
- if( !avp )
- return;
-
- mySavedCursor = avp->cursor();
- avp->setCursor( *GLViewer_ViewPort::getHandCursor() );
- avp->installEventFilter( this );
-
- if ( myType == GLViewer_Viewer::Rect )
- myData = new QRect();
-}
-
-/*!
- Destructor
-*/
-GLViewer_ViewSketcher::~GLViewer_ViewSketcher()
-{
- GLViewer_ViewPort* avp = myViewer->getActiveView()->getViewPort();
- avp->removeEventFilter( this );
- avp->setCursor( mySavedCursor );
-
- if ( myType == GLViewer_Viewer::Rect )
- delete ( QRect* ) myData;
-}
-
-/*!
- Catches mouse events for the viewport. [ virtual protected ]
-*/
-bool GLViewer_ViewSketcher::eventFilter( QObject* o, QEvent* e )
-{
- switch ( e->type() )
- {
- case QEvent::MouseMove:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- {
- SketchState state = EnTrain;
- QMouseEvent* me = (QMouseEvent*)e;
-
- myButtonState = me->state();
- if ( e->type() == QEvent::MouseButtonPress )
- myButtonState |= me->button(); /* add pressed button */
-
- if ( myStart.isNull() )
- {
- state = Debut;
- myStart = me->pos();
- }
-
- int mouseOnlyState = ( myButtonState & ( LeftButton | MidButton | RightButton ) );
- if ( e->type() == QEvent::MouseButtonRelease && mouseOnlyState == sketchButton() )
- {
- state = Fin;
- }
- myCurr = me->pos();
- onSketch( state );
- return true;
- }
- default: break;
- }
- return QObject::eventFilter( o, e );
-}
-
-/*!
- Draws in the viewport. [ virtual protected ]
-*/
-void GLViewer_ViewSketcher::onSketch( SketchState state )
-{
- GLViewer_ViewPort* avp = myViewer->getActiveView()->getViewPort();
- if( !avp )
- return;
-
- if( myType == GLViewer_Viewer::Rect )
- {
- QRect* sketchRect = ( QRect* )data();
- if ( myButtonState & sketchButton() )
- {
- QRect rect( QMIN( myStart.x(), myCurr.x() ), QMIN( myStart.y(), myCurr.y() ),
- QABS( myStart.x() - myCurr.x() ), QABS( myStart.y() - myCurr.y() ) );
- if ( !rect.isEmpty() )
- {
- QPainter p( avp );
- p.setPen( Qt::white );
- p.setRasterOp( Qt::XorROP );
- if ( !sketchRect->isEmpty() )
- p.drawRect( *sketchRect ); /* erase */
- *sketchRect = rect;
- if ( state != Fin )
- p.drawRect( *sketchRect );
- }
- }
- }
-
- if ( state == Fin )
- {
- QApplication::syncX(); /* force rectangle redrawing */
- myViewer->activateSketching( GLViewer_Viewer::NoSketching );
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Viewer.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_VIEWER_H
-#define GLVIEWER_VIEWER_H
-
-#include "GLViewer_Defs.h"
-#include "GLViewer_ViewFrame.h"
-#include <SUIT_ViewModel.h>
-
-#include <qlist.h>
-#include <qcursor.h>
-#include <qobject.h>
-#include <qpixmap.h>
-
-class GLViewer_Selector;
-class GLViewer_ViewSketcher;
-class GLViewer_ViewTransformer;
-
-class SUIT_Desktop;
-class SUIT_ViewWindow;
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_Object
- Base Viewer for GLViewer
-*/
-class GLVIEWER_API GLViewer_Viewer: public SUIT_ViewModel
-{
- Q_OBJECT
-
-public:
- enum SelectionMode { NoSelection, Single, Multiple };
- enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
- Zoom, PanGlobal, Pan, Rotate, UserTransform = 100 };
- enum SketchingType { NoSketching, Rect, UserSketching = 100 };
-
-public:
- GLViewer_Viewer( const QString& title );
- ~GLViewer_Viewer();
-
-public:
- virtual void setViewManager( SUIT_ViewManager* theViewManager );
- virtual QString getType() const { return Type(); }
- static QString Type() { return "GLViewer_ViewModel"; }
-
- virtual void contextMenuPopup( QPopupMenu* );
-
-public:
- void setSelectionMode( SelectionMode );
- SelectionMode getSelectionMode() const;
- GLViewer_Selector* getSelector() const;
-
- virtual void update( int = 0 );
-
- void activateTransform( int );
- void activateSketching( int );
-
- GLViewer_ViewFrame* getActiveView() const;
-
-signals:
- void selectionChanged( SelectionChangeStatus );
-
-protected:
- virtual void onSketchingStarted();
- virtual void onSketchingFinished();
- virtual void onTransformationStarted();
- virtual void onTransformationFinished();
- virtual void onSelectionModeChanged();
-
- virtual void unhilightDetected();
- virtual bool eventFilter( QObject*, QEvent* );
-
- /* virtual constructors */
- virtual GLViewer_ViewTransformer* createTransformer( int );
- virtual GLViewer_ViewSketcher* createSketcher( int );
- virtual GLViewer_Selector* createSelector();
-
- virtual void startOperations( QMouseEvent* ) {}
- virtual bool updateOperations( QMouseEvent* ) { return false; }
- virtual void finishOperations( QMouseEvent* ) {}
- virtual void startOperations( QWheelEvent* ) {}
-
-protected slots:
- virtual void onKeyEvent( SUIT_ViewWindow*, QKeyEvent* );
- virtual void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
- virtual void onWheelEvent( SUIT_ViewWindow*, QWheelEvent* );
-
- virtual void onSelectionCancel();
- virtual void onSelectionDone( bool add, SelectionChangeStatus status );
-
- virtual void onChangeBgColor();
-
-private:
- void handleMouseMove( QMouseEvent* );
- void handleMousePress( QMouseEvent* );
- void handleMouseRelease( QMouseEvent* );
- void handleWheel( QWheelEvent* );
-
-protected:
- GLViewer_Selector* mySelector; /* selector */
- SelectionMode mySelMode; /* current selection mode */
- GLViewer_ViewSketcher* mySketcher; /* sketch manipulator */
- GLViewer_ViewTransformer* myTransformer; /* transform manipulator */
-};
-
-class GLVIEWER_API GLViewer_ViewTransformer : public QObject
-{
-public:
- GLViewer_ViewTransformer( GLViewer_Viewer*, int type );
- ~GLViewer_ViewTransformer();
-
-public:
- /*! Returns transformer type */
- int type() const;
-
- /*! Sets/returns acceleration key ( CTRL by default ) */
- static int accelKey() { return acccelKey; }
- static void setAccelKey( int k ) { acccelKey = k; }
-
- /*! Sets/returns mouse button used for zooming ( MB1 by default ) */
- static int zoomButton() { return zoomBtn; }
- static void setZoomButton( int b ) { zoomBtn = b; }
-
- /*! Sets/returns mouse button used for panning ( MB2 by default ) */
- static int panButton() { return panBtn; }
- static void setPanButton( int b ) { panBtn = b; }
-
- /*! Sets/returns mouse button used for global pan ( MB1 by default ) */
- static int panGlobalButton() { return panGlobalBtn; }
- static void setPanGlobalButton( int b ) { panGlobalBtn = b; }
-
- /*! Sets/returns mouse button used for fit area ( MB1 by default ) */
- static int fitRectButton() { return fitRectBtn; }
- static void setFitRectButton( int b ) { fitRectBtn = b; }
-
- virtual void exec();
- virtual bool eventFilter( QObject*, QEvent* );
-
-protected:
- enum TransformState { Debut, EnTrain, Fin };
- virtual void onTransform( TransformState );
- void initTransform( bool );
-
-protected:
- static int panBtn;
- static int zoomBtn;
- static int fitRectBtn;
- static int panGlobalBtn;
-
- static int acccelKey;
-
- GLViewer_Viewer* myViewer;
- int myType;
- QCursor mySavedCursor;
- bool mySavedMouseTrack;
- QPoint myStart, myCurr;
- int myButtonState;
- QRect myDrawRect;
- int myMajorBtn;
-};
-
-class GLVIEWER_API GLViewer_ViewSketcher : public QObject
-{
-public:
- GLViewer_ViewSketcher( GLViewer_Viewer*, int type );
- ~GLViewer_ViewSketcher();
-
-public:
- /*! Returns sketcher type */
- int type() const { return myType; }
-
- /*! Returns result of sketching */
- void* data() const { return myData; }
-
- /*! Returns current state of mouse/sys kbd buttons */
- int buttonState() const { return myButtonState; }
-
- /*! Sets/returns mouse button used for sketching ( MB1 by default ) */
- static int sketchButton() { return sketchBtn; }
- static void setSketchButton( int b ) { sketchBtn = b; }
-
- virtual bool eventFilter( QObject*, QEvent* );
-
-protected:
- enum SketchState { Debut, EnTrain, Fin };
- virtual void onSketch( SketchState );
-
-protected:
- static int sketchBtn;
- GLViewer_Viewer* myViewer;
- int myType;
- void* myData;
- QCursor mySavedCursor;
- QPoint myStart, myCurr;
- int myButtonState;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Viewer2d.cxx
-// Created: November, 2004
-
-//#include <GLViewerAfx.h>
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_BaseObjects.h"
-#include "GLViewer_CoordSystem.h"
-#include "GLViewer_Context.h"
-#include "GLViewer_Drawer.h"
-#include "GLViewer_Selector2d.h"
-//#include "GLViewer_Sketcher.h"
-#include "GLViewer_ViewPort2d.h"
-
-#include "SUIT_Desktop.h"
-#include "SUIT_ViewWindow.h"
-
-#include "OSD_Timer.hxx"
-#include <TColStd_MapOfInteger.hxx>
-
-#include <qpopupmenu.h>
-#include <qpointarray.h>
-#include <qcolordialog.h>
-
-/*!
- Constructor
- \param title - viewer title
-*/
-GLViewer_Viewer2d::GLViewer_Viewer2d( const QString& title) :
-GLViewer_Viewer( title )
-{
- myGLContext = new GLViewer_Context( this );
-
- //myGLSketcher = new GLViewer_Sketcher( this );
-
- createSelector();
-
- mySelMode = GLViewer_Viewer::Multiple;
-
- myDrawers.clear();
-}
-
-/*!
- Destructor
-*/
-GLViewer_Viewer2d::~GLViewer_Viewer2d()
-{
- //myGLSketcher = 0;
- //delete myGLSketcher;
- GLViewer_TexFont::clearTextBases();
-}
-
-/*!Create new instance of view window on desktop \a theDesktop.
- *\retval SUIT_ViewWindow* - created view window pointer.
- */
-SUIT_ViewWindow* GLViewer_Viewer2d::createView( SUIT_Desktop* theDesktop )
-{
- return new GLViewer_ViewFrame( theDesktop, this );
-}
-
-/*!
- Adds item for change background color
- \param thePopup - menu
-*/
-void GLViewer_Viewer2d::addPopupItems( QPopupMenu* thePopup )
-{
- // CTH8434. "Change background color" menu item is available if there are no selected objects
- if ( getSelector() == 0 || getSelector()->numSelected() == 0 )
- {
- if( thePopup->count() > 0 )
- thePopup->insertSeparator();
- thePopup->insertItem( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
- }
-}
-
-/*!
- Changes background color
-*/
-void GLViewer_Viewer2d::onChangeBgColor()
-{
- if( !getActiveView() )
- return;
- GLViewer_ViewPort2d* vp = ( ( GLViewer_ViewPort2d* )getActiveView()->getViewPort() );
-
- QColor selColor = QColorDialog::getColor( vp->backgroundColor(), vp );
- if ( selColor.isValid() ) {
- vp->setBackgroundColor( selColor );
- }
-}
-
-/*!
- Updates colors for all drawers (does not work)
-*/
-void GLViewer_Viewer2d::updateColors( QColor colorH, QColor colorS )
-{
-// cout << "GLViewer_Viewer2d::updateColors" << endl;
-
-/*
- for ( DrawerMap::Iterator it = myDrawers.begin(); it != myDrawers.end(); ++it )
- {
- it.key()->setHColor( colorH );
- it.key()->setSColor( colorS );
- }
-*/
- /*
- ObjList anObjects = myGLContext->getObjects();
- ObjList::Iterator beginIt = anObjects.begin();
- ObjList::Iterator endIt = anObjects.end();
- for ( ObjList::Iterator it = beginIt; it != endIt; ++it )
- {
- //GLViewer_Drawer* aDrawer = (*it)->getDrawer();
- //aDrawer->setHColor( colorH );
- //aDrawer->setSColor( colorS );
- }
- */
-
-
- activateAllDrawers( TRUE );
-}
-
-/*!
- Updates rect of global scene by adding new rectangle
- \param theRect - rectangle
-*/
-void GLViewer_Viewer2d::updateBorders( GLViewer_Rect* theRect )
-{
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
- for ( int i = 0, n = views.count(); i < n; i++ )
- {
- GLViewer_Rect* border = ( ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)views[i])->getViewPort() )->getBorder();
-
- border->setLeft( QMIN( border->left(), theRect->left() ) );
- border->setRight( QMAX( border->right(), theRect->right() ) );
- border->setBottom( QMIN( border->bottom(), theRect->bottom() ) );
- border->setTop( QMAX( border->top(), theRect->top() ) );
- }
-}
-
-/*!
- Recomputes global scene rect
-*/
-void GLViewer_Viewer2d::updateBorders()
-{
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
-
- ObjList anObjects = myGLContext->getObjects();
- ObjList::Iterator beginIt = anObjects.begin();
- ObjList::Iterator endIt = anObjects.end();
- for ( int i = 0, n = views.count(); i < n; i++ )
- {
- GLViewer_Rect* border = ( ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)views[i])->getViewPort() )->getBorder();
- if ( !border )
- continue;
- border->setIsEmpty( true );
- // initialise border by default values to avoid old values
- border->setCoords( 0, 0, 0, 0 );
- for ( ObjList::Iterator it = beginIt; it != endIt; ++it )
- {
- GLViewer_Object* anObject = *it;
- GLViewer_Rect* aRect = anObject->getRect();
- if( !anObject->isSelectable() || !anObject->getVisible() )
- continue;
-
- if( border->isEmpty() )
- {
- border->setIsEmpty( false );
- border->setCoords( aRect->left(), aRect->right(), aRect->bottom(), aRect->top() );
- }
- else
- {
- border->setLeft( QMIN( border->left(), aRect->left() ) );
- border->setRight( QMAX( border->right(), aRect->right() ) );
- border->setBottom( QMIN( border->bottom(), aRect->bottom() ) );
- border->setTop( QMAX( border->top(), aRect->top() ) );
- }
- }
- }
-}
-
-/*!
- Redraws all active objects by updating all drawers in all views
-*/
-void GLViewer_Viewer2d::updateAll()
-{
- if ( !getActiveView() )
- return;
-
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
- for ( int i = 0, n = views.count(); i < n; i++ )
- ( ( GLViewer_ViewPort2d* )( ( GLViewer_ViewFrame* )views[i] )->getViewPort() )->getGLWidget()->updateGL();
-}
-
-/*!
- \param onlyUpdate is passed to method activateAllDrawers drawers
-*/
-void GLViewer_Viewer2d::updateDrawers( GLboolean update, GLfloat scX, GLfloat scY )
-{
-// cout << "GLViewer_Viewer2d::updateDrawers" << endl;
-
- //myGLContext->updateScales( scX, scY );
- //myGLSketcher->drawContour();
- activateAllDrawers( update );
-}
-
-/*!
- Activates drawers for objects from list \param theObjects only
-*/
-void GLViewer_Viewer2d::activateDrawers( QValueList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap )
-{
- //cout << "GLViewer_Viewer2d::activateDrawers " << (int)onlyUpdate << " " << (int)swap << endl;
- QValueList<GLViewer_Drawer*>::Iterator anIt = myDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator endDIt = myDrawers.end();
- for( ; anIt != endDIt; anIt++ )
- (*anIt)->clear();
-
- QValueList<GLViewer_Drawer*> anActiveDrawers;
- QValueList<GLViewer_Object*>::Iterator endOIt = theObjects.end();
-
- for( QValueList<GLViewer_Object*>::Iterator oit = theObjects.begin(); oit != endOIt; ++oit )
- {
- GLViewer_Drawer* aDrawer = (*oit)->getDrawer();
- if( !aDrawer )
- {
- anIt = myDrawers.begin();
- endDIt = myDrawers.end();
-
- for( ; anIt != endDIt; anIt++ )
- if( (*anIt)->getObjectType() == (*oit)->getObjectType() )
- {
- (*oit)->setDrawer( *anIt );
- aDrawer = *anIt;
- break;
- }
-
- if( !aDrawer )
- {
- myDrawers.append( (*oit)->createDrawer() );
- aDrawer = (*oit)->getDrawer();
- }
- }
- if ( !aDrawer )
- continue;
- aDrawer->addObject( (*oit) );
-
- int aPriority = aDrawer->getPriority();
-
- if( anActiveDrawers.findIndex( aDrawer ) != -1 )
- continue;
-
- QValueList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
- for( ; aDIt != aDEndIt; ++aDIt )
- if( (*aDIt)->getPriority() > aPriority )
- break;
-
- anActiveDrawers.insert( aDIt, aDrawer );
- }
-
- QValueList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
-
- QPtrVector<SUIT_ViewWindow> views = getViewManager()->getViews();
- for ( int i = 0, n = views.count(); i < n; i++ )
- {
- float xScale, yScale;
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)views[i])->getViewPort();
- vp->getScale( xScale, yScale );
- vp->getGLWidget()->makeCurrent();
-
- for( ; aDIt != aDEndIt; aDIt++ )
- {
- GLViewer_Drawer* aDrawer = *aDIt;
- if( aDrawer )
- aDrawer->create( xScale, yScale, onlyUpdate );
- }
-/*
- // draw border
- GLViewer_Rect* border = ( ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)views[i])->getViewPort() )->getBorder();
- (*aDIt)->drawRectangle( border, Qt::blue );
-
- QString coords = QString::number( border->left() ) + " " + QString::number( border->right() ) + " " +
- QString::number( border->bottom() ) + " " + QString::number( border->top() );
- (*aDIt)->drawText( "Border : " + coords, border->left(), border->top() + 10 / yScale,
- Qt::blue, &QFont( "Courier", 8, QFont::Normal ), 2 );
-*/
- if ( swap )
- vp->getGLWidget()->swapBuffers();
- }
-
- ( ( GLViewer_ViewPort2d* )getActiveView()->getViewPort() )->getGLWidget()->makeCurrent();
-}
-
-/*!
- Activates drawer for \param theObject
-*/
-void GLViewer_Viewer2d::activateDrawer( GLViewer_Object* theObject, bool onlyUpdate, GLboolean swap )
-{
- ObjList aList;
- aList.append( theObject );
- activateDrawers( aList, onlyUpdate, swap );
-}
-
-/*!
- \param onlyUpdate is passed to drawers
-*/
-void GLViewer_Viewer2d::activateAllDrawers( bool onlyUpdate, GLboolean swap )
-{
- if ( !getActiveView() )
- return;
-
- ObjList anActiveObjs;
- const ObjList& objs = myGLContext->getObjects();
- for( ObjList::const_iterator it = objs.begin(); it != objs.end(); ++it )
- {
- GLViewer_Object* obj = (GLViewer_Object*)(*it);
- if( obj->getVisible() )
- anActiveObjs.append( obj );
- }
-
- activateDrawers( anActiveObjs, onlyUpdate, swap );
-}
-
-/*!
- Creates set of marker
- \param theMarkersNum - number of markers
- \param theMarkersRad - radius of markers
-*/
-void GLViewer_Viewer2d::onCreateGLMarkers( int theMarkersNum, int theMarkersRad )
-{
- if ( !getActiveView() )
- return;
-
- GLViewer_MarkerSet* aMarkerSet = new GLViewer_MarkerSet( theMarkersNum, theMarkersRad );
- getGLContext()->insertObject( aMarkerSet );
-
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
- int vpWidth = vp->getWidth();
- int vpHeight = vp->getHeight();
-
- float* aXCoord = new float[ theMarkersNum ];
- float* anYCoord = new float[ theMarkersNum ];
-
- srand( 1 );
- for ( long i = 0; i < theMarkersNum; i++ )
- {
- aXCoord[i] = cos( PI * (rand() / (GLfloat)RAND_MAX) ) * ((GLfloat)vpWidth / 2.);
- anYCoord[i] = cos( PI * (rand() / (GLfloat)RAND_MAX) ) * ((GLfloat)vpHeight / 2.);
- }
-
- aMarkerSet->setXCoord( aXCoord, theMarkersNum );
- aMarkerSet->setYCoord( anYCoord, theMarkersNum );
- aMarkerSet->compute();
-
- updateBorders( aMarkerSet->getRect() );
-
- activateAllDrawers( false );
- activateTransform( GLViewer_Viewer::FitAll );
-
- delete[] aXCoord;
- delete[] anYCoord;
-}
-
-/*!
- Creates GL polyline
- \param theAnglesNum - number of angles
- \param theRadius - radius
- \param thePolylineNumber - number
-*/
-void GLViewer_Viewer2d::onCreateGLPolyline( int theAnglesNum, int theRadius, int thePolylineNumber )
-{
- if ( !getActiveView() )
- return;
-
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
- int vpWidth = vp->getWidth();
- int vpHeight = vp->getHeight();
-
- float* aXCoord = new float[ theAnglesNum ];
- float* anYCoord = new float[ theAnglesNum ];
-
- //srand( ( unsigned )time( NULL ) );
- srand( 1 );
- for( int j = 0; j < thePolylineNumber; j++)
- {
- GLViewer_Polyline* aPolyline = new GLViewer_Polyline( theAnglesNum, theRadius );
- getGLContext()->insertObject( aPolyline );
-
- float aXOffset = cos( PI * (rand() / (GLfloat)RAND_MAX) ) * ((GLfloat)vpWidth / 2.);
- float anYOffset = cos( PI * (rand() / (GLfloat)RAND_MAX) ) * ((GLfloat)vpHeight / 2.);
- for( int i = 0; i < theAnglesNum; i++ )
- {
- aXCoord[i] = cos( 2. * PI * i / theAnglesNum ) * theRadius + aXOffset;
- anYCoord[i] = sin( 2. * PI * i / theAnglesNum ) * theRadius + anYOffset;
- }
-
- aPolyline->setHighSelAll( true );
- aPolyline->setClosed( true );
- aPolyline->setXCoord( aXCoord, theAnglesNum );
- aPolyline->setYCoord( anYCoord, theAnglesNum );
- aPolyline->compute();
-
- updateBorders( aPolyline->getRect() );
- }
-
- activateAllDrawers( false );
- activateTransform( GLViewer_Viewer::FitAll );
-
- delete[] aXCoord;
- delete[] anYCoord;
-}
-
-/*!
- Creates text
- \param theStr - text string
- \param theTextNumber - number
-*/
-void GLViewer_Viewer2d::onCreateGLText( QString theStr, int theTextNumber )
-{
- if ( !getActiveView() )
- return;
-
- if( theTextNumber <= 0 )
- return;
-
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
- int vpWidth = vp->getWidth();
- int vpHeight = vp->getHeight();
-
- //srand( ( unsigned )time( NULL ) );
- srand( 1 );
- for( int j = 0; j < theTextNumber; j++)
- {
- float aXPos = cos( PI * (rand() / (GLfloat)RAND_MAX) ) * ((GLfloat)vpWidth / 2.);
- float anYPos = cos( PI * (rand() / (GLfloat)RAND_MAX) ) * ((GLfloat)vpHeight / 2.);
- QColor aColor( 255, 0, 255 );
-
- GLViewer_TextObject* aText = new GLViewer_TextObject( theStr, aXPos, anYPos, aColor );
- aText->compute();
- getGLContext()->insertObject( aText );
-
- updateBorders( aText->getRect() );
- }
-
- activateAllDrawers( false );
-}
-
-/*!
- Translates point from global CS to curreent viewer CS
- \param x, y - co-ordinates to be translated
-*/
-void GLViewer_Viewer2d::transPoint( GLfloat& x, GLfloat& y )
-{
- if ( !getActiveView() )
- return;
-
- GLfloat xScale, yScale;
- GLfloat xPan, yPan;
-
- GLViewer_ViewPort2d* curvp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
-
- curvp->getScale( xScale, yScale );
- curvp->getPan( xPan, yPan );
-
- GLfloat a = curvp->getGLWidget()->getRotationAngle() * PI / 180.;
-
- x = ( x - ( GLfloat )curvp->getWidth() / 2 ) / xScale;
- y = ( -y + ( GLfloat )curvp->getHeight() / 2 ) / yScale;
-
- GLfloat x1 = x;
- GLfloat y1 = y;
-
- x = x1 * cos(a) + y1 * sin(a);
- y = -x1 * sin(a) + y1 * cos(a);
-
- x -= xPan;
- y -= yPan;
-}
-
-/*!
- \return object rect in window CS
- \param theObject - object
-*/
-QRect* GLViewer_Viewer2d::getWinObjectRect( GLViewer_Object* theObject )
-{
- if ( !getActiveView() )
- return 0;
-
- GLfloat xScale, yScale;
- GLfloat xPan, yPan;
-
- GLViewer_ViewPort2d* curvp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
- GLfloat aWidth = curvp->getWidth();
- GLfloat aHeight = curvp->getHeight();
-
-
- curvp->getScale( xScale, yScale );
- curvp->getPan( xPan, yPan );
-
- QRect aObjRect = theObject->getRect()->toQRect();
- float aLeft = aObjRect.left() + xPan, aRight = aObjRect.right() + xPan;
- float aTop = aObjRect.top() + yPan, aBot = aObjRect.bottom() + yPan;
-
- GLfloat anAngle = curvp->getGLWidget()->getRotationAngle() * PI / 180.;
-
- QPointArray aPointArray(4);
- aPointArray[0] = QPoint( (int)(aLeft*cos(anAngle) - aTop*sin(anAngle)),
- (int)(aLeft*sin(anAngle) + aTop*cos(anAngle)) );
- aPointArray[1] = QPoint( (int)(aRight*cos(anAngle) - aTop*sin(anAngle)),
- (int)(aRight*sin(anAngle) + aTop*cos(anAngle)) );
- aPointArray[2] = QPoint( (int)(aRight*cos(anAngle) - aBot*sin(anAngle)),
- (int)(aRight*sin(anAngle) + aBot*cos(anAngle)) );
- aPointArray[3] = QPoint( (int)(aLeft*cos(anAngle) - aBot*sin(anAngle)),
- (int)(aLeft*sin(anAngle) + aBot*cos(anAngle)) );
-
- int aMinLeft = aPointArray[0].x(), aMaxRight = aPointArray[0].x(),
- aMinTop = aPointArray[0].y(), aMaxBottom = aPointArray[0].y();
- for( int i = 1; i < 4; i++ )
- {
- int x = aPointArray[i].x();
- int y = aPointArray[i].y();
- aMinLeft = QMIN( aMinLeft,x );
- aMaxRight = QMAX( aMaxRight, x );
- aMinTop = QMIN( aMinTop, y );
- aMaxBottom = QMAX( aMaxBottom, y );
- }
-
- aLeft = (aMinLeft/* + xPan*/)*xScale + aWidth / 2;
- aRight = (aMaxRight/* + xPan*/)*xScale + aWidth / 2;
-
- aTop = -( (aMaxBottom/* + yPan*/)*yScale - aHeight / 2 );
- aBot = -( (aMinTop/* + yPan*/)*yScale - aHeight / 2 );
-
- QRect* newRect = new QRect( (int)aLeft, (int)aTop, (int)(aRight-aLeft), (int)(aBot-aTop) );
-
- return newRect;
-}
-
-/*!
- Translates rect in window CS to rect in global CS
- \param theRect - rectangle to be translated
- \return transformed rect
-*/
-GLViewer_Rect GLViewer_Viewer2d::getGLVRect( const QRect& theRect ) const
-{
- if ( !getActiveView() )
- return GLViewer_Rect();
-
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
-
- if( !vp )
- return GLViewer_Rect();
-
- return vp->win2GLV( theRect );
-}
-
-/*!
- Translates rect in global CS to rect in window CS
- \param theRect - rectangle to be translated
- \return transformed rect
-*/
-QRect GLViewer_Viewer2d::getQRect( const GLViewer_Rect& theRect ) const
-{
- if ( !getActiveView() )
- return QRect();
-
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )getActiveView()->getViewPort();
-
- if( !vp )
- return QRect();
-
- return vp->GLV2win( theRect );
-}
-
-/*!
- \return new selector
-*/
-GLViewer_Selector* GLViewer_Viewer2d::createSelector()
-{
- return new GLViewer_Selector2d( this, getGLContext() );
-}
-
-/*!
- \return new Transformer
- \param type - type of new transformer
-*/
-GLViewer_ViewTransformer* GLViewer_Viewer2d::createTransformer( int type )
-{
- return new GLViewer_View2dTransformer( this, type );
-}
-
-/*!
- Custom mouse event handler
-*/
-void GLViewer_Viewer2d::onMouseEvent( SUIT_ViewWindow*, QMouseEvent* e )
-{
- if ( !getActiveView() )
- return;
-
- //if ( testRotation( e ) )
- // return;
-
- switch( e->type() )
- {
- case QEvent::MouseButtonPress :
- case QEvent::MouseMove :
- case QEvent::MouseButtonRelease :
- //if( myGLSketcher->getType() != None )
- // myGLSketcher->sketch( e );
- default: break;
- }
-
- GLViewer_Viewer::onMouseEvent( 0, e );
-}
-
-/*!
- Rotation transformation
-*/
-bool GLViewer_Viewer2d::testRotation( QMouseEvent* e )
-{
- if ( ( e->button() == GLViewer_View2dTransformer::rotateButton() ) &&
- ( e->type() == QEvent::MouseButtonPress ) &&
- ( e->state() & GLViewer_ViewTransformer::accelKey() ) )
- {
- activateTransform( GLViewer_Viewer::Rotate );
- return true;
- }
- return false;
-}
-
-/*!
- Inserts text lines as header for file
- \param aType - file type
- \param hFile - file instance
-*/
-void GLViewer_Viewer2d::insertHeader( VectorFileType aType, QFile& hFile )
-{
- if( aType == POST_SCRIPT )
- {
- QString header = "%!PS-Adobe-3.0\n";
- header += "%%Creator: OpenCascade 2004\n";
- header += "%%Title: Our document\n";
- header += "%%PageOrder: Ascend\n";
- header += "%%Orientation: Portrait\n";
- header += "%%LanguageLevel: 2\n";
-
- header += "%%Pages: 1\n";
- header += "%%Page: 1\n\n";
-
- hFile.writeBlock( header.ascii(), header.length() );
- }
- else if( aType == HPGL )
- {
- QString header = "[Esc].(;\n";
- header += "[Esc].I81;;17:\n";
- header += "[Esc].N;19:\n";
- header += "IN;\n";
- header += "SC;\n";
- header += "PU;\n";
- header += "SP1;\n";
- header += "LT;\n";
- header += "VS36;\n";
-
- hFile.writeBlock( header.ascii(), header.length() );
- }
-}
-
-/*!
- Inserts text lines as ending for file
- \param aType - file type
- \param hFile - file instance
-*/
-void GLViewer_Viewer2d::insertEnding( VectorFileType aType, QFile& hFile )
-{
- if( aType == POST_SCRIPT )
- {
- QString ending = "showpage\n\n%%EOF";
- hFile.writeBlock( ending.ascii(), ending.length() );
- }
- else if( aType == HPGL )
- {
- QString ending = "PU;PA0,0;SP;EC;PG1;EC1;OE\n";
- hFile.writeBlock( ending.ascii(), ending.length() );
- }
-}
-
-inline void mm2custom( GLViewer_Viewer2d::VectorFileType aType, double& value )
-{
- if( aType==GLViewer_Viewer2d::POST_SCRIPT )
- value*=2.8346; //mm to pt
-
- else if( aType==GLViewer_Viewer2d::HPGL )
- value*=40; //mm to plu (there are 40 plues in mm)
-#ifdef WIN32
- else if( aType==GLViewer_Viewer2d::ENH_METAFILE )
- value*=100; //this unit is 1/100 mm
-#endif
-}
-
-/*!
- Translates current view content to vector file
- \param aType - type of file
- \param FileName - name of file,
- \param aPType - paper size type
- \param mmLeft, mmRight, mmTop, mmBottom - margins
-*/
-bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, PaperType aPType,
- double mmLeft, double mmRight, double mmTop, double mmBottom )
-{
- if ( !getActiveView() )
- return false;
-
- QFile hFile( FileName.ascii() );
-
-#ifdef WIN32
- HDC hMetaFileDC;
-#endif
-
- GLViewer_ViewPort2d* aCurVP = (GLViewer_ViewPort2d*) getActiveView()->getViewPort();
-
- GLfloat xPan, yPan;
- aCurVP->getPan( xPan, yPan );
- GLfloat aRotation = aCurVP->getGLWidget()->getRotationAngle() * 3.14159265 / 180.0;
-
- GLViewer_CoordSystem aViewerCS( GLViewer_CoordSystem::Cartesian, xPan, yPan, 1.0, 1.0, aRotation );
-
- double AW = Sizes[2*int(aPType)],
- AH = Sizes[2*int(aPType)+1]; //size of Axx paper in mm
-
- mm2custom( aType, mmLeft ); //we translate mm to custom units
- mm2custom( aType, mmRight );
- mm2custom( aType, mmTop );
- mm2custom( aType, mmBottom );
- mm2custom( aType, AW );
- mm2custom( aType, AH );
-
- float xScale, yScale;
- aCurVP->getScale( xScale, yScale );
-
- double VPWidth = aCurVP->getWidth()/xScale, //the width in reference units
- VPHeight = aCurVP->getHeight()/yScale;
-
- double k1 = ( AW-mmLeft-mmRight ) / VPWidth,
- k2 = ( AH-mmTop-mmBottom ) / VPHeight;
-
- if( k1>k2 )
- k1 = k2; //We select the minimum
-
- double hdelta = ( AW-mmLeft-mmRight - VPWidth * k1 )/2.0, //addition in horizontal
- vdelta = ( AH-mmTop-mmBottom - VPHeight * k1 )/2.0; //addition in vertical
-
- mmLeft += hdelta; //The real free space on the left and right borders
- mmRight += hdelta;
- mmTop += vdelta;
- mmBottom += vdelta;
-
- GLViewer_CoordSystem aPaperCS( GLViewer_CoordSystem::Cartesian,
- -(mmLeft/k1+VPWidth/2.0), -(mmBottom/k1+VPHeight/2.0), 1/k1, 1/k1 );
-
- if( aType==POST_SCRIPT || aType==HPGL )
- {
- hFile.open( IO_ReadWrite | IO_Truncate );
- hFile.at( 0 );
- insertHeader( aType, hFile );
- }
-#ifdef WIN32
- else if( aType==ENH_METAFILE )
- {
- RECT r;
- r.left = 0; r.right = AW;
- r.top = 0; r.bottom = AH;
- HDC screen_dc = GetDC( 0 ); //The screen device context
- HDC bitDC = CreateCompatibleDC ( screen_dc ); //The context compatible with screen
-
- hMetaFileDC = CreateEnhMetaFile( bitDC, FileName.ascii(), &r, "" );
- SetMapMode( hMetaFileDC, MM_HIMETRIC );
- SetWindowOrgEx( hMetaFileDC, 0, r.bottom, NULL );
- HRGN ClipRgn = CreateRectRgn( 0, 0, AW, AH );
- SelectClipRgn( hMetaFileDC, ClipRgn );
-
- LOGBRUSH aBrushData;
- aBrushData.lbColor = RGB( 255, 255, 255 );
- aBrushData.lbStyle = BS_SOLID;
-
- FillRect( hMetaFileDC, &r, CreateBrushIndirect( &aBrushData ) );
-
- ReleaseDC( 0, screen_dc );
- DeleteDC( bitDC );
-
- aCurVP->getGLWidget()->translateBackgroundToEMF( hMetaFileDC, &aViewerCS, &aPaperCS );
- }
-#endif
-
- if( aType==POST_SCRIPT )
- {
- QString temp = "%1 %2 %3 %4 rectclip\n\n",
- aBuffer = temp.arg( mmLeft ).arg( mmBottom ).
- arg( AW-mmLeft-mmRight ).arg( AH-mmBottom-mmTop );
- //It is set clipping path
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
-
- aCurVP->getGLWidget()->translateBackgroundToPS( hFile, &aViewerCS, &aPaperCS );
- }
-
- bool result = true;
- for( int i=0, n=myDrawers.count(); i<n; i++ )
- if( aType==POST_SCRIPT )
- result &= myDrawers[ i ]->translateToPS( hFile, &aViewerCS, &aPaperCS );
- else if( aType==HPGL )
- result &= myDrawers[ i ]->translateToHPGL( hFile, &aViewerCS, &aPaperCS );
-#ifdef WIN32
- else if( aType==ENH_METAFILE )
- result &= myDrawers[ i ]->translateToEMF( hMetaFileDC, &aViewerCS, &aPaperCS );
-#endif
-
- if( aType==POST_SCRIPT || aType==HPGL )
- {
- insertEnding( aType, hFile);
- hFile.close();
- }
-#ifdef WIN32
- else if( aType==ENH_METAFILE )
- DeleteEnhMetaFile( CloseEnhMetaFile( hMetaFileDC ) );
-#endif
-
- return true;
-}
-
-/*!
- Repaints view
- \param theView - view to be repainted. If it is NULL then all views will be repainted
-*/
-void GLViewer_Viewer2d::repaintView( GLViewer_ViewFrame* theView, bool makeCurrent )
-{
- GLViewer_ViewFrame* aCurView;
- if( !theView )
- aCurView = (GLViewer_ViewFrame*)getActiveView();
- else
- aCurView = theView;
-
- if ( !aCurView )
- return;
-
- ObjList anActiveObjs;
- const ObjList& objs = myGLContext->getObjects();
- for( ObjList::const_iterator it = objs.begin(); it != objs.end(); ++it )
- {
- GLViewer_Object* obj = (GLViewer_Object*)(*it);
- if( obj->getVisible() )
- anActiveObjs.append( obj );
- }
-
- float xScale;
- float yScale;
-
- QValueList<GLViewer_Drawer*>::Iterator anIt = myDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator endDIt = myDrawers.end();
- for( ; anIt != endDIt; anIt++ )
- (*anIt)->clear();
-
- QValueList<GLViewer_Drawer*> anActiveDrawers;
- QValueList<GLViewer_Object*>::Iterator endOIt = anActiveObjs.end();
-
- for( QValueList<GLViewer_Object*>::Iterator oit = anActiveObjs.begin(); oit != endOIt; ++oit )
- {
- GLViewer_Drawer* aDrawer = (*oit)->getDrawer();
- if( !aDrawer )
- {
- anIt = myDrawers.begin();
-
- for( ; anIt != endDIt; anIt++ )
- if( (*anIt)->getObjectType() == (*oit)->getObjectType() )
- {
- (*oit)->setDrawer( *anIt );
- aDrawer = *anIt;
- break;
- }
-
- if( !aDrawer ) //are not exists
- {
- myDrawers.append( (*oit)->createDrawer() );
- aDrawer = (*oit)->getDrawer();
- }
- }
- aDrawer->addObject( (*oit) );
- if( anActiveDrawers.findIndex( aDrawer ) == -1 )
- anActiveDrawers.append( aDrawer );
- }
-
- QValueList<GLViewer_Drawer*>::Iterator aDIt = anActiveDrawers.begin();
- QValueList<GLViewer_Drawer*>::Iterator aDEndIt = anActiveDrawers.end();
-
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )aCurView->getViewPort();
- vp->getScale( xScale, yScale );
-
- if( makeCurrent )
- vp->getGLWidget()->makeCurrent();
-
- for( ; aDIt != aDEndIt; aDIt++ )
- (*aDIt)->create( xScale, yScale, false );
-
-// if ( swap )
- vp->getGLWidget()->swapBuffers();
-
-// ( ( GLViewer_ViewPort2d* )getActiveView()->getViewPort() )->getGLWidget()->makeCurrent();
-}
-
-/*!
- Starts some operation on mouse event
-*/
-void GLViewer_Viewer2d::startOperations( QMouseEvent* e )
-{
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
-
- float x = e->pos().x();
- float y = e->pos().y();
- transPoint( x, y );
- GLViewer_Pnt point( x, y );
-
- if( e->button() == Qt::LeftButton && !myGLContext->getCurrentObject() && vp->startPulling( point ) )
- return;
-
- if( e->button() == Qt::LeftButton && !(vp->currentBlock() & BS_Selection) && !myGLContext->getCurrentObject() )
- vp->startSelectByRect( e->x(), e->y() );
-}
-
-/*!
- Updates started operation on mouse event
-*/
-bool GLViewer_Viewer2d::updateOperations( QMouseEvent* e )
-{
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
-
- if( vp->isPulling() )
- {
- float x = e->pos().x();
- float y = e->pos().y();
- transPoint( x, y );
-
- vp->drawPulling( GLViewer_Pnt( x, y ) );
- updateAll();
- return true;
- }
-
- if( !myGLContext->getCurrentObject() )
- {
- vp->drawSelectByRect( e->x(), e->y() );
- return true;
- }
- return false;
-}
-
-/*!
- Completes started operation on mouse event
-*/
-void GLViewer_Viewer2d::finishOperations( QMouseEvent* e )
-{
- GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort();
-
- if( vp->isPulling() )
- {
- vp->finishPulling();
- updateAll();
- return;
- }
-
- if( !myGLContext->getCurrentObject() )
- {
- QRect aSelRect = vp->selectionRect();
- vp->finishSelectByRect();
- if ( getSelector() && !aSelRect.isNull() )
- {
- bool append = bool ( e->state() & GLViewer_Selector::appendKey() );
- getSelector()->select( aSelRect, append );
- }
- }
-}
-
-/*!
- Starts some operation on mouse wheel event
-*/
-void GLViewer_Viewer2d::startOperations( QWheelEvent* e )
-{
- bool zoomIn = e->delta() > 0;
- bool update = false;
- for( myGLContext->InitSelected(); myGLContext->MoreSelected(); myGLContext->NextSelected() )
- {
- GLViewer_Object* anObject = myGLContext->SelectedObject();
- update = anObject->updateZoom( zoomIn ) || update;
- }
-
- emit wheelZoomChange( zoomIn );
-
- if( update )
- updateAll();
-}
-
-
-int GLViewer_View2dTransformer::rotateBtn = RightButton;
-
-/*!
- Constructor
-*/
-GLViewer_View2dTransformer::GLViewer_View2dTransformer( GLViewer_Viewer* viewer, int typ )
-: GLViewer_ViewTransformer( viewer, typ )
-{
- if ( type() == GLViewer_Viewer::Rotate )
- initTransform( true );
-}
-
-/*!
- Destructor
-*/
-GLViewer_View2dTransformer::~GLViewer_View2dTransformer()
-{
- if ( type() == GLViewer_Viewer::Rotate )
- initTransform( false );
-}
-
-/*!
- Redefined to provide specific 3D transfomations. [ virtual public ]
-*/
-void GLViewer_View2dTransformer::exec()
-{
- if ( !myViewer->getActiveView() )
- return;
-
- /* additional transforms */
- GLViewer_ViewPort* vp = myViewer->getActiveView()->getViewPort();
- GLViewer_ViewPort2d* avp = (GLViewer_ViewPort2d*)vp;
- switch ( myType )
- {
- case GLViewer_Viewer::Rotate:
- myMajorBtn = rotateButton();
- avp->setCursor( *avp->getRotCursor() );
- break;
- default:
- GLViewer_ViewTransformer::exec();
- }
-}
-
-/*!
- Handles rotation. [ protected virtual ]
-*/
-void GLViewer_View2dTransformer::onTransform( TransformState state )
-{
- if ( !myViewer->getActiveView() )
- return;
-
- GLViewer_ViewPort* vp = myViewer->getActiveView()->getViewPort();
- GLViewer_ViewPort2d* avp = (GLViewer_ViewPort2d*)vp;
- if ( type() == GLViewer_Viewer::Rotate )
- {
- switch ( state )
- {
- case Debut:
- if ( myButtonState & myMajorBtn )
- avp->startRotation( myStart.x(), myStart.y() );
- break;
- case EnTrain:
- if ( myButtonState & myMajorBtn )
- avp->rotate( myCurr.x(), myCurr.y() );
- break;
- case Fin:
- avp->endRotation();
- break;
- default: break;
- }
- }
- GLViewer_ViewTransformer::onTransform( state );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Viewer2d.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_VIEWER2D_H
-#define GLVIEWER_VIEWER2D_H
-
-#ifdef WNT
-#include <windows.h>
-#endif
-
-#include <qmap.h>
-#include <qrect.h>
-
-#include "GLViewer_Viewer.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_ViewFrame.h"
-#include "GLViewer_Drawer.h"
-
-#include <TColStd_SequenceOfInteger.hxx>
-
-#include <GL/gl.h>
-
-class GLViewer_Object;
-class GLViewer_Context;
-class GLViewer_Selector2d;
-//class GLViewer_Sketcher;
-
-class SUIT_Desktop;
-class SUIT_ViewWindow;
-
-//! Paper sizes array
-const double Sizes[2*5] = {
- /* A1 */ 594.0, 840.0,
- /* A2 */ 420.0, 594.0,
- /* A3 */ 297.0, 420.0,
- /* A4 */ 210.0, 297.0,
- /* A5 */ 148.5, 210.0
-};
-
-#ifdef WNT
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- \class GLViewer_Viewer2d
- OpenGL Viewer 2D
-*/
-
-class GLVIEWER_API GLViewer_Viewer2d : public GLViewer_Viewer
-{
- Q_OBJECT
-
-public:
- //! Type of sketcher operation
- enum GLSketchingType
- {
- None,
- Polyline,
- Arc,
- Curve,
- Scribble,
- Oval,
- Rectangle
- };
- //! Type of export vector file
- enum VectorFileType
- {
- POST_SCRIPT,
- HPGL
-#ifdef WIN32
- , ENH_METAFILE
-#endif
- };
-
- //! Type of paper for export to vector format
- enum PaperType
- {
- A1=0,
- A2,
- A3,
- A4,
- A5
- };
-
-public:
- //! A constructor
- GLViewer_Viewer2d( const QString& title );
- //! A destructor
- ~GLViewer_Viewer2d();
-
-public:
- //! Redefined method
- /*Returns GLViewer_ViewFrame*/
- virtual SUIT_ViewWindow* createView( SUIT_Desktop* );
-
- //! Adds item for change background color
- void addPopupItems( QPopupMenu* );
-
- //void activateGLSketching( int );
-
- //! Returns all drawers
- const QValueList<GLViewer_Drawer*>& getDrawers() const { return myDrawers; }
-
- //! Returns context
- GLViewer_Context* getGLContext() const { return myGLContext; }
- //! Updates colors for all drawers (does not work)
- void updateColors( QColor colorH, QColor colorS );
-
- //! Updates rect of global scene by adding new rect
- void updateBorders( GLViewer_Rect* theRect );
- //! Recomputes global scene rect
- void updateBorders();
-
- //! Redraws all active objects by updating all drawers in all views
- void updateAll();
- //! Updates all drawers with new scale factor
- /* \param onlyUpdate is passed to method activateAllDrawersdrawers*/
- void updateDrawers( GLboolean onlyUpdate, GLfloat scX = 0.0, GLfloat scY = 0.0 );
- //! Activates drawers for objects from list \param theObjects only
- void activateDrawers( QValueList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE );
- //! Activates drawer for \param theObject
- void activateDrawer( GLViewer_Object* theObject, bool onlyUpdate, GLboolean swap = GL_FALSE );
- //! Updates all drawers with new scale factor
- /* \param onlyUpdate is passed to drawers*/
- void activateAllDrawers( bool onlyUpdate, GLboolean swap = GL_FALSE );
-
- //! Translates point (x,y) from global CS to curreent viewer CS
- void transPoint( GLfloat& x, GLfloat& y );
- //! Returns object rect in window CS
- QRect* getWinObjectRect( GLViewer_Object* theObject);
-
- //! Translates rect in window CS to rect in global CS
- GLViewer_Rect getGLVRect( const QRect& ) const;
- //! Translates rect in global CS to rect in window CS
- QRect getQRect( const GLViewer_Rect& ) const;
-
- //! Inserts common text lines starting file of \param aType
- virtual void insertHeader( VectorFileType aType, QFile& hFile );
- //! Inserts common text lines ending file of \param aType
- virtual void insertEnding( VectorFileType aType, QFile& hFile );
- //! Translates current view content to vector file
- /* Translates current view content to vector file with type \param aType, name \param FileName,
- * output paper size \param aPType, with margins in mm
- */
- virtual bool translateTo( VectorFileType aType, QString FileName, PaperType aPType,
- double mmLeft, double mmRight, double mmTop, double mmBottom );
-
- //bool isSketchingActive();
- //int getSketchingType();
-
- //virtual void startSketching();
- //virtual void finishSketching();
-
- //! Repaints view \param theView. If \param theView = NULL repaints all views.
- void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false );
-
-signals:
- //! Signal needs for optimum recompute of zoom depending objects
- //! Warning: use recompute without update viewer
- void wheelZoomChange( bool );
-
-public slots:
- //void onSketchDelObject();
- //void onSketchUndoLast();
- //void onSketchFinish();
-
- //! Changes background color
- void onChangeBgColor();
- //! Creates set of marker number \param number and radius = \param size
- void onCreateGLMarkers( int number = 1000, int size = 5 );
- //! Creates set of polyline number \param number, number of angles = \param angles and diameter = \param size
- void onCreateGLPolyline( int number = 100, int angles = 10, int size = 100 );
- //! Creates set of text number \param number and with text = \param text
- void onCreateGLText( QString text = "Text", int number = 1 );
-
-protected:
- //! Returns new selector
- GLViewer_Selector* createSelector();
- //! Returns new Transformer with type \param type
- GLViewer_ViewTransformer* createTransformer( int type);
-
- //! Transforms point (x,y) in Viewer CS to Post Script CS
- void transformCoordsToPS( double& x, double& y );
- //! Transforms point (x,y) in Viewer CS to HPGL CS
- void transformCoordsToHPGL( double& x, double& y );
-
- //! Starts any operations on mouse event
- virtual void startOperations( QMouseEvent* );
- //! Updates started operations on mouse event
- virtual bool updateOperations( QMouseEvent* );
- //! Completes started operations on mouse event
- virtual void finishOperations( QMouseEvent* );
- //! Starts any operations on mouse wheel event
- virtual void startOperations( QWheelEvent* );
-
-protected slots:
- void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
-
-private:
- //! Rotation transformation
- bool testRotation( QMouseEvent* );
-protected:
- //! Current context
- GLViewer_Context* myGLContext;
- //! Map of active drawers
- QValueList<GLViewer_Drawer*> myDrawers;
-
- //GLViewer_Sketcher* myGLSketcher;
-};
-
-class GLVIEWER_API GLViewer_View2dTransformer : public GLViewer_ViewTransformer
-{
-public:
- GLViewer_View2dTransformer( GLViewer_Viewer*, int );
- ~GLViewer_View2dTransformer();
-
- virtual void exec();
-
- /*! Sets/returns mouse butto which will be used for rotation ( MB1 by default ) */
- static int rotateButton() { return rotateBtn; }
- static void setRotateButton( int b ) { rotateBtn = b; }
-
-protected:
- void onTransform( TransformState );
-
- static int rotateBtn;
-};
-
-#ifdef WNT
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Widget.cxx
-// Created: November, 2004
-
-#include "GLViewer_Widget.h"
-#include "GLViewer_ViewPort2d.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_Compass.h"
-#include "GLViewer_Grid.h"
-#include "GLViewer_Object.h"
-#include "GLViewer_CoordSystem.h"
-
-#include <cmath>
-using namespace std;
-
-#include <qevent.h>
-#include <qrect.h>
-
-#include <qpixmap.h>
-#include <qimage.h>
-#include <qapplication.h>
-#include <qintdict.h>
-#include <qpaintdevicemetrics.h>
-#include <qsize.h>
-#include <qtooltip.h>
-
-/*!
- A constructor
- Parameters using for QOGLWidget as is
-*/
-GLViewer_Widget::GLViewer_Widget( QWidget* parent, const char* name ):
-QGLWidget( parent, 0/*, WRepaintNoErase | WResizeNoErase*/ )
-{
- myViewPort = ( GLViewer_ViewPort2d* )parent;
-
- myXPan = 0.0;
- myYPan = 0.0;
- myZPan = 0.0;
- myXScale = 1.0;
- myYScale = 1.0;
- myZScale = 1.0;
- myRotationAngle = 0.0;
- myRotationCenterX = 0.0;
- myRotationCenterY = 0.0;
- myRotationCenterZ = 1.0;
- myRotationAnglePrev = 0.0;
-
- myStart = GL_TRUE;
-
- isExportMode = false;
-
- //init();
- setMouseTracking( true );
-}
-
-/*!
- Destructor
-*/
-GLViewer_Widget::~GLViewer_Widget()
-{
-}
-
-/*!
- \return offset parameters of Window in OpenGL global scene
-*/
-void GLViewer_Widget::getPan( GLfloat& xPan, GLfloat& yPan, GLfloat& zPan )
-{
- xPan = myXPan;
- yPan = myYPan;
- zPan = myZPan;
-}
-
-/*!
- A function for installing the offset parameters of Window in OpenGL global scene
-*/
-void GLViewer_Widget::setPan( GLfloat xPan, GLfloat yPan, GLfloat zPan )
-{
- myXPan = xPan;
- myYPan = yPan;
- myZPan = zPan;
-}
-
-/*!
- \return scales on OpenGL scene along 3 directions in 2d scene zScale = 1.0
-*/
-void GLViewer_Widget::getScale( GLfloat& xScale, GLfloat& yScale, GLfloat& zScale )
-{
- xScale = myXScale;
- yScale = myYScale;
- zScale = myZScale;
-}
-
-/*!
- A function for installing the scales of OpenGL scene
-*/
-void GLViewer_Widget::setScale( GLfloat xScale, GLfloat yScale, GLfloat zScale )
-{
- if ( xScale > 0 && yScale > 0 && zScale > 0 )
- {
- myXScale = xScale;
- myYScale = yScale;
- myZScale = zScale;
- }
-}
-
-/*!
- \return start point of curren rotation of Window in OpenGL global scene
-*/
-void GLViewer_Widget::getRotationStart( GLfloat& rotationStartX,
- GLfloat& rotationStartY,
- GLfloat& rotationStartZ )
-{
- rotationStartX = myRotationStartX;
- rotationStartY = myRotationStartY;
- rotationStartZ = myRotationStartZ;
-}
-
-/*!
- A function for installing the rotation angle of Window in OpenGL global scene in degree (Only in 2D)
-*/
-void GLViewer_Widget::setRotationStart( GLfloat rotationStartX,
- GLfloat rotationStartY,
- GLfloat rotationStartZ )
-{
- myRotationStartX = rotationStartX;
- myRotationStartY = rotationStartY;
- myRotationStartZ = rotationStartZ;
-}
-
-/*!
- \return parameters of rotation
- \param rotationAngle - angle
- \param rotationCenterX - center x
- \param rotationCenterY - center y
- \param rotationCenterZ - center z
-*/
-void GLViewer_Widget::getRotation( GLfloat& rotationAngle,
- GLfloat& rotationCenterX,
- GLfloat& rotationCenterY,
- GLfloat& rotationCenterZ )
-{
- rotationAngle = myRotationAngle;
- rotationCenterX = myRotationCenterX;
- rotationCenterY = myRotationCenterY;
- rotationCenterZ = myRotationCenterZ;
-}
-
-/*!
- Sets parameters of rotation
- \param rotationAngle - angle
- \param rotationCenterX - center x
- \param rotationCenterY - center y
- \param rotationCenterZ - center z
-*/
-void GLViewer_Widget::setRotation( GLfloat rotationAngle,
- GLfloat rotationCenterX,
- GLfloat rotationCenterY,
- GLfloat rotationCenterZ )
-{
- myRotationAngle = rotationAngle;
- myRotationCenterX = rotationCenterX;
- myRotationCenterY = rotationCenterY;
- myRotationCenterZ = rotationCenterZ;
-}
-
-
-/*!
- Sets image as background
- \param filename - name of file
-*/
-void GLViewer_Widget::setBackground( QString filename )
-{
-
- //get image
- QImage buf;
- if ( !filename.isEmpty() && buf.load( filename ) )
- { // Load first image from file
- isLoadBackground = true;
- myBackgroundFile = filename;
-
- myIW = buf.width();
- myIH = buf.height();
-
- myBackgroundSize = 64;
- while( myBackgroundSize < myIW || myBackgroundSize < myIH)
- myBackgroundSize = myBackgroundSize * 2;
-
- GLubyte* pixels = new GLubyte[myBackgroundSize * myBackgroundSize * 4];
-
- for( int i = 0; i < myBackgroundSize; i++ )
- {
- for( int j = 0; j < myBackgroundSize; j++ )
- {
- if( j < myIW && i < myIH )
- {
- pixels[i * myBackgroundSize * 4 + j * 4] = (GLubyte)qRed( buf.pixel(j,myIH - i - 1) );
- pixels[i * myBackgroundSize * 4 + j * 4 + 1]= (GLubyte)qGreen( buf.pixel(j,myIH - i - 1) );
- pixels[i * myBackgroundSize * 4 + j * 4 + 2] = (GLubyte)qBlue( buf.pixel(j,myIH - i - 1) );
- }
- else
- {
- pixels[i * myBackgroundSize * 4 + j * 4] = (GLubyte)0;
- pixels[i * myBackgroundSize * 4 + j * 4 + 1] = (GLubyte)0;
- pixels[i * myBackgroundSize * 4 + j * 4 + 2] = (GLubyte)0;
- }
- pixels[i * myBackgroundSize* 4 + j * 4 + 3] = (GLubyte)255;
- }
- }
-
- //initialize texture
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glGenTextures(1, &texName);
- glBindTexture(GL_TEXTURE_2D, texName);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myBackgroundSize , myBackgroundSize, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- pixels);
-
- delete[] pixels;
- }
-}
-
-/*!
- Adds tooltip
- \param theString - tooltip text
- \param theRect - tooltip rectangle
-*/
-void GLViewer_Widget::addToolTip( QString theString, QRect theRect )
-{
- myToolTipRect = theRect;
- QToolTip::add( this, myToolTipRect, theString );
-}
-
-/*!
- Removes tooltip
-*/
-void GLViewer_Widget::removeToolTip()
-{
- QToolTip::remove( this, myToolTipRect );
-}
-
-/*!
- Initialization (redefined virtual from QGLWidget)
-*/
-void GLViewer_Widget::initializeGL()
-{
- setAutoBufferSwap( true );
-
- glShadeModel(GL_FLAT);
-
- //get image
- QImage buf;
- QString aPicturePath = getenv("GLViewer__Background_Picture");
-
- if ( !aPicturePath.isEmpty() && buf.load( aPicturePath ) )
- { // Load first image from file
- isLoadBackground = true;
- setBackground( aPicturePath );
-
- }
-
- else
- isLoadBackground = false;
-}
-
-/*!
- Paints content
-*/
-void GLViewer_Widget::paintGL()
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-
- glRotatef( myRotationAngle, myRotationCenterX, myRotationCenterY, myRotationCenterZ );
- glScalef( myXScale, myYScale, myZScale );
- glTranslatef( myXPan, myYPan, myZPan );
-
- if( isLoadBackground )
- {
- glEnable(GL_TEXTURE_2D);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glBindTexture(GL_TEXTURE_2D, texName);
- glBegin(GL_QUADS);
-
- glTexCoord2f( 0.0, 0.0); glVertex3f( -myIW/2, -myIH/2, 0.0);
- glTexCoord2f( 0.0, (float)myIH/myBackgroundSize ); glVertex3f( -myIW/2, myIH/2, 0.0);
- glTexCoord2f( (float)myIW/myBackgroundSize, (float)myIH/myBackgroundSize ); glVertex3f( myIW/2, myIH/2, 0.0);
- glTexCoord2f( (float)myIW/myBackgroundSize, 0.0); glVertex3f( myIW/2, -myIH/2, 0.0);
-
- glEnd();
- glFlush();
- glDisable(GL_TEXTURE_2D);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- }
-
-
- GLViewer_Grid* grid = myViewPort->getGrid();
- if( grid )
- grid->draw();
-
- GLViewer_Viewer2d* v = ( GLViewer_Viewer2d* )getViewPort()->getViewFrame()->getViewer();
- if( !isExportMode )
- v->updateDrawers( GL_FALSE, myXScale, myYScale );
- else
- v->repaintView( getViewPort()->getViewFrame() );
-}
-
-/*!
- Resets OpenGl parameters after resize
- \param w - new width
- \param h - new height
-*/
-void GLViewer_Widget::resizeGL( int w, int h )
-{
-
- if( h < 1 ) h = 1;
- if( w < 1 ) w = 1;
- glViewport( 0, 0, w, h);
-
- if( myStart )
- {
- myWidth = w;
- myHeight = h;
- myStart = GL_FALSE;
- }
-
- myViewPort->initResize( w, h );
-
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- GLfloat w_c = w / 2., h_c = h / 2.;
-
- gluOrtho2D( -w_c, w_c, -h_c, h_c );
-
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-}
-
-/*!
- Provides repaint in export mode
-*/
-void GLViewer_Widget::exportRepaint()
-{
- isExportMode = true;
-
- paintGL();
-
- isExportMode = false;
-}
-
-/*!
- Custom paint event handler
-*/
-void GLViewer_Widget::paintEvent( QPaintEvent* e )
-{
- QApplication::sendEvent( myViewPort, e );
-}
-
-/*!
- Custom mouse move event handler
-*/
-void GLViewer_Widget::mouseMoveEvent( QMouseEvent* e )
-{
- QApplication::sendEvent( myViewPort, e );
-}
-
-/*!
- Custom mouse press event handler
-*/
-void GLViewer_Widget::mousePressEvent( QMouseEvent* e )
-{
- QApplication::sendEvent( myViewPort, e );
-}
-
-/*!
- Custom mouse release event handler
-*/
-void GLViewer_Widget::mouseReleaseEvent( QMouseEvent* e )
-{
- QApplication::sendEvent( myViewPort, e );
-}
-
-/*!
- Custom enter event handler
-*/
-void GLViewer_Widget::enterEvent( QEvent* e )
-{
- updateGL();
-}
-
-/*!
- Custom leave event handler
-*/
-void GLViewer_Widget::leaveEvent( QEvent* e )
-{
- updateGL();
-}
-
-
-/*!
- \return the hex code of digit < 16
- \param c - digit
-*/
-inline char hex( uchar c )
-{
- if( c<=9 )
- return '0'+c;
- else if( c < 16 )
- return 'a' + c - 10;
-
- return ' ';
-}
-
-/*!
- Translates part of image inside rectangle from w1 to w2 and from h2 to h1 to PS format
- \param hFile - PostScript file
- \param image - image to be tarnslated
- \param w1 - x start position
- \param w2 - x end position
- \param h1 - y start position
- \param h2 - y end position
- \param aViewerCS - viewer co-ordinate system
- \param aPSCS - paper co-ordinate system
- \param a
- \param b
- \param c
- \param d
- \param dw
- \param dh
-*/
-void AddImagePart( QFile& hFile, QImage& image, int w1, int w2, int h1, int h2,
- GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS,
- double a, double b, double c, double d, double dw, double dh )
-{
- if( aViewerCS && aPSCS )
- {
- double width = w2-w1+1, height = h2-h1+1;
- QString aBuffer = "", temp = "%1 %2 8 [ %3 %4 %5 %6 %7 %8 ]\n";
- aBuffer += temp.arg( width ).arg( height ).
- arg( a ).arg( b ).arg( c ).arg( d ).
- arg( dw ).arg( dh );
- aBuffer += "<\n";
-
- char line[81]; line[80] = '\0'; int cur_index = 0;
- int full = 0;
- for( int i=h2; i>=h1; i-- )
- {
- uchar* theCurLine = image.scanLine( i ), cur;
- for( int j=w1; j<=w2; j++ )
- for( int k=0; k<3; k++ )
- {
- cur = *(theCurLine+4*j+2-k);
- *(line+cur_index) = hex( cur/16 ); //HI
- *(line+cur_index+1) = hex( cur%16 ); //LO
- full++;
- cur_index+=2;
- if( cur_index>=80 )
- {
- aBuffer += line;
- aBuffer += "\n";
- cur_index = 0;
- }
- }
- }
-
- aBuffer += "> false 3 colorimage\n\n";
-
- hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
- }
-}
-
-/*!
- \return background rectangle in viewer CS
-*/
-void GLViewer_Widget::getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom )
-{
- left = -myIW/2; right = myIW/2;
- top = myIH/2; bottom = -myIH/2;
-}
-
-/*!
- Translates background to PostScript
- \param hFile - PostScript file
- \param aViewerCS - viewer co-ordinate system
- \param aPSCS - paper co-ordinate system
-*/
-void GLViewer_Widget::translateBackgroundToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
-{
- QImage buf;
-
- if( aViewerCS && aPSCS && isLoadBackground && buf.load( myBackgroundFile ) )
- {
- double a, b, c, d, dx, dy; //The preparation of transformation matrix
-
- double width = buf.width(), height = buf.height();
-
- double left, top, right, bottom;
- getBackgroundRectInViewerCS( left, top, right, bottom );
-
- double aax = left, aay = bottom,
- bbx = right, bby = bottom,
- ccx = left, ccy = top;
-
- aViewerCS->transform( *aPSCS, aax, aay );
- aViewerCS->transform( *aPSCS, bbx, bby );
- aViewerCS->transform( *aPSCS, ccx, ccy );
-
- a = ( bbx - aax ) / width;
- b = ( ccx - aax ) / height;
- c = ( bby - aay ) / width;
- d = ( ccy - aay ) / height;
-
- //Now we must find invert matrix
- double det = a*d-b*c,
- newa = d/det,
- newb = -c/det,
- newc = -b/det,
- newd = a/det;
-
- a = newa; b = newb; c = newc; d = newd;
-
- dx = -(a*aax+c*aay);
- dy = -(b*aax+d*aay); //according to PS specification of coordinate transformation
-
- const int max = 133000; //The maximum length of string in PS
- int dh = int( floor( double( max ) / ( 3.0*2.0*width ) ) );
- for( int k=buf.height()-1; k>=0; k-=dh )
- AddImagePart( hFile, buf, 0, buf.width()-1, QMAX( k-dh+1, 0 ), k,
- aViewerCS, aPSCS, a, b, c, d, dx, dy-(buf.height()-1-k) );
- }
-}
-
-/*!
- Translates image line with one color depth to line with other depth
-*/
-void DecodeScanLine( int width, uchar* dest, int dest_depth, uchar* source, int source_depth )
-{
-#ifndef WIN32
-typedef unsigned int WORD;
-#endif
-
- int aSize = width*dest_depth,
- dw = aSize % 8;
-
- if( dw )
- aSize+=dw;
-
- if( dest_depth==source_depth )
- memcpy( dest, source, aSize/8 );
- else
- {
- double r, g, b; WORD color;
- for( int i=0; i<width; i++ )
- {
- color = 0;
- switch( source_depth )
- {
- case 16:
- memcpy( &color, source + 2*i, 2 );
- b = double( color & 0x001F ) / 31.0;
- g = double( ( color & 0x07E0 ) >> 5 ) / 63.0;
- r = double( ( color & 0xF800 ) >> 11 ) / 31.0;
- break;
- case 24:
- b = double( *(source + 3*i) ) / 255.0;
- g = double( *(source + 3*i+1) ) / 255.0;
- r = double( *(source + 3*i+2) ) / 255.0;
- break;
- case 32:
- b = double( *(source + 4*i) ) / 255.0;
- g = double( *(source + 4*i+1) ) / 255.0;
- r = double( *(source + 4*i+2) ) / 255.0;
- break;
- }
- switch( dest_depth )
- {
- case 16:
- color = WORD(b*31.0);
- color += (WORD(g*63.0)<<5);
- color += (WORD(r*31.0)<<11);
- memcpy( dest + 2*i, &color, 2 );
- break;
- case 24:
- *( dest + 3*i ) = (uchar)(255*b);
- *( dest + 3*i+1 ) = (uchar)(255*g);
- *( dest + 3*i+2 ) = (uchar)(255*r);
- break;
- case 32:
- *( dest + 4*i ) = (uchar)(255*b);
- *( dest + 4*i+1 ) = (uchar)(255*g);
- *( dest + 4*i+2 ) = (uchar)(255*r);
- *( dest + 4*i+3 ) = 0;
- break;
- }
- }
- }
-}
-
-#ifdef WIN32
-/*!
- Translates background to EMF
- \param dc - descriptor of EMF
- \param aViewerCS - viewer co-ordinate system
- \param aPSCS - paper co-ordinate system
-*/
-void GLViewer_Widget::translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
-{
- QImage buf;
-
- if( aViewerCS && aEMFCS && isLoadBackground && buf.load( myBackgroundFile ) )
- {
- double left, top, right, bottom;
- getBackgroundRectInViewerCS( left, top, right, bottom );
-
- double aRot = aViewerCS->getRotation();
-
- double lx = left, ly = top;
- aViewerCS->transform( *aEMFCS, lx, ly );
-
- aViewerCS->setRotation( 0.0 ); //we switch off the rotation of CS
-
- aViewerCS->transform( *aEMFCS, left, top );
- aViewerCS->transform( *aEMFCS, right, bottom );
-
- int w = buf.width(),
- h = buf.height();
-
- HDC aScrDC = GetDC( 0 );
- HDC aCompDC = CreateCompatibleDC( aScrDC );
- HBITMAP aBMP = CreateCompatibleBitmap( aScrDC, w, h );
-
- BITMAP aBitInfo;
- GetObject ( aBMP, sizeof(BITMAP), &aBitInfo );
- int depth = aBitInfo.bmBitsPixel; //how many bits represent a color of one pixel
-
- int aLineSize = w*depth;
- int dw = aLineSize % 32; //scanline word aligning
-
- if( dw )
- aLineSize += 32-dw;
-
- aLineSize /= 8;
-
- BYTE* bits = new BYTE[aLineSize*h];
- memset( bits, 0, aLineSize*h );
- uchar* aLine = NULL;
-
- for( int i=0; i<h; i++ )
- {
- aLine = buf.scanLine( i );
- DecodeScanLine( w, bits+aLineSize*i, depth, aLine, buf.depth() );
- }
-
- SetBitmapBits( aBMP, aLineSize*h, bits );
-
- HGDIOBJ old = SelectObject( aCompDC, aBMP );
-
- XFORM aTrans;
- GetWorldTransform( dc, &aTrans );
- XFORM aRotTrans = aTrans;
- double a = aRotTrans.eM11,
- b = aRotTrans.eM12,
- c = aRotTrans.eM21,
- d = aRotTrans.eM22;
-
- aRotTrans.eM11 = a*cos( aRot )-b*sin( aRot ); //we multiply the current matrix with the rotation matrix
- aRotTrans.eM12 = a*sin( aRot )+b*cos( aRot );
- aRotTrans.eM21 = c*cos( aRot )-d*sin( aRot );
- aRotTrans.eM22 = c*sin( aRot )+d*cos( aRot );
-
- a = aRotTrans.eM11;
- b = aRotTrans.eM12;
- c = aRotTrans.eM21;
- d = aRotTrans.eM22;
-
- double det = a*d-b*c, //now we find the invert matrix
- newa = d/det,
- newb = -c/det,
- newc = -b/det,
- newd = a/det;
-
- a = newa; b = newb; c = newc; d = newd;
-
- aRotTrans.eDx = lx -(a*left+c*top); //we find the dx and dy translating (left,top)->(lx,ly) -
- aRotTrans.eDy = ly -(b*left+d*top); //the real image of left-top corner of picture
-
- SetWorldTransform( dc, &aRotTrans );
- int res = StretchBlt( dc, left, top, right-left, bottom-top, aCompDC, 0, 0, w, h, SRCCOPY );
- SetWorldTransform( dc, &aTrans );
-
- SelectObject( aCompDC, old );
-
- ReleaseDC( 0, aScrDC );
- DeleteDC( aCompDC );
- DeleteObject( aBMP );
- delete[] bits;
-
- aViewerCS->setRotation( aRot );
- }
-}
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : OPEN CASCADE
-//
-
-// File: GLViewer_Widget.h
-// Created: November, 2004
-
-#ifndef GLVIEWER_WIDGET_H
-#define GLVIEWER_WIDGET_H
-
-#include "GLViewer.h"
-
-#include <qgl.h>
-#include <qfile.h>
-
-class GLViewer_ViewPort2d;
-class GLViewer_CoordSystem;
-
-/*!
- \class GLViewer_Widget
- Widget for visualization of OpenGL scene
-*/
-class GLVIEWER_API GLViewer_Widget : public QGLWidget
-{
- Q_OBJECT
-
-public:
- //! A constructor
- /*! Parameters using for QOGLWidget as is
- */
- GLViewer_Widget( QWidget* theParent, const char* theName = 0 );
-
- //! A destructor
- ~GLViewer_Widget();
-
- //! Returns parent GLViewer_ViewPort2d
- /*! ViewPort2d because this class is not use for 3D Viewer */
- GLViewer_ViewPort2d* getViewPort() const { return myViewPort; }
- //! Returns width of OpenGl Window
- GLint getWidth() const { return myWidth; }
- //! Returns height of OpenGl Window
- GLint getHeight() const { return myHeight; }
-
- //! Returns scales on OpenGL scene along 3 directions
- /*! in 2d scene zScale = 1.0 */
- void getScale( GLfloat& xScale,
- GLfloat& yScale,
- GLfloat& zScale );
- //! A function for installing the scales of OpenGL scene
- void setScale( GLfloat xScale,
- GLfloat yScale,
- GLfloat zScaleGLfloat );
-
- //! Returns offset parameters of Window in OpenGL global scene
- void getPan( GLfloat& xPan, GLfloat& yPan, GLfloat& zPan );
- //! A function for installing the offset parameters of Window in OpenGL global scene
- void setPan( GLfloat xPan, GLfloat yPan, GLfloat zPan );
-
- //! Returns rotation angle of Window in OpenGL global scene in degree
- /*! Only in 2D */
- GLfloat getRotationAngle() const { return myRotationAnglePrev; }
- //! A function for installing the rotation angle of Window in OpenGL global scene in degree
- /*! Only in 2D */
- void setRotationAngle( GLfloat a ) { myRotationAnglePrev = a; }
-
- //! Returns start point of curren rotation of Window in OpenGL global scene
- void getRotationStart( GLfloat& rotationStartX,
- GLfloat& rotationStartY,
- GLfloat& rotationStartZ );
- //! A function for installing the start point of curren rotation of Window in OpenGL global scene
- void setRotationStart( GLfloat rotationStartX,
- GLfloat rotationStartY,
- GLfloat rotationStartZ );
- //! Returns parameters of current rotation
- void getRotation( GLfloat& rotationAngle,
- GLfloat& rotationCenterX,
- GLfloat& rotationCenterY,
- GLfloat& rotationCenterZ );
- //! A function for installing the parameters of current rotation
- void setRotation( GLfloat, GLfloat, GLfloat, GLfloat );
-
- //! A function load picture from file with name theFileName and post it in center of global OpenGL scene
- void setBackground( QString theFileName );
-
- //! A function add the tool tip with text theTTText on theTTRect rect to the widget window
- void addToolTip( QString theTTText, QRect theTTRect );
- //! A function remove tool tip form widget window
- void removeToolTip();
-
- //! A function translate background of window in to PostScript file on disk
- /*!
- *\param hFile the name of PostScript file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aPSCS the GLViewer_CoordSystem of PostScript page
- */
- virtual void translateBackgroundToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
-
- //! A function repaints OpenGL scene in export mode
- /* Repaints all objects in only current view */
- void exportRepaint();
-
-#ifdef WIN32
- //! A function translate background of window in to EMF file on disk
- //!
- /*!
- *\warning WIN32 only
- *
- *\param dc the name of HDC associated with file chosen by user
- *\param aViewerCS the GLViewer_CoordSystem of window
- *\param aEMFCS the GLViewer_CoordSystem of EMF page
- */
- virtual void translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
-#endif
-
-private:
- //! Auxiliary function. Returns rect of window background in viewer coordinate system
- void getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom );
-
-protected:
- /* Redefined QT methods */
- //! A function is called before first display of window (create OpenGL scene)
- virtual void initializeGL();
- //! A function is called in earch paint event of window
- /* Calling by public method repaint() */
- virtual void paintGL();
- //! A function is called in earch resize event of window
- virtual void resizeGL( int, int );
-
-
- virtual void paintEvent( QPaintEvent* );
- virtual void mouseMoveEvent( QMouseEvent* );
- virtual void mousePressEvent( QMouseEvent* );
- virtual void mouseReleaseEvent( QMouseEvent* );
-
- /* Needs to redefine because Window must be updated highlight presentation when mouse enter window */
- virtual void enterEvent( QEvent* );
- /* Needs to redefine because Window must be updated highlight presentation when mouse leave window */
- virtual void leaveEvent( QEvent* );
-
-private:
- //! width of window
- GLint myWidth;
- //! height of window
- GLint myHeight;
-
- //! Scale along X direction
- GLfloat myXScale;
- //! Scale along Y direction
- GLfloat myYScale;
- //! Scale along Z direction
- /* equals 1 in 2D */
- GLfloat myZScale;
-
- //! Window offset along X direction
- GLfloat myXPan;
- //! Window offset along Y direction
- GLfloat myYPan;
- //! Window offset along Z direction
- /* equals 0 in 2D */
- GLfloat myZPan;
-
- GLfloat myRotationStartX;
- GLfloat myRotationStartY;
- GLfloat myRotationStartZ;
- GLfloat myRotationAngle;
- GLfloat myRotationCenterX;
- GLfloat myRotationCenterY;
- GLfloat myRotationCenterZ;
- GLfloat myRotationAnglePrev;
-
- GLboolean myStart;
- GLViewer_ViewPort2d* myViewPort;
-
- //! True if background is loaded
- bool isLoadBackground;
- //! File name of background image
- QString myBackgroundFile;
- //! Texture id of loaded background image
- GLuint texName;
- //! Width of background image
- int myIW;
- //! Height of background image
- int myIH;
- //! Size of background image
- int myBackgroundSize;
-
- QRect myToolTipRect;
-
- //! Needs for export repaint
- bool isExportMode;
-};
-
-#endif // GLVIEWER_WIDGET_H
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# File : Makefile.in
-# Author : Vladimir Klyachin (OCN)
-# Module : caf
-# $Header$
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@srcdir@/resources
-
-
-@COMMENCE@
-
-# header files
-EXPORT_HEADERS= GLViewer.h \
- GLViewer_AspectLine.h \
- GLViewer_BaseDrawers.h \
- GLViewer_BaseObjects.h \
- GLViewer_Compass.h \
- GLViewer_Context.h \
- GLViewer_CoordSystem.h \
- GLViewer_Defs.h \
- GLViewer_Drawer.h \
- GLViewer_Geom.h \
- GLViewer_Grid.h \
- GLViewer_Group.h \
- GLViewer_MimeSource.h \
- GLViewer_Object.h \
- GLViewer_Selector.h \
- GLViewer_Selector2d.h \
- GLViewer_Text.h \
- GLViewer_Tools.h \
- GLViewer_ToolTip.h \
- GLViewer_ViewFrame.h \
- GLViewer_ViewManager.h \
- GLViewer_ViewPort.h \
- GLViewer_ViewPort2d.h \
- GLViewer_Viewer.h \
- GLViewer_Viewer2d.h \
- GLViewer_Widget.h
-
-# .po files to transform in .qm
-PO_FILES = GLViewer_images.po \
- GLViewer_msg_en.po
-
-# Libraries targets
-LIB = libGLViewer.la
-
-LIB_SRC= GLViewer_AspectLine.cxx \
- GLViewer_BaseDrawers.cxx \
- GLViewer_BaseObjects.cxx \
- GLViewer_Compass.cxx \
- GLViewer_Context.cxx \
- GLViewer_CoordSystem.cxx \
- GLViewer_Drawer.cxx \
- GLViewer_Geom.cxx \
- GLViewer_Grid.cxx \
- GLViewer_Group.cxx \
- GLViewer_MimeSource.cxx \
- GLViewer_Object.cxx \
- GLViewer_Selector.cxx \
- GLViewer_Selector2d.cxx \
- GLViewer_Text.cxx \
- GLViewer_Tools.cxx \
- GLViewer_ToolTip.cxx \
- GLViewer_ViewFrame.cxx \
- GLViewer_ViewManager.cxx \
- GLViewer_ViewPort.cxx \
- GLViewer_ViewPort2d.cxx \
- GLViewer_Viewer.cxx \
- GLViewer_Viewer2d.cxx \
- GLViewer_Widget.cxx
-
-LIB_MOC = GLViewer_Selector.h \
- GLViewer_Selector2d.h \
- GLViewer_ToolTip.h \
- GLViewer_ViewFrame.h \
- GLViewer_ViewManager.h \
- GLViewer_ViewPort.h \
- GLViewer_ViewPort2d.h \
- GLViewer_Viewer.h \
- GLViewer_Viewer2d.h \
- GLViewer_Widget.h
-
-RESOURCES_FILES = cursor_rotate.png \
- cursor_sketch.png \
- cursor_zoom.png \
- view_dump.png \
- view_fitall.png \
- view_fitarea.png \
- view_fitselect.png \
- view_glpan.png \
- view_pan.png \
- view_reset.png \
- view_zoom.png
-
-CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES)
-
-LDFLAGS+=$(QT_MT_LIBS) $(CAS_KERNEL)
-
-LIBS+= -lsuit -L/usr/X11R6/lib@LIB_LOCATION_SUFFIX@ -lGLU
-
-@CONCLUDE@
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: GLViewer_images.po
-// Created: 10/25/2004 12:46:36 PM
-// Author: Sergey Anikin
-// Copyright (C) CEA 2004
-
-msgid ""
-msgstr ""
-"Project-Id-Version: example-Qt-message-extraction\n"
-"POT-Creation-Date: 1999-02-23 15:38+0200\n"
-"PO-Revision-Date: 2005-05-05 10:17+0400\n"
-"Last-Translator: \n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-msgid "ICON_GL_FITALL"
-msgstr "view_fitall.png"
-
-msgid "ICON_GL_FITAREA"
-msgstr "view_fitarea.png"
-
-msgid "ICON_GL_FITSELECT"
-msgstr "view_fitselect.png"
-
-msgid "ICON_GL_GLOBALPAN"
-msgstr "view_glpan.png"
-
-msgid "ICON_GL_PAN"
-msgstr "view_pan.png"
-
-msgid "ICON_GL_RESET"
-msgstr "view_reset.png"
-
-msgid "ICON_GL_ZOOM"
-msgstr "view_zoom.png"
-
-msgid "ICON_GL_DUMP"
-msgstr "view_dump.png"
-
-msgid "ICON_GL_CURSOR_ZOOM"
-msgstr "cursor_zoom.png"
-
-msgid "ICON_GL_CURSOR_ROTATE"
-msgstr "cursor_rotate.png"
-
-msgid "ICON_GL_CURSOR_SKETCH"
-msgstr "cursor_sketch.png"
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: GLViewer_msg_en.po
-// Created: 10/25/2004 12:46:36 PM
-// Author: Sergey Anikin
-// Copyright (C) CEA 2004
-
-msgid ""
-msgstr ""
-"Project-Id-Version: example-Qt-message-extraction\n"
-"POT-Creation-Date: 1999-02-23 15:38+0200\n"
-"PO-Revision-Date: 1999-02-23 15:38+0200\n"
-"Last-Translator: \n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-msgid "LBL_TOOLBAR_LABEL"
-msgstr "View Operations"
-
-msgid "DSC_RESET_VIEW"
-msgstr "Reset View Point"
-
-msgid "MNU_RESET_VIEW"
-msgstr "Reset"
-
-msgid "DSC_FITALL"
-msgstr "Fit all objects inside the view frame"
-
-msgid "MNU_FITALL"
-msgstr "Fit All"
-
-msgid "DSC_FITRECT"
-msgstr "Fit area within the view frame"
-
-msgid "MNU_FITRECT"
-msgstr "Fit Area"
-
-msgid "DSC_FITSELECT"
-msgstr "Fit area of selection within the view frame"
-
-msgid "MNU_FITSELECT"
-msgstr "Fit Selection"
-
-msgid "DSC_ZOOM_VIEW"
-msgstr "Zoom the view"
-
-msgid "MNU_ZOOM_VIEW"
-msgstr "Zoom"
-
-msgid "DSC_PAN_VIEW"
-msgstr "Panning the view"
-
-msgid "MNU_PAN_VIEW"
-msgstr "Panning"
-
-msgid "DSC_GLOBALPAN_VIEW"
-msgstr "Selection of a new center of the view"
-
-msgid "MNU_GLOBALPAN_VIEW"
-msgstr "Global Panning"
-
-msgid "DSC_DUMP_VIEW"
-msgstr "Saves the active view in the image file"
-
-msgid "MNU_DUMP_VIEW"
-msgstr "Dump"
-
-msgid "GL_IMAGE_FILES"
-msgstr "Images Files (*.bmp *.png)"
-
-msgid "INF_APP_DUMP_VIEW"
-msgstr "Dump view"
-
-msgid "ERR_DOC_CANT_SAVE_FILE"
-msgstr "Cannot save file"
-
-msgid "ERROR"
-msgstr "Error"
-
-msgid "CHANGE_BGCOLOR"
-msgstr "Change background..."
-
-msgid "GLViewer_ViewFrame::DUMP_VIEW_SAVE_FILE_DLG_CAPTION"
-msgstr "Save Dump View in file"
-
-msgid "GLViewer_ViewFrame::DUMP_VIEW_ERROR_DLG_CAPTION"
-msgstr "Error"
-
-msgid "GLViewer_ViewFrame::DUMP_VIEW_ERROR_DLG_TEXT"
-msgstr "Can't save Dump View in file"
-
-msgid "GLViewer_ViewManager::GL_VIEW_TITLE"
-msgstr "GL Scene:%M - viewer:%V"
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp.h
-// Created: June, 2005
-// Author: OCC team
-
-
-// The following ifdef block is the standard way of creating macros which make exporting
-// from a DLL simpler. All files within this DLL are compiled with the LightApp_EXPORTS
-// symbol defined on the command line. this symbol should not be defined on any project
-// that uses this DLL. This way any other project whose source files include this file see
-// LightApp_API functions as being imported from a DLL, wheras this DLL sees symbols
-// defined with this macro as being exported.
-#ifdef WNT
-
-#ifdef LIGHTAPP_EXPORTS
-#define LIGHTAPP_EXPORT __declspec(dllexport)
-#else
-#define LIGHTAPP_EXPORT __declspec(dllimport)
-#endif
-
-#pragma warning ( disable:4251 )
-#pragma warning ( disable:4786 )
-#pragma warning ( disable:4503 )
-
-#else
-#define LIGHTAPP_EXPORT
-#endif //WNT
-
-#define APP_VERSION "0.1"
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_AboutDlg.cxx
-// Created: 03.06.2005 13:52:45
-// Author: Sergey TELKOV
-// Copyright (C) CEA 2005
-
-#include "LightApp_AboutDlg.h"
-
-#include <SUIT_Session.h>
-#include <SUIT_ResourceMgr.h>
-
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-#include <qgroupbox.h>
-
-/*!Constructor.*/
-LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent )
-: QtxDialog( parent, "salome_about_dialog", true, false, None )
-{
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-
- QPixmap ico = resMgr->loadPixmap( "LightApp", tr( "ICO_ABOUT" ), false );
- if ( !ico.isNull() )
- setIcon( ico );
-
- QPalette pal = palette();
- QColorGroup cg = pal.active();
- cg.setColor( QColorGroup::Foreground, Qt::darkBlue );
- cg.setColor( QColorGroup::Background, Qt::white );
- pal.setActive( cg ); pal.setInactive( cg ); pal.setDisabled( cg );
- setPalette(pal);
-
- QVBoxLayout* main = new QVBoxLayout( mainFrame() );
- QGroupBox* base = new QGroupBox( 1, Qt::Horizontal, "", mainFrame() );
- base->setFrameStyle( QFrame::NoFrame );
- base->setInsideMargin( 0 );
- main->addWidget( base );
-
- QLabel* screen = new QLabel( base );
- screen->setScaledContents( true );
- screen->setAlignment( Qt::AlignCenter );
- screen->setFrameStyle( QFrame::Box | QFrame::Plain );
-
- QLabel* title = new QLabel( base );
- title->setAlignment( Qt::AlignCenter );
- changeFont( title, true, false, false, 5 );
-
- QLabel* version = new QLabel( base );
- version->setAlignment( Qt::AlignCenter );
- changeFont( version, false, true, false, 2 );
-
- QLabel* copyright = new QLabel( base );
- copyright->setAlignment( Qt::AlignCenter );
- changeFont( copyright, false, false, false, 1 );
-
- QLabel* license = new QLabel( base );
- license->setAlignment( Qt::AlignCenter );
- changeFont( license, false, false, false, 1 );
-
- screen->setPixmap( resMgr->loadPixmap( "LightApp", tr( "ABOUT" ), false ) );
- checkLabel( screen );
-
- QString titleText = tr( "ABOUT_TITLE" );
- if ( titleText == "ABOUT_TITLE" )
- titleText = defName;
- title->setText( titleText );
- checkLabel( title );
-
- QString verText = tr( "ABOUT_VERSION" );
- if ( verText.contains( "%1" ) )
- verText = verText.arg( defVer );
- version->setText( verText );
- checkLabel( version );
-
- copyright->setText( tr( "ABOUT_COPYRIGHT" ) );
- checkLabel( copyright );
-
- license->setText( tr( "ABOUT_LICENSE" ) );
- checkLabel( license );
-
- QString capText = tr( "ABOUT_CAPTION" );
- if ( capText.contains( "%1" ) )
- capText = capText.arg( defName );
- setCaption( capText );
-
- setSizeGripEnabled( false );
-}
-
-/*!Destructor.*/
-LightApp_AboutDlg::~LightApp_AboutDlg()
-{
- //! Do nothing.
-}
-
-/*!On mouse press event.*/
-void LightApp_AboutDlg::mousePressEvent( QMouseEvent* )
-{
- accept();
-}
-
-/*!Change font of widget \a wid.
- *\param wid - QWidget
- *\param bold - boolean value
- *\param italic - boolean value
- *\param underline - boolean value
- *\param inc - integer increment for font point size.
- */
-void LightApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic,
- const bool underline, const int inc ) const
-{
- if ( !wid )
- return;
-
- QFont widFont = wid->font();
- widFont.setBold( bold );
- widFont.setItalic( italic );
- widFont.setUnderline( underline );
- widFont.setPointSize( widFont.pointSize() + inc );
-}
-
-/*!Check lable \a lab.*/
-void LightApp_AboutDlg::checkLabel( QLabel* lab ) const
-{
- if ( !lab )
- return;
-
- bool vis = !lab->text().stripWhiteSpace().isEmpty() ||
- ( lab->pixmap() && !lab->pixmap()->isNull() );
- vis ? lab->show() : lab->hide();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_AboutDlg.h
-// Created: 03.06.2005 13:49:25
-// Author: Sergey TELKOV
-// Copyright (C) CEA 2005
-
-#ifndef LIGHTAPP_ABOUTDLG_H
-#define LIGHTAPP_ABOUTDLG_H
-
-#include "LightApp.h"
-
-#include <QtxDialog.h>
-
-class QLabel;
-
-/*!
- \class LightApp_AboutDlg
- LightApp help about dialog
-*/
-class LIGHTAPP_EXPORT LightApp_AboutDlg : public QtxDialog
-{
- Q_OBJECT
-
-public:
- LightApp_AboutDlg( const QString&, const QString&, QWidget* = 0 );
- virtual ~LightApp_AboutDlg();
-
-protected:
- virtual void mousePressEvent( QMouseEvent* );
-
-private:
- void checkLabel( QLabel* ) const;
- void changeFont( QWidget*, const bool = false, const bool = false,
- const bool = false, const int = 0 ) const;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Application.cxx
-// Created: 6/20/2005 18:39:45 PM
-// Author: Natalia Donis
-// Copyright (C) CEA 2005
-
-#ifndef DISABLE_PYCONSOLE
- #include "PythonConsole_PyInterp.h" // WARNING! This include must be the first!
- #include <PythonConsole_PyConsole.h>
-#endif
-
-#include "LightApp_Application.h"
-#include "LightApp_WidgetContainer.h"
-#include "LightApp_Module.h"
-#include "LightApp_DataModel.h"
-#include "LightApp_Study.h"
-#include "LightApp_Preferences.h"
-#include "LightApp_PreferencesDlg.h"
-#include "LightApp_ModuleDlg.h"
-#include "LightApp_AboutDlg.h"
-
-#include "LightApp_OBFilter.h"
-
-#include "LightApp_EventFilter.h"
-
-#include "LightApp_OBSelector.h"
-#include "LightApp_SelectionMgr.h"
-
-#include <CAM_Module.h>
-#include <CAM_DataModel.h>
-#include <CAM_Study.h>
-#include <STD_TabDesktop.h>
-
-#include <SUIT_Session.h>
-#include <SUIT_Study.h>
-#include <SUIT_FileDlg.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Tools.h>
-#include <SUIT_Accel.h>
-
-#include <QtxMRUAction.h>
-#include <QtxDockAction.h>
-#include <QtxToolBar.h>
-#include <qprocess.h>
-
-#include <LogWindow.h>
-#include <OB_Browser.h>
-#include <OB_ListView.h>
-
-#ifndef DISABLE_GLVIEWER
- #include <GLViewer_Viewer.h>
- #include <GLViewer_ViewManager.h>
- #include "LightApp_GLSelector.h"
-#endif
-
-#ifndef DISABLE_PLOT2DVIEWER
- #include <Plot2d_ViewManager.h>
- #include <Plot2d_ViewModel.h>
-#ifndef DISABLE_SALOMEOBJECT
- #include <SPlot2d_ViewModel.h>
-#else
- #include <Plot2d_ViewModel.h>
-#endif
-#endif
-
-#ifndef DISABLE_OCCVIEWER
- #include <OCCViewer_ViewManager.h>
-#ifndef DISABLE_SALOMEOBJECT
- #include <SOCC_ViewModel.h>
-#else
- #include <OCCViewer_ViewModel.h>
-#endif
- #include "LightApp_OCCSelector.h"
-#endif
-
-#ifndef DISABLE_VTKVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- #include <SVTK_ViewModel.h>
- #include <SVTK_ViewManager.h>
- #include "LightApp_VTKSelector.h"
-#else
- #include <VTKViewer_ViewModel.h>
- #include <VTKViewer_ViewManager.h>
-#endif
- #include <VTKViewer_ViewModel.h>
-#endif
-
-//#ifndef DISABLE_SUPERVGRAPHVIEWER
-// #include <SUPERVGraph_ViewModel.h>
-// #include <SUPERVGraph_ViewFrame.h>
-// #include <SUPERVGraph_ViewManager.h>
-//#endif
-
-#include <QtxWorkstack.h>
-
-#include <qdir.h>
-#include <qimage.h>
-#include <qstring.h>
-#include <qwidget.h>
-#include <qstringlist.h>
-#include <qfile.h>
-#include <qapplication.h>
-#include <qmap.h>
-#include <qstatusbar.h>
-#include <qthread.h>
-#include <qobjectlist.h>
-#include <qcombobox.h>
-#include <qinputdialog.h>
-#include <qmessagebox.h>
-#include <qfontdatabase.h>
-
-#define FIRST_HELP_ID 1000000
-
-#ifndef DISABLE_SALOMEOBJECT
- #include "SALOME_InteractiveObject.hxx"
- #include "SALOME_ListIO.hxx"
-#endif
-
-static const char* imageEmptyIcon[] = {
-"20 20 1 1",
-". c None",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"....................",
-"...................."};
-
-int LightApp_Application::lastStudyId = 0;
-
-/*!
- \return last global id of study
-*/
-int LightApp_Application::studyId()
-{
- return LightApp_Application::lastStudyId;
-}
-
-/*!Create new instance of LightApp_Application.*/
-extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
-{
- return new LightApp_Application();
-}
-
-/*! \var global preferences of LightApp */
-LightApp_Preferences* LightApp_Application::_prefs_ = 0;
-
-/*!
- \class LightApp_Application
- Application containing LightApp module
-*/
-
-/*!Constructor.*/
-LightApp_Application::LightApp_Application()
-: CAM_Application( false ),
-myPrefs( 0 )
-{
- STD_TabDesktop* desk = new STD_TabDesktop();
-
- setDesktop( desk );
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
-
- desktop()->setIcon( aLogo );
- desktop()->setDockableMenuBar( true );
- desktop()->setDockableStatusBar( false );
-
- // base logo (salome itself)
- desktop()->addLogo( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
- // extra logo (salome-based application)
- desktop()->addLogo( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
-
- clearViewManagers();
-
- mySelMgr = new LightApp_SelectionMgr( this );
-
- myAccel = SUIT_Accel::getAccel();
-
-#ifndef DISABLE_OCCVIEWER
- myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, OCCViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, OCCViewer_Viewer::Type() );
-#endif
-#ifndef DISABLE_VTKVIEWER
- myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, VTKViewer_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, VTKViewer_Viewer::Type() );
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
- myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, Plot2d_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, Plot2d_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, Plot2d_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, Plot2d_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, Plot2d_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, Plot2d_Viewer::Type() );
- myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, Plot2d_Viewer::Type() );
-#endif
-
- connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
-
- // Set existing font for the python console in resources
- if( !aResMgr->hasValue( "PyConsole", "font" ) )
- return;
-
- QFont f = aResMgr->fontValue( "PyConsole", "font" );
- QFontDatabase fdb;
- QStringList famdb = fdb.families();
-
- if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
- return;
-
- QStringList anAddFamilies = QStringList::split( ";", aResMgr->stringValue( "PyConsole", "additional_families" ) );
- QString aFamily;
- for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
- {
- aFamily = *it;
- if ( famdb.contains(aFamily) )
- {
- f.setFamily( aFamily );
- aResMgr->setValue( "PyConsole", "font", f );
- break;
- }
- }
-}
-
-/*!Destructor.
- *\li Save window geometry.
- *\li Save desktop geometry.
- *\li Save resource maneger.
- *\li Delete selection manager.
- */
-LightApp_Application::~LightApp_Application()
-{
- delete mySelMgr;
-}
-
-/*!Start application.*/
-void LightApp_Application::start()
-{
- if ( desktop() )
- desktop()->loadGeometry( resourceMgr(), "desktop" );
-
- CAM_Application::start();
-
- QAction* a = action( ViewWindowsId );
- if ( a && a->inherits( "QtxDockAction" ) )
- ((QtxDockAction*)a)->setAutoPlace( true );
-
- updateWindows();
- updateViewManagers();
-
- putInfo( "" );
- desktop()->statusBar()->message( "" );
-
- LightApp_EventFilter::Init();
-}
-
-/*!Gets application name.*/
-QString LightApp_Application::applicationName() const
-{
- return tr( "APP_NAME" );
-}
-
-/*!Gets application version.*/
-QString LightApp_Application::applicationVersion() const
-{
- static QString _app_version;
-
- if ( _app_version.isEmpty() )
- {
- QString resVersion = tr( "APP_VERSION" );
- if ( resVersion != "APP_VERSION" )
- {
- _app_version = resVersion;
- }
- else
- {
- QString path( ::getenv( "GUI_ROOT_DIR" ) );
- if ( !path.isEmpty() )
- path += QDir::separator();
- path += QString( "bin/salome/VERSION" );
-
- QFile vf( path );
- if ( vf.open( IO_ReadOnly ) )
- {
- QString line;
- vf.readLine( line, 1024 );
- vf.close();
-
- if ( !line.isEmpty() )
- {
- while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
- line.remove( line.length() - 1, 1 );
-
- int idx = line.findRev( ":" );
- if ( idx != -1 )
- _app_version = line.mid( idx + 1 ).stripWhiteSpace();
- }
- }
- }
- }
- return _app_version;
-}
-
-/*!Load module by \a name.*/
-CAM_Module* LightApp_Application::loadModule( const QString& name )
-{
- CAM_Module* mod = CAM_Application::loadModule( name );
- if ( mod )
- {
- connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
- connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
- connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
- }
- return mod;
-}
-
-/*!Activate module by \a modName*/
-bool LightApp_Application::activateModule( const QString& modName )
-{
- QString actName;
- CAM_Module* prevMod = activeModule();
-
- if ( prevMod )
- actName = prevMod->moduleName();
-
- if ( actName == modName )
- return true;
-
- putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
-
- saveWindowsGeometry();
-
- bool status = CAM_Application::activateModule( modName );
-
- updateModuleActions();
-
- putInfo( "" );
-
- if ( !status )
- return false;
-
- updateWindows();
- updateViewManagers();
-
- return true;
-}
-
-/*!
- Opens other study into active Study. If Study is empty - creates it.
- \param theName - name of study
-*/
-bool LightApp_Application::useStudy(const QString& theName)
-{
- createEmptyStudy();
- LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
- bool res = false;
- if (aStudy)
- res = aStudy->loadDocument( theName );
- updateDesktopTitle();
- updateCommandsStatus();
- return res;
-}
-
-/*!Gets selection manager.*/
-LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
-{
- return mySelMgr;
-}
-
-/*!Creat action "New window" for certain type of viewer:*/
-void LightApp_Application::createActionForViewer( const int id,
- const int parentId,
- const QString& suffix,
- const int accel )
-{
- QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ), QIconSet(),
- tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ),
- tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ),
- accel, desktop(), false, this, SLOT( onNewWindow() ) );
- createMenu( a, parentId, -1 );
-}
-
-/*!Create actions:*/
-void LightApp_Application::createActions()
-{
- STD_Application::createActions();
-
- SUIT_Desktop* desk = desktop();
- SUIT_ResourceMgr* resMgr = resourceMgr();
-
- //! Preferences
- createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
- tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
- CTRL+Key_F, desk, false, this, SLOT( onPreferences() ) );
-
- //! Help for modules
- int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
- int helpModuleMenu = createMenu( tr( "MEN_DESK_MODULE_HELP" ), helpMenu, -1, 0 );
- createMenu( separator(), helpMenu, -1, 1 );
-
- QStringList aModuleList;
- modules( aModuleList, false );
-
- int id = LightApp_Application::UserID + FIRST_HELP_ID;
- // help for KERNEL and GUI
- QCString dir;
- QString aFileName = "index.htm";
- QString root;
- QAction* a;
- if (dir = getenv("GUI_ROOT_DIR")) {
- root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("doc") + Qtx::addSlash("salome") +
- Qtx::addSlash("gui") + Qtx::addSlash("GUI") );
- if ( QFileInfo( root + aFileName ).exists() ) {
- a = createAction( id, tr( QString("GUI Help") ), QIconSet(),
- tr( QString("GUI Help") ),
- tr( QString("GUI Help") ),
- 0, desk, false, this, SLOT( onHelpContentsModule() ) );
- a->setName( QString("GUI") );
- createMenu( a, helpModuleMenu, -1 );
- id++;
- }
- }
- if (dir = getenv("KERNEL_ROOT_DIR")) {
- QString aFN = "index.html";
- root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") +
- Qtx::addSlash("salome") );
- if ( QFileInfo( root + aFN ).exists() ) {
- a = createAction( id, tr( QString("KERNEL Help") ), QIconSet(),
- tr( QString("KERNEL Help") ),
- tr( QString("KERNEL Help") ),
- 0, desk, false, this, SLOT( onHelpContentsModule() ) );
- a->setName( QString("KERNEL") );
- createMenu( a, helpModuleMenu, -1 );
- id++;
- }
- }
- // help for other existing modules
- QStringList::Iterator it;
- for ( it = aModuleList.begin(); it != aModuleList.end(); ++it )
- {
- if ( (*it).isEmpty() )
- continue;
-
- QString modName = moduleName( *it );
-
- if (dir = getenv( modName + "_ROOT_DIR")) {
- root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("doc") + Qtx::addSlash("salome") +
- Qtx::addSlash("gui") + Qtx::addSlash(modName) );
- if ( QFileInfo( root + aFileName ).exists() ) {
-
- QAction* a = createAction( id, tr( moduleTitle(modName) + QString(" Help") ), QIconSet(),
- tr( moduleTitle(modName) + QString(" Help") ),
- tr( moduleTitle(modName) + QString(" Help") ),
- 0, desk, false, this, SLOT( onHelpContentsModule() ) );
- a->setName( modName );
- createMenu( a, helpModuleMenu, -1 );
- id++;
- }
- }
- }
-
- //! MRU
- QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
- connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
- registerAction( MRUId, mru );
-
- // default icon for neutral point ('SALOME' module)
- QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
- if ( defIcon.isNull() )
- defIcon = QPixmap( imageEmptyIcon );
-
- //! default icon for any module
- QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
- if ( modIcon.isNull() )
- modIcon = QPixmap( imageEmptyIcon );
-
- QStringList modList;
- modules( modList, false );
-
- if( modList.count()>1 )
- {
- QToolBar* modTBar = new QtxToolBar( true, desk );
- modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
-
- QActionGroup* modGroup = new QActionGroup( this );
- modGroup->setExclusive( true );
- modGroup->setUsesDropDown( true );
-
- a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
- tr( "PRP_APP_MODULE" ), 0, desk, true );
- modGroup->add( a );
- myActions.insert( QString(), a );
-
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
-
- const int iconSize = 20;
-
- modGroup->addTo( modTBar );
- QObjectList *l = modTBar->queryList( "QComboBox" );
- QObjectListIt oit( *l );
- while ( QObject* obj = oit.current() ) {
- QComboBox* cb = (QComboBox*)obj;
- if ( cb ) cb->setFocusPolicy( QWidget::NoFocus );
- ++oit;
- }
- delete l;
-
- modTBar->addSeparator();
-
- for ( it = modList.begin(); it != modList.end(); ++it )
- {
- if ( !isLibExists( *it ) )
- continue;
-
- QString iconName;
- if ( iconMap.contains( *it ) )
- iconName = iconMap[*it];
-
- QString modName = moduleName( *it );
-
- QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
- if ( icon.isNull() )
- {
- icon = modIcon;
- printf( "****************************************************************\n" );
- printf( "* Icon for %s not found. Using the default one.\n", (*it).latin1() );
- printf( "****************************************************************\n" );
- }
-
- icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
-
- QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
- a->addTo( modTBar );
- modGroup->add( a );
-
- myActions.insert( *it, a );
- }
-
- SUIT_Tools::simplifySeparators( modTBar );
- connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
- }
-
- // New window
- int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
- int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
- createMenu( separator(), windowMenu, -1, 1 );
-
-
-#ifndef DISABLE_GLVIEWER
- createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), ALT+Key_G );
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
- createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), ALT+Key_P );
-#endif
-#ifndef DISABLE_OCCVIEWER
- createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), ALT+Key_O );
-#endif
-#ifndef DISABLE_VTKVIEWER
- createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), ALT+Key_K );
-#endif
-
-
- createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
- SHIFT+Key_R, desk, false, this, SLOT( onRenameWindow() ) );
- createMenu( RenameId, windowMenu, -1 );
-
- int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
- createMenu( PreferencesId, fileMenu, 15, -1 );
- createMenu( separator(), fileMenu, -1, 15, -1 );
-
- /*
- createMenu( separator(), fileMenu, -1, 100, -1 );
- createMenu( MRUId, fileMenu, 100, -1 );
- createMenu( separator(), fileMenu, -1, 100, -1 );
- */
-}
-
-/*!On module activation action.*/
-void LightApp_Application::onModuleActivation( QAction* a )
-{
- if ( !a )
- return;
-
- QString modName = a->menuText();
- if ( modName == tr( "APP_NAME" ) )
- modName = QString::null;
-
- // Force user to create/open a study before module activation
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
- QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
- if ( icon.isNull() )
- icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
-
- bool cancelled = false;
- while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
- LightApp_ModuleDlg aDlg( desktop(), modName, icon );
- int res = aDlg.exec();
-
- switch ( res ){
- case 1:
- onNewDoc();
- break;
- case 2:
- onOpenDoc();
- break;
- case 3:
- //onLoadStudy();
- //break;
- case 0:
- default:
- putInfo( tr("INF_CANCELLED") );
- myActions[QString()]->setOn( true );
- cancelled = true;
- }
- }
-
- if ( !cancelled )
- activateModule( modName );
-}
-
-/*!Default module activation.*/
-QString LightApp_Application::defaultModule() const
-{
- QStringList aModuleNames;
- modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
- //! If there's the one and only module --> activate it automatically
- //! TODO: Possible improvement - default module can be taken from preferences
- return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
-}
-
-/*!On new window slot.*/
-void LightApp_Application::onNewWindow()
-{
- const QObject* obj = sender();
- if ( !obj || !obj->inherits( "QAction" ) )
- return;
-
- QString type;
- int id = actionId( (QAction*)obj );
- switch ( id )
- {
-#ifndef DISABLE_GLVIEWER
- case NewGLViewId:
- type = GLViewer_Viewer::Type();
- break;
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
- case NewPlot2dId:
- type = Plot2d_Viewer::Type();
- break;
-#endif
-#ifndef DISABLE_OCCVIEWER
- case NewOCCViewId:
- type = OCCViewer_Viewer::Type();
- break;
-#endif
-#ifndef DISABLE_VTKVIEWER
- case NewVTKViewId:
- type = VTKViewer_Viewer::Type();
- break;
-#endif
- }
-
- if ( !type.isEmpty() )
- createViewManager( type );
-}
-
-/*!
- SLOT: Creates new document
-*/
-void LightApp_Application::onNewDoc()
-{
- SUIT_Study* study = activeStudy();
-
- saveWindowsGeometry();
-
- CAM_Application::onNewDoc();
-
- if ( !study ) // new study will be create in THIS application
- {
- updateWindows();
- updateViewManagers();
- }
-}
-
-/*!
- SLOT: Opens new document
-*/
-void LightApp_Application::onOpenDoc()
-{
- SUIT_Study* study = activeStudy();
- saveWindowsGeometry();
-
- CAM_Application::onOpenDoc();
-
- if ( !study ) // new study will be create in THIS application
- {
- updateWindows();
- updateViewManagers();
- }
-}
-
-#include "SUIT_MessageBox.h"
-
-/*!
- SLOT: Opens new document.
- \param aName - name of file
-*/
-bool LightApp_Application::onOpenDoc( const QString& aName )
-{
- bool isAlreadyOpen = false;
-
- // Look among opened studies
- if (activeStudy()) { // at least one study is opened
- SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> aAppList = aSession->applications();
- QPtrListIterator<SUIT_Application> it (aAppList);
- SUIT_Application* aApp = 0;
- // iterate on all applications
- for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
- if (aApp->activeStudy()->studyName() == aName) {
- isAlreadyOpen = true; // Already opened, ask user what to do
-
- // The document ... is already open.
- // Do you want to reload it?
- int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
- tr("QUE_DOC_ALREADYOPEN").arg(aName),
- tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
- if (aAnswer == 1) { // reload
- if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
- // Opened in THIS (active) application.
- STD_Application* app1 = (STD_Application*)aAppList.at(0);
- STD_Application* app2 = (STD_Application*)aAppList.at(1);
- if (!app1 || !app2) {
- // Error
- return false;
- }
- if (app1->activeStudy()->studyName() == aName) {
- // app1 is this application, we need another one
- app1 = app2;
- }
- // Close document of this application. This application will be destroyed.
- onCloseDoc(/*ask = */false);
- // Open the file with another application, as this one will be destroyed.
- return app1->onOpenDoc(aName);
- } else {
- // Opened in another application.
- STD_Application* app = (STD_Application*)aApp;
- if (app)
- app->onCloseDoc(/*ask = */false);
- }
- } else { // do not reload
- // OK, the study will not be reloaded, but we call
- // CAM_Application::onOpenDoc( aName ) all the same.
- // It will activate a desktop of the study <aName>.
- }
- }
- }
- }
-
- bool res = CAM_Application::onOpenDoc( aName );
-
- QAction* a = action( MRUId );
- if ( a && a->inherits( "QtxMRUAction" ) )
- {
- QtxMRUAction* mru = (QtxMRUAction*)a;
- if ( res )
- mru->insert( aName );
- else
- mru->remove( aName );
- }
- return res;
-}
-
-/*!
- SLOT: Displays "About" message box
-*/
-void LightApp_Application::onHelpAbout()
-{
- LightApp_AboutDlg* dlg = new LightApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
- dlg->exec();
- delete dlg;
-}
-
-/*!
- SLOT: Loads document
- \param aName - name of document
-*/
-bool LightApp_Application::onLoadDoc( const QString& aName )
-{
- bool res = CAM_Application::onLoadDoc( aName );
-
- /*jfa tmp:QAction* a = action( MRUId );
- if ( a && a->inherits( "QtxMRUAction" ) )
- {
- QtxMRUAction* mru = (QtxMRUAction*)a;
- if ( res )
- mru->insert( aName );
- else
- mru->remove( aName );
- }*/
- return res;
-}
-
-/*!
- Private SLOT: Called on selection is changed
- Dispatchs active module that selection is changed
-*/
-void LightApp_Application::onSelection()
-{
- onSelectionChanged();
-
- if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
- ((LightApp_Module*)activeModule())->selectionChanged();
-}
-
-/*!
- Sets active study.
- \param study - SUIT_Study.
-*/
-void LightApp_Application::setActiveStudy( SUIT_Study* study )
-{
- CAM_Application::setActiveStudy( study );
-
- activateWindows();
-}
-
-/*!
- Enables/Disables menu items and toolbar buttons. Rebuild menu
-*/
-void LightApp_Application::updateCommandsStatus()
-{
- CAM_Application::updateCommandsStatus();
- QAction* a = 0;
-
-#ifndef DISABLE_GLVIEWER
- a = action( NewGLViewId );
- if( a )
- a->setEnabled( activeStudy() );
-#endif
-
-#ifndef DISABLE_PLOT2DVIEWER
- a = action( NewPlot2dId );
- if( a )
- a->setEnabled( activeStudy() );
-#endif
-
-#ifndef DISABLE_OCCVIEWER
- a = action( NewOCCViewId );
- if( a )
- a->setEnabled( activeStudy() );
-#endif
-
-#ifndef DISABLE_VTKVIEWER
- a = action( NewVTKViewId );
- if( a )
- a->setEnabled( activeStudy() );
-#endif
-}
-
-/*!
- \class RunBrowser
- Runs system command in separate thread
-*/
-class RunBrowser: public QThread {
-public:
-
- RunBrowser( LightApp_Application* app, QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
- myApp(theApp), myParams(theParams),
-#ifdef WIN32
- myHelpFile("file://" + theHelpFile + theContext),
-#else
- myHelpFile("file:" + theHelpFile + theContext),
-#endif
- myStatus(0),
- myLApp( app )
-{
-};
-
- virtual void run()
- {
- QString aCommand;
-
- if ( !myApp.isEmpty())
- {
- aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
-
- QProcess* proc = new QProcess();
- proc->addArgument( aCommand );
- //myStatus = system(aCommand);
-
- //if(myStatus != 0)
- if(!proc->start())
- {
- QCustomEvent* ce2000 = new QCustomEvent( 2000 );
- QString* msg = new QString( QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile) );
- ce2000->setData( msg );
- postEvent( myLApp, ce2000 );
- }
- }
- }
-
-private:
- QString myApp;
- QString myParams;
- QString myHelpFile;
- int myStatus;
- LightApp_Application* myLApp;
-};
-
-/*!
- SLOT: Displays help contents for choosen module
-*/
-void LightApp_Application::onHelpContentsModule()
-{
- const QAction* obj = (QAction*) sender();
-
- QString aComponentName = obj->name();
- QString aFileName = "index.htm";
- QString aFileNameKernel = "index.html";
-
- QCString dir = getenv( aComponentName + "_ROOT_DIR");
- QString homeDir = !aComponentName.compare(QString("KERNEL")) ?
- Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") ) :
- Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash("gui") + Qtx::addSlash(aComponentName) );
-
- QString helpFile = QFileInfo( homeDir + (!aComponentName.compare(QString("KERNEL")) ? aFileNameKernel : aFileName) ).absFilePath();
- SUIT_ResourceMgr* resMgr = resourceMgr();
- QString platform;
-#ifdef WIN32
- platform = "winapplication";
-#else
- platform = "application";
-#endif
- QString anApp = resMgr->stringValue("ExternalBrowser", platform);
-#ifdef WIN32
- QString quote("\"");
- anApp.prepend( quote );
- anApp.append( quote );
-#endif
- QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
-
- if (!anApp.isEmpty()) {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
- rs->start();
- }
- else {
- if( SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
- tr("DEFINE_EXTERNAL_BROWSER"),
- tr("BUT_OK"),tr("BUT_CANCEL"),0,1,0 )==0 )
- onPreferences();
- }
-}
-
-/*!
- SLOT: Displays help contents for choosen dialog
-*/
-void LightApp_Application::onHelpContextModule(const QString& theComponentName, const QString& theFileName)
-{
- QCString dir = getenv( theComponentName + "_ROOT_DIR");
- QString homeDir = Qtx::addSlash(Qtx::addSlash(dir)+Qtx::addSlash("doc")+Qtx::addSlash("salome")+Qtx::addSlash("gui")+Qtx::addSlash(theComponentName));
-
- QString helpFile = QFileInfo( homeDir + theFileName ).absFilePath();
- SUIT_ResourceMgr* resMgr = resourceMgr();
- QString platform;
-#ifdef WIN32
- platform = "winapplication";
-#else
- platform = "application";
-#endif
- QString anApp = resMgr->stringValue("ExternalBrowser", platform);
-#ifdef WIN32
- QString quote("\"");
- anApp.prepend( quote );
- anApp.append( quote );
-#endif
- QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
-
- if (!anApp.isEmpty()) {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
- rs->start();
- }
- else {
- if( SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
- tr("DEFINE_EXTERNAL_BROWSER"),
- tr("BUT_OK"), tr("BUT_CANCEL"),0,1,0)==0 )
- onPreferences();
- }
-}
-
-/*!
- Sets enable or disable some actions on selection changed.
-*/
-void LightApp_Application::onSelectionChanged()
-{
-}
-
-/*!
- \return window by key
- \param flag - key for window
- \param studyId - study id
- Flag used how identificator of window in windows list.
-*/
-QWidget* LightApp_Application::window( const int flag, const int studyId ) const
-{
- QWidget* wid = 0;
-
- int sId = studyId;
- if ( sId < 0 )
- {
- if ( !activeStudy() )
- return 0;
- else
- sId = activeStudy()->id();
- }
-
- if ( myWindows.contains( flag ) )
- wid = myWindows[flag]->widget( sId );
-
- return wid;
-}
-
-/*!
- Adds window to application.
- \param wid - QWidget
- \param flag - key for window
- \param studyId - study id
- Flag used how identificator of window in windows list.
-*/
-void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
-{
- if ( !wid )
- return;
-
- int sId = studyId;
- if ( sId < 0 )
- {
- if ( !activeStudy() )
- return;
- else
- sId = activeStudy()->id();
- }
-
- if ( !myWindows.contains( flag ) )
- {
- QMap<int, int> winMap;
- currentWindows( winMap );
-
- LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
- connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
- // asv: connecting a slot for storing visibility flag of a window
- connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
- myWindows.insert( flag, newWC );
- if ( winMap.contains( flag ) )
- desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
-
- myWindows[flag]->setResizeEnabled( true );
- myWindows[flag]->setCloseMode( QDockWindow::Always );
- myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
- myWindows[flag]->setFixedExtentWidth( wid->width() );
- myWindows[flag]->setFixedExtentHeight( wid->height() );
- }
-
- QFont f;
-#ifndef DISABLE_PYCONSOLE
- if( wid->inherits( "PythonConsole" ) )
- {
- if( resourceMgr()->hasValue( "PyConsole", "font" ) )
- f = resourceMgr()->fontValue( "PyConsole", "font" );
- else
- {
- f = ( ( PythonConsole* )wid )->font();
- resourceMgr()->setValue( "PyConsole", "font", f );
- }
- }
- else
-#endif
- f = wid->font();
-
- myWindows[flag]->insert( sId, wid );
- wid->setFont(f);
-
- setWindowShown( flag, !myWindows[flag]->isEmpty() );
-}
-
-/*!
- Removes window from application.
- \param flag - key for window
- \param studyId - study id
- Flag used how identificator of window in windows list.
-*/
-void LightApp_Application::removeWindow( const int flag, const int studyId )
-{
- if ( !myWindows.contains( flag ) )
- return;
-
- int sId = studyId;
- if ( sId < 0 )
- {
- if ( !activeStudy() )
- return;
- else
- sId = activeStudy()->id();
- }
-
- bool anIsEmpty = !myWindows[flag]->isEmpty();
- QWidget* wid = myWindows[flag]->widget( sId );
- myWindows[flag]->remove( sId );
- delete wid;
-
- //setWindowShown( flag, !myWindows[flag]->isEmpty() );
- setWindowShown( flag, anIsEmpty );
-}
-
-/*!
- Gets window.
- \param flag - key for window
- \param studyId - study id
- Flag used how identificator of window in windows list.
-*/
-QWidget* LightApp_Application::getWindow( const int flag, const int studyId )
-{
- QWidget* wid = window( flag, studyId );
- if ( !wid )
- addWindow( wid = createWindow( flag ), flag, studyId );
-
- return wid;
-}
-
-/*!
- \return is window visible
- \param type - flag of window
-*/
-bool LightApp_Application::isWindowVisible( const int type ) const
-{
- bool res = false;
- if ( myWindows.contains( type ) )
- {
- SUIT_Desktop* desk = ((LightApp_Application*)this)->desktop();
- res = desk && desk->appropriate( myWindows[type] );
- }
- return res;
-}
-
-/*!
- Sets window show or hide.
- \param type - window identificator.
- \param on - true/false (window show/hide)
-*/
-void LightApp_Application::setWindowShown( const int type, const bool on )
-{
- if ( !desktop() || !myWindows.contains( type ) )
- return;
-
- QDockWindow* dw = myWindows[type];
- desktop()->setAppropriate( dw, on );
- if( on )
- dw->show();
- else if( dw->isShown() )
- {
- dw->hide();
- myWindowsVisible[ type ] = true;
- }
-}
-
-/*!
- \return Object Browser
-*/
-OB_Browser* LightApp_Application::objectBrowser()
-{
- OB_Browser* ob = 0;
- QWidget* wid = window( WT_ObjectBrowser );
- if ( wid && wid->inherits( "OB_Browser" ) )
- ob = (OB_Browser*)wid;
- return ob;
-}
-
-/*!
- \return Log Window
-*/
-LogWindow* LightApp_Application::logWindow()
-{
- LogWindow* lw = 0;
- QWidget* wid = getWindow( WT_LogWindow );
- if ( wid->inherits( "LogWindow" ) )
- lw = (LogWindow*)wid;
- return lw;
-}
-
-#ifndef DISABLE_PYCONSOLE
-/*!
- \return Python Console
-*/
-PythonConsole* LightApp_Application::pythonConsole()
-{
- PythonConsole* console = 0;
- QWidget* wid = getWindow( WT_PyConsole );
- if ( wid->inherits( "PythonConsole" ) )
- console = (PythonConsole*)wid;
- return console;
-}
-#endif
-
-/*!
- Updates object browser and maybe data models
- \param updateModels - if it is true, then data models are updated
-*/
-void LightApp_Application::updateObjectBrowser( const bool updateModels )
-{
- // update existing data models
- if ( updateModels )
- {
- const bool isAutoUpdate = objectBrowser() ? objectBrowser()->isAutoUpdate() : true;
- if( objectBrowser() )
- objectBrowser()->setAutoUpdate( false );
-
- LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
- if ( study ) {
- CAM_Study::ModelList dm_list;
- study->dataModels( dm_list );
- for ( CAM_Study::ModelListIterator it( dm_list ); it.current(); ++it ) {
- CAM_DataModel* camDM = it.current();
- if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
- ((LightApp_DataModel*)camDM)->update();
- }
- }
-
- if( objectBrowser() )
- objectBrowser()->setAutoUpdate( isAutoUpdate );
- }
- if ( objectBrowser() )
- {
- objectBrowser()->updateGeometry();
- objectBrowser()->updateTree( 0, false );
- }
-}
-
-/*!
- \return preferences
-*/
-LightApp_Preferences* LightApp_Application::preferences() const
-{
- return preferences( false );
-}
-
-/*!
- \return first view manager of some type
- \param vmType - type of view manager
- \param create - is it necessary to create view manager in case, when there is no manager of such type
-*/
-SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
-{
- SUIT_ViewManager* aVM = viewManager( vmType );
- SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
-
- if ( anActiveVM && anActiveVM->getType() == vmType )
- aVM = anActiveVM;
-
- if ( aVM && create )
- {
- if ( !aVM->getActiveView() )
- aVM->createView();
- else
- aVM->getActiveView()->setFocus();
- }
- else if ( create )
- aVM = createViewManager( vmType );
-
- return aVM;
-}
-
-/*!
- Creates view manager of some type
- \param vmType - type of view manager
-*/
-SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
-{
- SUIT_ResourceMgr* resMgr = resourceMgr();
-
- SUIT_ViewManager* viewMgr = 0;
-#ifndef DISABLE_GLVIEWER
- if( vmType == GLViewer_Viewer::Type() )
- {
- viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
- new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
- }
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
- if( vmType == Plot2d_Viewer::Type() )
- {
- viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
- Plot2d_Viewer* vm;
-#ifndef DISABLE_SALOMEOBJECT
- vm = new SPlot2d_Viewer();
-#else
- vm = new Plot2d_Viewer();
-#endif
- viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
- Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
- if( wnd )
- {
- Plot2d_ViewFrame* frame = wnd->getViewFrame();
- frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
- }
- }
-#endif
- //#ifndef DISABLE_SUPERVGRAPHVIEWER
- // if( vmType == SUPERVGraph_Viewer::Type() )
- // {
- // viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
- // }
- //#endif
-#ifndef DISABLE_OCCVIEWER
- if( vmType == OCCViewer_Viewer::Type() )
- {
- viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
- OCCViewer_Viewer* vm;
-#ifndef DISABLE_SALOMEOBJECT
- vm = new SOCC_Viewer();
-#else
- vm = new OCCViewer_Viewer();
-#endif
- vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
- vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
- int u( 1 ), v( 1 );
- vm->isos( u, v );
- u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
- v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
- vm->setIsos( u, v );
- viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
- new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
- }
-#endif
-#ifndef DISABLE_VTKVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- if ( vmType == SVTK_Viewer::Type() )
-#else
- if ( vmType == VTKViewer_Viewer::Type() )
-#endif
- {
-#ifndef DISABLE_SALOMEOBJECT
- viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
- SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
- if( vm )
- {
- vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
- vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
- resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
- new LightApp_VTKSelector( vm, mySelMgr );
- }
-#else
- viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
- VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
- if ( vm )
- vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
-#endif
- }
-#endif
-
- if ( !viewMgr )
- return 0;
-
- addViewManager( viewMgr );
- SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
-
- if ( viewWin && desktop() )
- viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
-
- return viewMgr;
-}
-
-/*!
- SLOT: Removes view manager from application
-*/
-void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
-{
- removeViewManager( theVM );
-}
-
-/*!
- Protected SLOT: On study created.
- \param theStudy - just created study
-*/
-void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
-{
- SUIT_DataObject* aRoot = 0;
- if ( theStudy && theStudy->root() )
- {
- aRoot = theStudy->root();
- //aRoot->setName( tr( "DATA_MODELS" ) );
- }
- getWindow( WT_ObjectBrowser );
- if ( objectBrowser() != 0 )
- objectBrowser()->setRootObject( aRoot );
-
- activateModule( defaultModule() );
-
- if ( objectBrowser() )
- objectBrowser()->openLevels();
-
- activateWindows();
-}
-
-/*!
- Protected SLOT: On study opened.
- \param theStudy - just opened study
-*/
-void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
-{
- SUIT_DataObject* aRoot = 0;
- if ( theStudy && theStudy->root() )
- {
- aRoot = theStudy->root();
- //aRoot->dump();
- }
- getWindow( WT_ObjectBrowser );
- if ( objectBrowser() )
- objectBrowser()->setRootObject( aRoot );
-
- activateModule( defaultModule() );
-
- if ( objectBrowser() )
- objectBrowser()->openLevels();
-
- activateWindows();
-
- emit studyOpened();
-}
-
-/*!Protected SLOT. On study saved.*/
-void LightApp_Application::onStudySaved( SUIT_Study* )
-{
- emit studySaved();
-}
-
-/*!Protected SLOT. On study closed.*/
-void LightApp_Application::onStudyClosed( SUIT_Study* s )
-{
- // Bug 10396: clear selection
- mySelMgr->clearSelected();
-
- // Bug 12944: emit signal only after clear selection
- emit studyClosed();
-
- activateModule( "" );
-
- for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
- removeWindow( itr.key(), s->id() );
-}
-
-/*!Protected SLOT.On desktop activated.*/
-void LightApp_Application::onDesktopActivated()
-{
- CAM_Application::onDesktopActivated();
- LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
- if(aModule)
- aModule->studyActivated();
-}
-
-/*!Gets file filter.
- *\retval QString "(*.bin)"
- */
-QString LightApp_Application::getFileFilter() const
-{
- //return "(*.bin)";
- // HDF persistence
- return "(*.hdf)";
-}
-
-/*!
- Shows file dialog and return user selected file name
-*/
-QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent )
-{
- if ( !parent )
- parent = desktop();
- QStringList fls = QStringList::split( ";;", filters, false );
- return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
-}
-
-/*! Gets directory*/
-QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
-{
- if ( !parent )
- parent = desktop();
- return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
-}
-
-/*! Get open file names*/
-QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent )
-{
- if ( !parent )
- parent = desktop();
- QStringList fls = QStringList::split( ";;", filters, false );
- return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
-}
-
-/*!Private SLOT. Update object browser.*/
-void LightApp_Application::onRefresh()
-{
- updateObjectBrowser( true );
-}
-
-/*!Private SLOT. On preferences.*/
-void LightApp_Application::onPreferences()
-{
- QApplication::setOverrideCursor( Qt::waitCursor );
-
- LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
-
- QApplication::restoreOverrideCursor();
-
- if ( !prefDlg )
- return;
-
- if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() ) {
- if ( desktop() )
- desktop()->saveGeometry( resourceMgr(), "desktop" );
- resourceMgr()->save();
- }
-
- delete prefDlg;
-}
-
-/*!Protected SLOT. On preferences changed.*/
-void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
-{
- LightApp_Module* sMod = 0;
- CAM_Module* mod = module( modName );
- if ( mod && mod->inherits( "LightApp_Module" ) )
- sMod = (LightApp_Module*)mod;
-
- if ( sMod )
- sMod->preferencesChanged( section, param );
- else
- preferencesChanged( section, param );
-}
-
-/*!Private SLOT. On open document with name \a aName.*/
-void LightApp_Application::onMRUActivated( QString aName )
-{
- onOpenDoc( aName );
-}
-
-/*!Remove all windows from study.*/
-void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
-{
- CAM_Application::beforeCloseDoc( s );
-}
-
-/*!Update actions.*/
-void LightApp_Application::updateActions()
-{
- updateCommandsStatus();
-}
-
-/*!
- Creates new study
-*/
-SUIT_Study* LightApp_Application::createNewStudy()
-{
- LightApp_Application::lastStudyId++;
-
- LightApp_Study* aStudy = new LightApp_Study( this );
-
- // Set up processing of major study-related events
- connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
- connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
- connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
- connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
-
- return aStudy;
-}
-
-/*!
- Creates window by flag.
- \param flag - identificator of window type
-*/
-QWidget* LightApp_Application::createWindow( const int flag )
-{
- QWidget* wid = 0;
- if ( flag == WT_ObjectBrowser )
- {
- OB_Browser* ob = new OB_Browser( desktop() );
- ob->setAutoUpdate( true );
- //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
- ob->setCaption( tr( "OBJECT_BROWSER" ) );
-
- OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
- if( ob_list )
- ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
-
- ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
- ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
-
- // Create OBSelector
- new LightApp_OBSelector( ob, mySelMgr );
-
- wid = ob;
-
- ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
- }
-#ifndef DISABLE_PYCONSOLE
- else if ( flag == WT_PyConsole )
- {
- PythonConsole* pyCons = new PythonConsole( desktop() );
- pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
- wid = pyCons;
- // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
- }
-#endif
- else if ( flag == WT_LogWindow )
- {
- LogWindow* logWin = new LogWindow( desktop() );
- logWin->setCaption( tr( "LOG_WINDOW" ) );
- wid = logWin;
- logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
- }
- return wid;
-}
-
-/*!
- \return default windows( Object Browser, Python Console )
- Adds to map \a aMap.
- */
-void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
-{
- aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
-#ifndef DISABLE_PYCONSOLE
- aMap.insert( WT_PyConsole, Qt::DockBottom );
-#endif
- // aMap.insert( WT_LogWindow, Qt::DockBottom );
-}
-
-/*!Default view managers*/
-void LightApp_Application::defaultViewManagers( QStringList& ) const
-{
- /*!Do nothing.*/
-}
-
-/*!
- \return preferences.
- Create preferences, if \a crt = true.
-*/
-LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
-{
- if ( myPrefs )
- return myPrefs;
-
- LightApp_Application* that = (LightApp_Application*)this;
-
- bool toCreate = !_prefs_ && crt;
- if( toCreate )
- {
- _prefs_ = new LightApp_Preferences( resourceMgr() );
- that->createPreferences( _prefs_ );
- }
-
- that->myPrefs = _prefs_;
-
- QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
- for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
- {
- if ( !appIt.current()->inherits( "LightApp_Application" ) )
- continue;
-
- LightApp_Application* app = (LightApp_Application*)appIt.current();
-
- QStringList modNameList;
- app->modules( modNameList, false );
- for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
- {
- int id = _prefs_->addPreference( *it );
- _prefs_->setItemProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
- }
-
- ModuleList modList;
- app->modules( modList );
- for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
- {
- LightApp_Module* mod = 0;
- if ( itr.current()->inherits( "LightApp_Module" ) )
- mod = (LightApp_Module*)itr.current();
-
- if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
- {
- int modCat = _prefs_->addPreference( mod->moduleName() );
- _prefs_->setItemProperty( modCat, "info", QString::null );
- if( toCreate )
- mod->createPreferences();
- }
- }
- }
-
- connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
- this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
-
- return myPrefs;
-}
-
-/*!
- Adds new module to application
-*/
-void LightApp_Application::moduleAdded( CAM_Module* mod )
-{
- CAM_Application::moduleAdded( mod );
-
- LightApp_Module* lightMod = 0;
- if ( mod && mod->inherits( "LightApp_Module" ) )
- lightMod = (LightApp_Module*)mod;
-
- if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
- {
- int modCat = myPrefs->addPreference( mod->moduleName() );
- myPrefs->setItemProperty( modCat, "info", QString::null );
- lightMod->createPreferences();
- }
-}
-
-/*!
- Create preferences
-*/
-void LightApp_Application::createPreferences( LightApp_Preferences* pref )
-{
- if ( !pref )
- return;
-
- int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
-
- int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
- int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
- pref->setItemProperty( studyGroup, "columns", 1 );
-
- pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
- pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
- pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
-
- int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
- pref->setItemProperty( extgroup, "columns", 1 );
- QString platform;
-#ifdef WIN32
- platform = "winapplication";
-#else
- platform = "application";
-#endif
- int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
- pref->setItemProperty( apppref, "existing", true );
- pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
- pref->setItemProperty( apppref, "readOnly", false );
-
- pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
-
- int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
- pref->setItemProperty( pythonConsoleGroup, "columns", 1 );
- pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
-
- int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
-
- int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
-
- int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
-
- int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), viewTab );
-
- int supervGroup = pref->addPreference( tr( "PREF_GROUP_SUPERV" ), viewTab );
-
- pref->setItemProperty( occGroup, "columns", 1 );
- pref->setItemProperty( vtkGroup, "columns", 1 );
- pref->setItemProperty( plot2dGroup, "columns", 1 );
-
- int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
- LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
- pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
- LightApp_Preferences::Color, "OCCViewer", "background" );
-
- pref->setItemProperty( occTS, "min", 1.0E-06 );
- pref->setItemProperty( occTS, "max", 1000 );
-
- int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
- LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
- int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
- LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
-
- pref->setItemProperty( isoU, "min", 0 );
- pref->setItemProperty( isoU, "max", 100000 );
-
- pref->setItemProperty( isoV, "min", 0 );
- pref->setItemProperty( isoV, "max", 100000 );
-
- int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
- LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" );
- pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
- pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
- LightApp_Preferences::Color, "VTKViewer", "background" );
-
- pref->setItemProperty( vtkTS, "min", 1.0E-06 );
- pref->setItemProperty( vtkTS, "max", 150 );
-
- pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
- LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
-
- int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
- LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
- QStringList aLegendPosList;
- aLegendPosList.append( tr("PREF_LEFT") );
- aLegendPosList.append( tr("PREF_RIGHT") );
- aLegendPosList.append( tr("PREF_TOP") );
- aLegendPosList.append( tr("PREF_BOTTOM") );
-
- QValueList<QVariant> anIndexesList;
- anIndexesList.append(0);
- anIndexesList.append(1);
- anIndexesList.append(2);
- anIndexesList.append(3);
-
- pref->setItemProperty( legendPosition, "strings", aLegendPosList );
- pref->setItemProperty( legendPosition, "indexes", anIndexesList );
-
- int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
- LightApp_Preferences::Selector, "Plot2d", "CurveType" );
- QStringList aCurveTypesList;
- aCurveTypesList.append( tr("PREF_POINTS") );
- aCurveTypesList.append( tr("PREF_LINES") );
- aCurveTypesList.append( tr("PREF_SPLINE") );
-
- anIndexesList.clear();
- anIndexesList.append(0);
- anIndexesList.append(1);
- anIndexesList.append(2);
-
- pref->setItemProperty( curveType, "strings", aCurveTypesList );
- pref->setItemProperty( curveType, "indexes", anIndexesList );
-
- int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
- LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
-
- pref->setItemProperty( markerSize, "min", 0 );
- pref->setItemProperty( markerSize, "max", 100 );
-
- QStringList aScaleModesList;
- aScaleModesList.append( tr("PREF_LINEAR") );
- aScaleModesList.append( tr("PREF_LOGARITHMIC") );
-
- anIndexesList.clear();
- anIndexesList.append(0);
- anIndexesList.append(1);
-
- int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
- LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
-
- pref->setItemProperty( horScale, "strings", aScaleModesList );
- pref->setItemProperty( horScale, "indexes", anIndexesList );
-
- int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
- LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
-
- pref->setItemProperty( verScale, "strings", aScaleModesList );
- pref->setItemProperty( verScale, "indexes", anIndexesList );
-
- pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
- LightApp_Preferences::Color, "Plot2d", "Background" );
-
- int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
- int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
- pref->setItemProperty( dirGroup, "columns", 1 );
- pref->addPreference( tr( "" ), dirGroup,
- LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
-
- pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), supervGroup,
- LightApp_Preferences::Color, "SUPERVGraph", "Background" );
- pref->addPreference( tr( "PREF_SUPERV_TITLE_COLOR" ), supervGroup,
- LightApp_Preferences::Color, "SUPERVGraph", "Title" );
-// pref->addPreference( tr( "PREF_SUPERV_CTRL_COLOR" ), supervGroup,
-// LightApp_Preferences::Color, "SUPERVGraph", "Ctrl" );
-
- int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
- int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab );
- pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
- "ObjectBrowser", "auto_size_first" );
- pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
- "ObjectBrowser", "auto_size" );
-}
-
-/*!
- Changes appearance of application according to changed preferences
- \param sec - section
- \param param - name of changed parameter
-*/
-void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
-{
- SUIT_ResourceMgr* resMgr = resourceMgr();
- if ( !resMgr )
- return;
-
-#ifndef DISABLE_OCCVIEWER
- if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
- {
- double sz = resMgr->doubleValue( sec, param, -1 );
- QPtrList<SUIT_ViewManager> lst;
- viewManagers( OCCViewer_Viewer::Type(), lst );
- for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
- {
- SUIT_ViewModel* vm = it.current()->getViewModel();
- if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
- continue;
-
- OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
- occVM->setTrihedronSize( sz );
- occVM->getAISContext()->UpdateCurrentViewer();
- }
- }
-#endif
-
-#ifndef DISABLE_VTKVIEWER
- if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
- {
- double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
- bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
- QPtrList<SUIT_ViewManager> lst;
-#ifndef DISABLE_SALOMEOBJECT
- viewManagers( SVTK_Viewer::Type(), lst );
- for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
- {
- SUIT_ViewModel* vm = it.current()->getViewModel();
- if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
- continue;
-
- SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
- if( vtkVM )
- {
- vtkVM->setTrihedronSize( sz, isRelative );
- vtkVM->Repaint();
- }
- }
-#endif
- }
-#endif
-
-#ifndef DISABLE_OCCVIEWER
- if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
- {
- QPtrList<SUIT_ViewManager> lst;
- viewManagers( OCCViewer_Viewer::Type(), lst );
- int u = resMgr->integerValue( sec, "iso_number_u" );
- int v = resMgr->integerValue( sec, "iso_number_v" );
- for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
- {
- OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.current() );
- if( mgr && mgr->getOCCViewer() )
- mgr->getOCCViewer()->setIsos( u, v );
- }
- }
-#endif
-
- if( sec=="ObjectBrowser" )
- {
- if( param=="auto_size" || param=="auto_size_first" )
- {
- OB_Browser* ob = objectBrowser();
- if( !ob )
- return;
-
- bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
- autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
- ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
- ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
- if( autoSize )
- for( int i=1; i<ob->listView()->columns(); i++ )
- if( ob->listView()->columnWidth( i )>0 )
- ob->listView()->adjustColumn( i );
- updateObjectBrowser( false );
- }
- }
-
- if( sec=="Study" )
- {
- if( param=="store_positions" )
- updateWindows();
- }
-
-#ifndef DISABLE_PYCONSOLE
- if( sec=="PyConsole" )
- {
- if( param=="font" )
- if( pythonConsole() )
- pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
- }
-#endif
-}
-
-/*!
- Saves preferences
-*/
-void LightApp_Application::savePreferences()
-{
- saveWindowsGeometry();
-
- if ( resourceMgr() )
- {
- if ( desktop() )
- desktop()->saveGeometry( resourceMgr(), "desktop" );
- resourceMgr()->save();
- }
-}
-
-/*!
- Updates desktop title
-*/
-void LightApp_Application::updateDesktopTitle() {
- QString aTitle = applicationName();
- QString aVer = applicationVersion();
- if ( !aVer.isEmpty() )
- aTitle += QString( " " ) + aVer;
-
- if ( activeStudy() ) {
- QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
- aTitle += QString( " - [%1]" ).arg( sName );
- }
-
- desktop()->setCaption( aTitle );
-}
-
-/*!
- Updates windows after close document
-*/
-void LightApp_Application::afterCloseDoc()
-{
- updateWindows();
-
- CAM_Application::afterCloseDoc();
-}
-
-/*!
- Updates actions of active module
-*/
-void LightApp_Application::updateModuleActions()
-{
- QString modName;
- if ( activeModule() )
- modName = activeModule()->moduleName();
-
- if ( myActions.contains( modName ) )
- myActions[modName]->setOn( true );
-}
-
-/*!
- Gets current windows.
- \param winMap - output current windows map.
-*/
-void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
-{
- winMap.clear();
- if ( !activeStudy() )
- return;
-
- if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
- ((LightApp_Module*)activeModule())->windows( winMap );
- else
- defaultWindows( winMap );
-}
-
-/*!
- Gets current view managers.
- \param lst - output current view managers list.
-*/
-void LightApp_Application::currentViewManagers( QStringList& lst ) const
-{
- lst.clear();
- if ( !activeStudy() )
- return;
-
- if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
- ((LightApp_Module*)activeModule())->viewManagers( lst );
- else
- defaultViewManagers( lst );
-}
-
-/*!
- Updates windows
-*/
-void LightApp_Application::updateWindows()
-{
- QMap<int, int> winMap;
- currentWindows( winMap );
-
- if ( activeStudy() ) {
- for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
- getWindow( it.key() );
-
- loadWindowsGeometry();
- }
-
- // setWindowShown should be done even if no study is active (open). in this case all open windows
- // will be hidden, which is neccessary in this case.
- for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) {
-
- if ( myWindowsVisible.contains( itr.key() ) &&
- !myWindowsVisible[ itr.key() ] )
- continue;
-
- setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
- }
-}
-
-/*!
- Updates view managers
-*/
-void LightApp_Application::updateViewManagers()
-{
- QStringList lst;
- currentViewManagers( lst );
-
- for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
- getViewManager( *it, true );
-}
-
-/*!
- Loads windows geometry
-*/
-void LightApp_Application::loadWindowsGeometry()
-{
- bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
- if( !store )
- return;
-
- QtxDockAction* dockMgr = 0;
-
- QAction* a = action( ViewWindowsId );
- if ( a && a->inherits( "QtxDockAction" ) )
- dockMgr = (QtxDockAction*)a;
-
- if ( !dockMgr )
- return;
-
- QString modName;
- if ( activeModule() )
- modName = activeModule()->name("");
-
- QString section = QString( "windows_geometry" );
- if ( !modName.isEmpty() )
- section += QString( "." ) + modName;
-
- dockMgr->loadGeometry( resourceMgr(), section, false );
- dockMgr->restoreGeometry();
-}
-
-/*!
- Saves windows geometry
-*/
-void LightApp_Application::saveWindowsGeometry()
-{
- bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
- if( !store )
- return;
-
- QtxDockAction* dockMgr = 0;
-
- QAction* a = action( ViewWindowsId );
- if ( a && a->inherits( "QtxDockAction" ) )
- dockMgr = (QtxDockAction*)a;
-
- if ( !dockMgr )
- return;
-
- QString modName;
- if ( activeModule() )
- modName = activeModule()->name("");
-
- QString section = QString( "windows_geometry" );
- if ( !modName.isEmpty() )
- section += QString( "." ) + modName;
-
- dockMgr->storeGeometry();
- dockMgr->saveGeometry( resourceMgr(), section, false );
-}
-
-/*!
- Activates windows
-*/
-void LightApp_Application::activateWindows()
-{
- if ( activeStudy() )
- {
- for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
- itr.data()->activate( activeStudy()->id() );
- }
-}
-
-/*!
- Adds icon names for modules
-*/
-void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
-{
- iconMap.clear();
-
- SUIT_ResourceMgr* resMgr = resourceMgr();
- if ( !resMgr )
- return;
-
- QStringList modList;
- modules( modList, false );
-
- for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
- {
- QString modName = *it;
- QString modIntr = moduleName( modName );
- QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
-
- if ( modIcon.isEmpty() )
- continue;
-
- if ( SUIT_Tools::extension( modIcon ).isEmpty() )
- modIcon += QString( ".png" );
-
- iconMap.insert( modName, modIcon );
- }
-}
-
-/*!
- Inserts items in popup, which necessary for current application
-*/
-void LightApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
-{
- CAM_Application::contextMenuPopup( type, thePopup, title );
-
- OB_Browser* ob = objectBrowser();
- if ( !ob || type != ob->popupClientType() )
- return;
-
- thePopup->insertSeparator();
- thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
-}
-
-/*!
- Create empty study
-*/
-void LightApp_Application::createEmptyStudy()
-{
- CAM_Application::createEmptyStudy();
- if ( objectBrowser() )
- objectBrowser()->updateTree();
-}
-
-/*!
- Activates module
- \param mod - module to be activated
-*/
-bool LightApp_Application::activateModule( CAM_Module* mod )
-{
- bool res = CAM_Application::activateModule( mod );
- if ( objectBrowser() )
- objectBrowser()->updateTree();
- return res;
-}
-
-/*!
- \return keyborad accelerators manager object
-*/
-SUIT_Accel* LightApp_Application::accel() const
-{
- return myAccel;
-}
-
-/*!
- Removes dead widget container from map
-*/
-void LightApp_Application::onWCDestroyed( QObject* ob )
-{
- // remove destroyed widget container from windows map
- for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
- {
- if ( itr.data() != ob )
- continue;
-
- int key = itr.key();
- myWindows.remove( key );
- break;
- }
-}
-
-/*!
- Connects just added view manager
-*/
-void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
-{
- connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
- this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
- STD_Application::addViewManager( vm );
-}
-
-/*!
- Remove view manager from memory
-*/
-void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
-{
- disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
- this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
- STD_Application::removeViewManager( vm );
- delete vm;
-}
-
-/*!
- Renames active window of desktop
-*/
-void LightApp_Application::onRenameWindow()
-{
- if( !desktop() )
- return;
-
- QWidget* w = desktop()->activeWindow();
- if( !w )
- return;
-
- bool ok;
- QString name = QInputDialog::getText( tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->caption(), &ok, w );
- if( ok && !name.isEmpty() )
- w->setCaption( name );
-}
-
-/*!
- \return if the library of module exists
- \param moduleTitle - title of module
-*/
-bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
-{
- if( moduleTitle.isEmpty() )
- return false;
-
- QString lib = moduleLibrary( moduleTitle );
-
- //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
- bool isPythonModule = lib.contains("SalomePyQtGUI");
-
- QStringList paths;
-#ifdef WIN32
- paths = QStringList::split( ";", ::getenv( "PATH" ) );
-#else
- paths = QStringList::split( ":", ::getenv( "LD_LIBRARY_PATH" ) );
-#endif
-
- bool isLibFound = false;
- QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
-
- if( inf.exists() )
- {
- isLibFound = true;
- break;
- }
- }
-
- if ( !isLibFound )
- {
- printf( "****************************************************************\n" );
- printf( "* Warning: library %s cannot be found\n", moduleTitle.latin1() );
- printf( "* Module will not be available\n" );
- printf( "****************************************************************\n" );
- }
- else if ( !isPythonModule )
- return true;
-
- if ( isPythonModule )
- {
- QString pylib = moduleName( moduleTitle ) + QString(".py");
- QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
-
- // Check the python library
-#ifdef WIN32
- paths = QStringList::split( ";", ::getenv( "PATH" ) );
-#else
- paths = QStringList::split( ":", ::getenv( "PYTHONPATH" ) );
-#endif
- bool isPyLib = false, isPyGuiLib = false;
- QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
- QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
-
- if( !isPyLib && inf.exists() )
- isPyLib = true;
-
- if( !isPyGuiLib && infgui.exists() )
- isPyGuiLib = true;
-
- if ( isPyLib && isPyGuiLib && isLibFound)
- return true;
- }
-
- printf( "****************************************************************\n" );
- printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.latin1() );
- if (!isPyLib)
- printf( "* No module named %s\n", moduleName( moduleTitle ).latin1() );
- if (!isPyGuiLib)
- printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).latin1() );
- printf( "****************************************************************\n" );
- return true;
- }
- return false;
-}
-
-/*!
- \return default name for an active study
-*/
-void LightApp_Application::setDefaultStudyName( const QString& theName )
-{
- QStringList anInfoList;
- modules( anInfoList, false );
-
- LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
- if( anInfoList.count() == 1 && // to avoid a conflict between different modules
- !aStudy->isSaved() )
- {
- aStudy->setStudyName( theName );
- updateDesktopTitle();
- }
-}
-
-/*! slot, called on show/hide of a dock window */
-void LightApp_Application::onVisibilityChanged( bool visible )
-{
- const QObject* win = sender();
-
- for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
- if ( itr.data() == win )
- {
- myWindowsVisible[ itr.key() ] = visible;
- return;
- }
-}
-
-/*!
- Custom event handler
-*/
-bool LightApp_Application::event( QEvent* e )
-{
- if( e && e->type()==2000 )
- {
- QCustomEvent* ce = ( QCustomEvent* )e;
- QString* d = ( QString* )ce->data();
- if( SUIT_MessageBox::warn2(0, tr("WRN_WARNING"),
- d ? *d : "",
- tr("BUT_OK"), tr("BUT_CANCEL"), 0, 1, 0 )==0 )
- onPreferences();
- if( d )
- delete d;
- return true;
- }
- return CAM_Application::event( e );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Application.h
-// Created: 6/20/2005 18:39:25 PM
-// Author: OCC team
-// Copyright (C) CEA 2005
-
-#ifndef LIGHTAPP_APPLICATION_H
-#define LIGHTAPP_APPLICATION_H
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#include "LightApp.h"
-#include <CAM_Application.h>
-
-class LogWindow;
-class OB_Browser;
-#ifndef DISABLE_PYCONSOLE
- class PythonConsole;
-#endif
-class STD_Application;
-class LightApp_WidgetContainer;
-class LightApp_Preferences;
-class LightApp_SelectionMgr;
-class SUIT_Study;
-class SUIT_Accel;
-class CAM_Module;
-
-class QString;
-class QWidget;
-class QStringList;
-class QPixmap;
-
-#ifdef WIN32
-#pragma warning( disable:4251 )
-#endif
-
-/*!
- Description : Application containing only LightApp module
-*/
-
-class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
-{
- Q_OBJECT
-
-public:
- typedef enum { WT_ObjectBrowser,
-#ifndef DISABLE_PYCONSOLE
- WT_PyConsole,
-#endif
- WT_LogWindow,
- WT_User }
- WindowTypes;
-
- enum { MenuWindowId = 6 };
-
- enum { RenameId = CAM_Application::UserID,
-
-#ifndef DISABLE_GLVIEWER
- NewGLViewId ,
-#endif
-
-#ifndef DISABLE_PLOT2DVIEWER
- NewPlot2dId,
-#endif
-
-#ifndef DISABLE_OCCVIEWER
- NewOCCViewId,
-#endif
-
-#ifndef DISABLE_VTKVIEWER
- NewVTKViewId,
-#endif
-
- PreferencesId, MRUId, UserID };
-public:
- LightApp_Application();
- virtual ~LightApp_Application();
-
- virtual QString applicationName() const;
- virtual QString applicationVersion() const;
-
- virtual CAM_Module* loadModule( const QString& );
- virtual bool activateModule( const QString& );
-
- virtual bool useStudy( const QString& );
-
- LightApp_SelectionMgr* selectionMgr() const;
-
- LogWindow* logWindow();
- OB_Browser* objectBrowser();
-#ifndef DISABLE_PYCONSOLE
- PythonConsole* pythonConsole();
-#endif
-
- virtual void updateObjectBrowser( const bool = true );
-
- LightApp_Preferences* preferences() const;
-
- virtual QString getFileFilter() const;
-
- virtual QString getFileName( bool open, const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent );
- virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
- virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent );
-
- void updateActions();
-
- SUIT_ViewManager* getViewManager( const QString&, const bool );
- virtual void addViewManager( SUIT_ViewManager* );
- virtual void removeViewManager( SUIT_ViewManager* );
- virtual SUIT_ViewManager* createViewManager( const QString& vmType );
-
- QWidget* getWindow( const int, const int = -1 );
- QWidget* window( const int, const int = -1 ) const;
- void addWindow( QWidget*, const int, const int = -1 );
- void removeWindow( const int, const int = -1 );
-
- bool isWindowVisible( const int ) const;
- void setWindowShown( const int, const bool );
-
- virtual void start();
-
- virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
-
- virtual void createEmptyStudy();
-
- SUIT_Accel* accel() const;
-
- void setDefaultStudyName( const QString& theName );
-
- static int studyId();
-
- virtual bool event( QEvent* );
-
-signals:
- void studyOpened();
- void studySaved();
- void studyClosed();
-
-public slots:
- virtual void onHelpContentsModule();
- virtual void onHelpContextModule( const QString&, const QString& );
- virtual void onNewDoc();
- virtual void onOpenDoc();
- virtual void onHelpAbout();
- virtual bool onOpenDoc( const QString& );
- virtual bool onLoadDoc( const QString& );
-
-protected:
- virtual void createActions();
- virtual void createActionForViewer( const int id,
- const int parentId,
- const QString& suffix,
- const int accel );
- virtual SUIT_Study* createNewStudy();
- virtual QWidget* createWindow( const int );
- virtual void defaultWindows( QMap<int, int>& ) const;
- void defaultViewManagers( QStringList& ) const;
-
- virtual void setActiveStudy( SUIT_Study* );
- virtual void updateCommandsStatus();
- virtual void onSelectionChanged();
-
- virtual void beforeCloseDoc( SUIT_Study* );
- virtual void afterCloseDoc();
- virtual void moduleAdded( CAM_Module* );
- virtual bool activateModule( CAM_Module* = 0 );
-
- LightApp_Preferences* preferences( const bool ) const;
- virtual void createPreferences( LightApp_Preferences* );
- virtual void preferencesChanged( const QString&, const QString& );
- virtual void savePreferences();
- virtual void updateDesktopTitle();
-
-protected slots:
- virtual void onDesktopActivated();
-
- void onNewWindow();
- void onModuleActivation( QAction* );
- void onCloseView( SUIT_ViewManager* );
-
- void onStudyCreated( SUIT_Study* );
- void onStudyOpened( SUIT_Study* );
- void onStudySaved( SUIT_Study* );
- void onStudyClosed( SUIT_Study* );
-
- void onWCDestroyed( QObject* );
-
-private slots:
- void onSelection();
- void onRefresh();
- void onPreferences();
- void onMRUActivated( QString );
- void onPreferenceChanged( QString&, QString&, QString& );
- void onRenameWindow();
- void onVisibilityChanged( bool );
-
-protected:
- void updateWindows();
- void updateViewManagers();
- void updateModuleActions();
-
- void loadWindowsGeometry();
- void saveWindowsGeometry();
-
- void updatePreference( const QString&, const QString&, const QString& );
-
- QString defaultModule() const;
- void currentWindows( QMap<int, int>& ) const;
- void currentViewManagers( QStringList& ) const;
- void moduleIconNames( QMap<QString, QString>& ) const;
-
- void activateWindows();
- bool isLibExists( const QString& ) const;
-
-protected:
- typedef QMap<QString, QAction*> ActionMap;
- typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
- typedef QMap<int, bool> WindowVisibilityMap;
-
-protected:
- LightApp_Preferences* myPrefs;
- LightApp_SelectionMgr* mySelMgr;
- ActionMap myActions;
- WindowMap myWindows;
- WindowVisibilityMap myWindowsVisible;
-
- SUIT_Accel* myAccel;
-
- static LightApp_Preferences* _prefs_;
-
- static int lastStudyId;
-};
-
-#ifdef WIN32
-#pragma warning( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_DataModel.cxx
-// Created: 10/25/2004 10:36:06 AM
-// Author: Sergey LITONIN
-// Copyright (C) CEA 2004
-
-#include "LightApp_DataModel.h"
-#include "LightApp_Study.h"
-#include "LightApp_RootObject.h"
-#include "LightApp_DataObject.h"
-#include "LightApp_Module.h"
-#include "LightApp_Application.h"
-
-#include <OB_Browser.h>
-
-#include <SUIT_Application.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-#include <SUIT_DataObject.h>
-
-/*!
- Constructor
-*/
-LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
-: CAM_DataModel( theModule )
-{
-}
-
-/*!
- Destructor
-*/
-LightApp_DataModel::~LightApp_DataModel()
-{
-}
-
-/*!
- Emit opened()
-*/
-bool LightApp_DataModel::open( const QString&, CAM_Study* study, QStringList )
-{
- emit opened(); //TODO: is it really needed? to be removed maybe...
- return true;
-}
-
-/*!
- Emit saved()
-*/
-bool LightApp_DataModel::save( QStringList& )
-{
- emit saved();
- return true;
-}
-
-/*!
- Emit saved()
-*/
-bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& )
-{
- emit saved();
- return true;
-}
-
-/*!
- Emit closed()
-*/
-bool LightApp_DataModel::close()
-{
- emit closed();
- return true;
-}
-
-/*!
- Build whole data model tree
-*/
-void LightApp_DataModel::build()
-{
-}
-
-/*!
- Updates data model presentation in some widgets (for example, in object browser
-*/
-void LightApp_DataModel::updateWidgets()
-{
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
- if( app )
- app->objectBrowser()->updateTree( 0, false );
-}
-
-/*!
- Default behaviour of data model update for light modules
-*/
-void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* )
-{
- LightApp_ModuleObject* modelRoot = dynamic_cast<LightApp_ModuleObject*>( root() );
- DataObjectList ch;
- if( modelRoot )
- {
- ch = modelRoot->children();
- for ( DataObjectListIterator it( ch ); it.current(); ++it )
- it.current()->setParent( 0 );
- }
- build();
- updateWidgets();
- for( DataObjectListIterator it( ch ); it.current(); ++it )
- it.current()->deleteLater();
-}
-
-/*!
- \return corresponding module
-*/
-LightApp_Module* LightApp_DataModel::getModule() const
-{
- return dynamic_cast<LightApp_Module*>( module() );
-}
-
-/*!
- \return corresponding study
-*/
-LightApp_Study* LightApp_DataModel::getStudy() const
-{
- LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root()->root() );
- if ( !aRoot )
- return 0;
- return aRoot->study();
-}
-
-/*!
- default implementation, always returns false so as not to mask study's isModified()
-*/
-bool LightApp_DataModel::isModified() const
-{
- return false;
-}
-
-/*!
- default implementation, always returns true so as not to mask study's isSaved()
-*/
-bool LightApp_DataModel::isSaved() const
-{
- return true;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_DataModel.h
-// Created: 10/25/2004 10:32:33 AM
-// Author: Sergey LITONIN
-// Copyright (C) CEA 2004
-
-#ifndef LIGHTAPP_DATAMODEL_H
-#define LIGHTAPP_DATAMODEL_H
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#include "LightApp.h"
-#include "CAM_DataModel.h"
-
-class LightApp_Module;
-class LightApp_Study;
-class LightApp_DataObject;
-
-/*!
- Description : Base class of data model
-*/
-class LIGHTAPP_EXPORT LightApp_DataModel : public CAM_DataModel
-{
- Q_OBJECT
-
-public:
- LightApp_DataModel ( CAM_Module* theModule );
- virtual ~LightApp_DataModel();
-
- virtual bool open( const QString&, CAM_Study*, QStringList );
- virtual bool save( QStringList& );
- virtual bool saveAs( const QString&, CAM_Study*, QStringList& );
- virtual bool close();
-
- virtual void update( LightApp_DataObject* = 0, LightApp_Study* = 0 );
-
- virtual bool isModified() const;
- virtual bool isSaved() const;
-
- LightApp_Module* getModule() const;
-
-signals:
- void opened();
- void saved();
- void closed();
-
-protected:
- LightApp_Study* getStudy() const;
- virtual void build();
- virtual void updateWidgets();
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_DataObject.h"
-
-#include "LightApp_Study.h"
-#include "LightApp_RootObject.h"
-
-#include "CAM_DataModel.h"
-#include "CAM_Module.h"
-
-#include <SUIT_Application.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_DataObjectKey.h>
-
-#include <qobject.h>
-
-/*!
- Class: LightApp_DataObject::Key
- Level: Internal
-*/
-class LightApp_DataObject::Key : public SUIT_DataObjectKey
-{
-public:
- Key( const QString& );
- virtual ~Key();
-
- virtual bool isLess( const SUIT_DataObjectKey* ) const;
- virtual bool isEqual( const SUIT_DataObjectKey* ) const;
-
-private:
- QString myEntry;
-};
-
-/*!Constructor. Initialize by \a entry.*/
-LightApp_DataObject::Key::Key( const QString& entry )
-: SUIT_DataObjectKey(),
- myEntry( entry )
-{
-}
-
-/*!Destructor. Do nothing.*/
-LightApp_DataObject::Key::~Key()
-{
-}
-
-/*!Checks: Is current key less than \a other.*/
-bool LightApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const
-{
- Key* that = (Key*)other;
- return myEntry < that->myEntry;
-}
-
-/*!Checks: Is current key equal with \a other.*/
-bool LightApp_DataObject::Key::isEqual( const SUIT_DataObjectKey* other ) const
-{
- Key* that = (Key*)other;
- return myEntry == that->myEntry;
-}
-
-/*!Constructor. Initialize by \a parent*/
-LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent )
-: CAM_DataObject( parent ), myCompObject( 0 ), myCompDataType( "" )
-{
-}
-
-/*!Destructor. Do nothing.*/
-LightApp_DataObject::~LightApp_DataObject()
-{
-}
-
-/*!Gets object ID.
- *\retval QString
- */
-QString LightApp_DataObject::entry() const
-{
- return QString::null;
-}
-
-/*!Create and return new key object.*/
-SUIT_DataObjectKey* LightApp_DataObject::key() const
-{
- QString str = entry();
- return new Key( str );
-}
-
-/*!Gets component object.
- *\retval SUIT_DataObject.
- */
-SUIT_DataObject* LightApp_DataObject::componentObject() const
-{
- if ( !myCompObject ) {
- SUIT_DataObject* compObj = 0; // for root object
-
- if ( parent() && parent() == root() )
- compObj = (SUIT_DataObject*)this; // for component-level objects
- else
- {
- compObj = parent(); // for lower level objects
- while ( compObj && compObj->parent() != root() )
- compObj = compObj->parent();
- }
- LightApp_DataObject* that = (LightApp_DataObject*)this;
- that->myCompObject = compObj;
- }
- return myCompObject;
-}
-
-/*!Get component type.*/
-QString LightApp_DataObject::componentDataType() const
-{
- if ( myCompDataType.isEmpty() ) {
- SUIT_DataObject* aCompObj = componentObject();
- LightApp_ModuleObject* anObj = dynamic_cast<LightApp_ModuleObject*>( aCompObj );
- if ( anObj ) {
- CAM_DataModel* aModel = anObj->dataModel();
- if ( aModel ) {
- LightApp_DataObject* that = (LightApp_DataObject*)this;
- that->myCompDataType = aModel->module()->name();
- }
- }
- }
- return myCompDataType;
-}
-
-
-
-/*!Constructor.Initialize by \a parent.*/
-LightApp_ModuleObject::LightApp_ModuleObject( SUIT_DataObject* parent )
-: CAM_RootObject( parent ),
- CAM_DataObject( parent )
-{
-}
-
-/*!Constructor.Initialize by \a module and parent.*/
-LightApp_ModuleObject::LightApp_ModuleObject( CAM_DataModel* dm, SUIT_DataObject* parent )
-: CAM_RootObject( dm, parent ),
- CAM_DataObject( parent )
-{
-}
-
-/*!Destructor. Do nothing.*/
-LightApp_ModuleObject::~LightApp_ModuleObject()
-{
-}
-
-/*!Returns module name */
-QString LightApp_ModuleObject::name() const
-{
- return CAM_RootObject::name();
-}
-
-/*!Insert new child object to the children list at specified position
- *\add component in Study for this module object if it necessary*/
-void LightApp_ModuleObject::insertChild( SUIT_DataObject* theObj, int thePosition )
-{
- CAM_RootObject::insertChild(theObj, thePosition);
-
- CAM_DataModel* aModel = dataModel();
-
- LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>(parent());
-
- if (aRoot)
- aRoot->study()->addComponent(aModel);
-
-
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_DATAOBJECT_H
-#define LIGHTAPP_DATAOBJECT_H
-
-#include "LightApp.h"
-
-#include "CAM_DataObject.h"
-#include "CAM_DataModel.h"
-#include "CAM_RootObject.h"
-
-class LightApp_Study;
-
-/*!Description : Data Object has empty entry so it's children must redefine metod entry() and return some unique string*/
-// to do : decomment virtual inheritance
-class LIGHTAPP_EXPORT LightApp_DataObject : public virtual CAM_DataObject
-{
- class Key;
-
-public:
- enum { CT_Value, CT_Entry, CT_IOR, CT_RefEntry };
-
-public:
- LightApp_DataObject( SUIT_DataObject* = 0 );
- virtual ~LightApp_DataObject();
-
- virtual SUIT_DataObjectKey* key() const;
- virtual QString entry() const;
-
- virtual SUIT_DataObject* componentObject() const;
- virtual QString componentDataType() const;
-
-protected:
- QString myCompDataType;
- SUIT_DataObject* myCompObject;
-};
-
-/*!
- * LightApp_ModuleObject - class for optimized access to DataModel from
- * CAM_RootObject.h.
- * In modules which will be redefine LightApp_DataObject, LightApp_ModuleObject must be children from rederined DataObject for having necessary properties and children from LightApp_ModuleObject.
- */
-
-class LIGHTAPP_EXPORT LightApp_ModuleObject : public CAM_RootObject
-{
-public:
- LightApp_ModuleObject( SUIT_DataObject* = 0 );
- LightApp_ModuleObject ( CAM_DataModel*, SUIT_DataObject* = 0 );
-
- virtual ~LightApp_ModuleObject();
-
- virtual QString name() const;
- virtual void insertChild( SUIT_DataObject*, int thePosition );
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_DataOwner.h"
-
-#include "LightApp_DataObject.h"
-
-#ifndef WNT
-#include <typeinfo>
-#define _typeinfo std::type_info
-#else
-#include <typeinfo.h>
-#define _typeinfo type_info
-#endif
-
-#include <iostream>
-
-/*!Constructor. Initialize by \a theEntry.*/
-LightApp_DataOwner::LightApp_DataOwner( const QString& theEntry )
-: myEntry( theEntry )
-{
-}
-
-LightApp_DataOwner::LightApp_DataOwner( const LightApp_DataObject* obj )
-: myEntry( obj ? obj->entry() : QString::null )
-{
-}
-
-#ifndef DISABLE_SALOMEOBJECT
-/*!Constructor. Initialize by \a SALOME_InteractiveObject.*/
-LightApp_DataOwner::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO )
-: myEntry( !theIO.IsNull() ? theIO->getEntry() : "" ),
-myIO( theIO )
-{
-}
-#endif
-
-/*!Destructor. Do nothing.*/
-LightApp_DataOwner::~LightApp_DataOwner()
-{
-}
-
-/*!Checks: Is current data owner equal \a obj.*/
-bool LightApp_DataOwner::isEqual( const SUIT_DataOwner& obj ) const
-{
- const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
- return other && entry() == other->entry();
-}
-
-bool LightApp_DataOwner::isLess( const SUIT_DataOwner& obj ) const
-{
- const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
- return other && entry() < other->entry();
-}
-
-/*!Gets entry.*/
-QString
-LightApp_DataOwner
-::entry() const
-{
- return myEntry;
-}
-
-#ifndef DISABLE_SALOMEOBJECT
-/*!Gets SALOME_InteractiveObject.*/
-const Handle(SALOME_InteractiveObject)&
-LightApp_DataOwner
-::IO() const
-{
- return myIO;
-}
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef LIGHTAPP_DATAOWNER_H
-#define LIGHTAPP_DATAOWNER_H
-
-#include "LightApp.h"
-#include "SUIT_DataOwner.h"
-
-#ifndef DISABLE_SALOMEOBJECT
- #include "SALOME_InteractiveObject.hxx"
-#endif
-
-class LightApp_DataObject;
-
-/*!
- This class provide data owner objects.
-*/
-class LIGHTAPP_EXPORT LightApp_DataOwner : public SUIT_DataOwner
-{
-public:
-#ifndef DISABLE_SALOMEOBJECT
- LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO );
-#endif
- LightApp_DataOwner( const LightApp_DataObject* );
- LightApp_DataOwner( const QString& );
- virtual ~LightApp_DataOwner();
-
- virtual bool isEqual( const SUIT_DataOwner& ) const;
- virtual bool isLess( const SUIT_DataOwner& ) const;
-
-#ifndef DISABLE_SALOMEOBJECT
- const Handle(SALOME_InteractiveObject)& IO() const;
-#endif
- QString entry() const;
-
-private:
- QString myEntry;
-#ifndef DISABLE_SALOMEOBJECT
- Handle(SALOME_InteractiveObject) myIO;
-#endif
-};
-
-typedef SMART(LightApp_DataOwner) LightApp_DataOwnerPtr;
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_DataSubOwner.h"
-
-#include "LightApp_DataObject.h"
-
-#ifdef WNT
-#include <typeinfo.h>
-#endif
-
-/*!Constructor.Initialize by \a entry and \a index*/
-LightApp_DataSubOwner::LightApp_DataSubOwner( const QString& entry, const int index )
-: LightApp_DataOwner( entry ),
-myIndex( index )
-{
-}
-
-/*!Destructor. Do nothing.*/
-LightApp_DataSubOwner::~LightApp_DataSubOwner()
-{
-}
-
-/*!Checks: Is current data sub owner equal \a obj.*/
-bool LightApp_DataSubOwner::isEqual( const SUIT_DataOwner& obj ) const
-{
- if (LightApp_DataOwner::isEqual(obj)) {
- const LightApp_DataSubOwner* other = dynamic_cast<const LightApp_DataSubOwner*>( &obj );
- return other && index() == other->index();
- }
- return false;
-}
-
-/*!Checks: Is current data sub owner less \a obj.*/
-bool LightApp_DataSubOwner::isLess( const SUIT_DataOwner& obj ) const
-{
- const LightApp_DataSubOwner* other = dynamic_cast<const LightApp_DataSubOwner*>( &obj );
- if(other && entry() == other->entry()){
- return index() < other->index();
- }
- return other && entry() < other->entry();
-}
-
-/*!Gets index.*/
-int LightApp_DataSubOwner::index() const
-{
- return myIndex;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef LIGHTAPP_DATASUBOWNER_H
-#define LIGHTAPP_DATASUBOWNER_H
-
-#include <LightApp.h>
-#include <LightApp_DataOwner.h>
-
-/*!
- Class provide sub owner.
- */
-class LIGHTAPP_EXPORT LightApp_DataSubOwner : public LightApp_DataOwner
-{
-public:
- LightApp_DataSubOwner( const QString&, const int );
- virtual ~LightApp_DataSubOwner();
-
- virtual bool isEqual( const SUIT_DataOwner& ) const;
- virtual bool isLess( const SUIT_DataOwner& obj ) const;
- int index() const;
-
-private:
- int myIndex;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Dialog.cxx
-// Author: Alexander SOLOVYOV
-
-#include <LightApp_Dialog.h>
-#include <SUIT_Session.h>
-
-#include <qtoolbutton.h>
-#include <qlineedit.h>
-#include <qlabel.h>
-
-/*!
- Constructor
-*/
-LightApp_Dialog::LightApp_Dialog( QWidget* parent, const char* name, bool modal,
- bool allowResize, const int f, WFlags wf )
-: QtxDialog( parent, name, modal, allowResize, f, wf ),
- myIsExclusive( true ),
- myIsBusy( false )
-{
- setObjectPixmap( "LightApp", tr( "ICON_SELECT" ) );
-}
-
-/*!
- Destructor
-*/
-LightApp_Dialog::~LightApp_Dialog()
-{
-}
-
-/*!
- Show dialog
-*/
-void LightApp_Dialog::show()
-{
- QtxDialog::show();
-}
-
-/*!
- \return isExclusive status of selection buttons
-*/
-bool LightApp_Dialog::isExclusive() const
-{
- return myIsExclusive;
-}
-
-/*!
- Updates "on" state of buttons according to special button
- \param _id - id of special button (if it is -1, then first selected button will be treated as special)
-*/
-void LightApp_Dialog::updateButtons( const int _id )
-{
- if( !myIsExclusive )
- return;
-
- int id = _id;
-
- ObjectMap::const_iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QToolButton* but = (QToolButton*)anIt.data().myBtn;
- if( but && but->isOn() )
- {
- if( id==-1 )
- id = anIt.key();
-
- if( anIt.key()!=id )
- but->setOn( false );
- }
- }
-}
-
-/*!
- Sets isExclusive status of selection buttons
- \param ex - new value of isExclusive status
-*/
-void LightApp_Dialog::setExclusive( const bool ex )
-{
- myIsExclusive = ex;
- updateButtons();
-}
-
-/*!
- Shows object selection widget
- \param id - identificator of object selection widget
-*/
-void LightApp_Dialog::showObject( const int id )
-{
- setObjectShown( id, true );
-}
-
-/*!
- Hides object selection widget
- \param id - identificator of object selection widget
-*/
-void LightApp_Dialog::hideObject( const int id )
-{
- setObjectShown( id, false );
-}
-
-/*!
- Shows/hides object selection widget
- \param id - identificator of object selection widget
- \param shown - if it is true, widget will be shown
-*/
-void LightApp_Dialog::setObjectShown( const int id, const bool shown )
-{
- if( myObjects.contains( id ) && isObjectShown( id )!=shown )
- {
- Object& obj = myObjects[ id ];
- obj.myEdit->setShown( shown );
- obj.myBtn->setShown( shown );
- obj.myLabel->setShown( shown );
- if( !shown )
- ( ( QToolButton* )obj.myBtn )->setOn( false );
- }
-}
-
-/*!
- \return isShown state of object selection widget
- \param id - identificator of object selection widget
-*/
-bool LightApp_Dialog::isObjectShown( const int id ) const
-{
- return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown();
-}
-
-/*!
- Change enable state of object selection widget
- \param id - identificator of object selection widget
- \param en - new value of enable state
-*/
-void LightApp_Dialog::setObjectEnabled( const int id, const bool en )
-{
- if( myObjects.contains( id ) && isObjectEnabled( id )!=en )
- {
- Object& obj = myObjects[ id ];
- obj.myEdit->setEnabled( en );
- obj.myBtn->setEnabled( en );
-// obj.myLabel->setEnabled( en );
- if( !en )
- ( ( QToolButton* )obj.myBtn )->setOn( false );
- }
-}
-
-/*!
- \return enable state of object selection widget
- \param id - identificator of object selection widget
-*/
-bool LightApp_Dialog::isObjectEnabled( const int id ) const
-{
- return myObjects.contains( id ) && myObjects[ id ].myEdit->isEnabled();
-}
-
-/*!
- Passes to all active widgets name, type and id of selected object
- \param name - name of selected object
- \param type - type of selected object
- \param id - id of selected object
- \param update - is need to update selection description string
-*/
-void LightApp_Dialog::selectObject( const QString& name, const int type, const QString& id, const bool update )
-{
- QStringList names; names.append( name );
- TypesList types; types.append( type );
- QStringList ids; ids.append( id );
- selectObject( names, types, ids, update );
-}
-
-/*!
- Passes to all active widgets names, types and ids of selected objects
- \param _names - names of selected objects
- \param _types - types of selected objects
- \param _ids - ids of selected objects
- \param update - is need to update selection description string
-*/
-void LightApp_Dialog::selectObject( const QStringList& _names,
- const TypesList& _types,
- const QStringList& _ids,
- const bool update )
-{
- ObjectMap::iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.data().myBtn->isOn() )
- selectObject( anIt.key(), _names, _types, _ids, update );
-}
-
-/*!
- \return true if widget has selection
- \param id - identificator of object selection widget
-*/
-bool LightApp_Dialog::hasSelection( const int id ) const
-{
- return myObjects.contains( id ) && !myObjects[ id ].myIds.isEmpty();
-}
-
-/*!
- Clears selection of widget
- \param id - identificator of object selection widget
-*/
-void LightApp_Dialog::clearSelection( const int id )
-{
- if( id==-1 )
- {
- ObjectMap::const_iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- clearSelection( anIt.key() );
- }
-
- else if( myObjects.contains( id ) )
- {
- myObjects[ id ].myIds.clear();
- myObjects[ id ].myTypes.clear();
- myObjects[ id ].myNames.clear();
-
- myObjects[ id ].myEdit->setText( QString::null );
- emit selectionChanged( id );
- }
-}
-
-/*!
- \return object selection widget
- \param theId - identificator of object selection widget
- \param theWgId may be "Label", "Btn" or "Control"
-*/
-QWidget* LightApp_Dialog::objectWg( const int theId, const int theWgId ) const
-{
- QWidget* aResWg = 0;
- if( myObjects.contains( theId ) )
- {
- if ( theWgId == Label )
- aResWg = myObjects[ theId ].myLabel;
- else if ( theWgId == Btn )
- aResWg = myObjects[ theId ].myBtn;
- else if ( theWgId == Control )
- aResWg = myObjects[ theId ].myEdit;
- }
- return aResWg;
-}
-
-/*!
- \return object selection widget text
- \param theId - identificator of object selection widget
-*/
-QString LightApp_Dialog::objectText( const int theId ) const
-{
- return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : "";
-}
-
-/*!
- Sets object selection widget text
- \param theId - identificator of object selection widget
- \param theText - new text
-*/
-void LightApp_Dialog::setObjectText( const int theId, const QString& theText )
-{
- if ( myObjects.contains( theId ) )
- myObjects[ theId ].myEdit->setText( theText );
-}
-
-/*!
- \return objects selected by widget
- \param id - identificator of object selection widget
- \param list - list to be filled by selected objects
-*/
-void LightApp_Dialog::selectedObject( const int id, QStringList& list ) const
-{
- if( myObjects.contains( id ) )
- list = myObjects[ id ].myIds;
-}
-
-/*!
- \return selected object id
- \param id - identificator of object selection widget
-*/
-QString LightApp_Dialog::selectedObject( const int id ) const
-{
- if ( myObjects.contains( id ) && myObjects[ id ].myIds.count() > 0 )
- return myObjects[ id ].myIds.first();
- else
- return "";
-}
-
-/*!
- \return all selected objects
- \param objs - map: widget id -> string id to be filled with selected objects
-*/
-void LightApp_Dialog::objectSelection( SelectedObjects& objs ) const
-{
- //objs.clear();
- ObjectMap::const_iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QStringList ids;
- selectedObject( anIt.key(), ids );
- if( !ids.isEmpty() )
- objs.insert( anIt.key(), ids );
- }
-}
-
-/*!
- Creates object selection widget
- \return id
- \label - label text
- \parent - parent object
- \id - proposed id for widget (if it is less than 0, the free id will be used)
-*/
-int LightApp_Dialog::createObject( const QString& label, QWidget* parent, const int id )
-{
- int nid = id;
- if( nid<0 )
- for( nid=0; myObjects.contains( nid ); nid++ );
-
- if( !myObjects.contains( nid ) )
- {
- QLabel* lab = new QLabel( label, parent );
- myObjects[ nid ].myLabel = lab;
-
- QToolButton* but = new QToolButton( parent );
- but->setIconSet( QIconSet( myPixmap ) );
- but->setToggleButton( true );
- but->setMaximumWidth( but->height() );
- but->setMinimumWidth( but->height() );
- connect( but, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) );
- myObjects[ nid ].myBtn = but;
-
- QLineEdit* ne = new QLineEdit( parent );
- ne->setReadOnly( true );
- ne->setMinimumWidth( 150 );
- connect( ne, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
- myObjects[ nid ].myEdit = ne;
-
- myObjects[ nid ].myNI = OneNameOrCount;
- }
- return nid;
-}
-
-/*!
- Changes label of object selection widget
- \param id - identificator of object selection widget
- \param label - new text of label
-*/
-void LightApp_Dialog::renameObject( const int id, const QString& label )
-{
- if( myObjects.contains( id ) )
- myObjects[ id ].myLabel->setText( label );
-}
-
-/*!
- Sets possible types for widget
- \param id - identificator of object selection widget
- \param type1,... - type
-*/
-void LightApp_Dialog::setObjectType( const int id, const int type1, ... )
-{
- TypesList types;
-
- const int* tt = &type1;
- while( *tt>=0 )
- {
- types.append( *tt );
- tt++;
- }
-
- setObjectType( id, types );
-}
-
-/*!
- Sets possible types for widget
- \param id - identificator of object selection widget
- \param list - list of possible types
-*/
-void LightApp_Dialog::setObjectType( const int id, const TypesList& list )
-{
- if( !myObjects.contains( id ) )
- return;
-
- TypesList& internal = myObjects[ id ].myPossibleTypes;
-
- QMap<int,int> types;
- TypesList::const_iterator anIt = list.begin(),
- aLast = list.end();
- for( ; anIt!=aLast; anIt++ )
- types.insert( *anIt, 0 );
-
-
- internal.clear();
- QMap<int,int>::const_iterator aMIt = types.begin(),
- aMLast = types.end();
- for( ; aMIt!=aMLast; aMIt++ )
- internal.append( aMIt.key() );
-
- updateObject( id );
-}
-
-/*!
- Adds new possible types to object selection widget
- \param id - identificator of object selection widget
- \param type1, ... - new types
-*/
-void LightApp_Dialog::addObjectType( const int id, const int type1, const int, ... )
-{
- TypesList types; objectTypes( id, types );
-
- const int* tt = &type1;
- while( *tt>=0 )
- {
- types.append( *tt );
- tt++;
- }
-
- setObjectType( id, types );
-}
-
-/*!
- Adds new possible types to object selection widget
- \param id - identificator of object selection widget
- \param list - new types
-*/
-void LightApp_Dialog::addObjectType( const int id, const TypesList& list )
-{
- TypesList types = list; objectTypes( id, types );
- setObjectType( id, types );
-}
-
-/*!
- Adds new possible type to object selection widget
- \param id - identificator of object selection widget
- \param type - new type
-*/
-void LightApp_Dialog::addObjectType( const int id, const int type )
-{
- TypesList types; objectTypes( id, types );
- types.append( type );
- setObjectType( id, types );
-}
-
-/*!
- Clears list of possibles types for object selection widget
- \param id - identificator of object selection widget
-*/
-void LightApp_Dialog::removeObjectType( const int id )
-{
- TypesList types;
- setObjectType( id, types );
-}
-
-/*!
- Removes types from list of possibles for object selection widget
- \param id - identificator of object selection widget
- \param list - list of types to be removed
-*/
-void LightApp_Dialog::removeObjectType( const int id, const TypesList& list )
-{
- if( !myObjects.contains( id ) )
- return;
-
- TypesList& internal = myObjects[ id ].myPossibleTypes;
-
- QMap<int,int> types;
- TypesList::const_iterator anIt = internal.begin(),
- aLast = internal.end();
- for( ; anIt!=aLast; anIt++ )
- types.insert( *anIt, 0 );
- anIt = list.begin(); aLast = list.end();
- for( ; anIt!=aLast; anIt++ )
- types.remove( *anIt );
-
-
- internal.clear();
- QMap<int,int>::const_iterator aMIt = types.begin(),
- aMLast = types.end();
- for( ; aMIt!=aMLast; aMIt++ )
- internal.append( aMIt.key() );
-
- updateObject( id );
-}
-
-/*!
- Removes type from list of possibles for object selection widget
- \param id - identificator of object selection widget
- \param type - type to be removed
-*/
-void LightApp_Dialog::removeObjectType( const int id, const int type )
-{
- TypesList list; list.append( type );
- removeObjectType( id, list );
-}
-
-/*!
- \return true if widget has such type
- \param id - identificator of object selection widget
- \param type - type to be checked
-*/
-bool LightApp_Dialog::hasObjectType( const int id, const int type ) const
-{
- if( myObjects.contains( id ) )
- return myObjects[ id ].myPossibleTypes.contains( type );
- else
- return false;
-}
-
-/*!
- Returns list of possible types for widget
- \param id - identificator of object selection widget
- \param list - list to be filled with possible types
-*/
-void LightApp_Dialog::objectTypes( const int id, TypesList& list ) const
-{
- if( myObjects.contains( id ) )
- {
- TypesList::const_iterator anIt = myObjects[ id ].myPossibleTypes.begin(),
- aLast = myObjects[ id ].myPossibleTypes.end();
- for( ; anIt!=aLast; anIt++ )
- list.append( *anIt );
- }
-}
-
-/*!
- SLOT: called if selection button is clicked
-*/
-void LightApp_Dialog::onToggled( bool on )
-{
- QButton* but = ( QButton* )sender();
- int id = -1;
-
- if( !but )
- return;
-
- ObjectMap::const_iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast && id==-1; anIt++ )
- if( anIt.data().myBtn==but )
- id = anIt.key();
-
- if( id!=-1 )
- if( on )
- {
- updateButtons( id );
- emit objectActivated( id );
- }
- else
- emit objectDeactivated( id );
-}
-
-/*!
- Updates selection description of widget
- \param id - identificator of object selection widget
- \param emit_signal - if it is true, the signal "selection changed" is emitted
-*/
-void LightApp_Dialog::updateObject( const int id, bool emit_signal )
-{
- if( hasSelection( id ) )
- {
- Object& obj = myObjects[ id ];
- filterTypes( id, obj.myNames, obj.myTypes, obj.myIds );
- obj.myEdit->setText( selectionDescription( obj.myNames, obj.myTypes, obj.myNI ) );
- if( emit_signal )
- emit selectionChanged( id );
- }
-}
-
-/*!
- Finds in list possible types
- \param id - identificator of object selection widget
- \param names - list of selected objects names
- \param types - list of selected objects types
- \param ids - list of selected objects ids
-*/
-void LightApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& types, QStringList& ids ) const
-{
- if( !myObjects.contains( id ) )
- return;
-
- const Object& obj = myObjects[ id ];
- if( obj.myPossibleTypes.isEmpty() )
- return;
-
- QStringList new_names, new_ids;
- TypesList new_types;
-
- TypesList::const_iterator anIt1 = types.begin(),
- aLast = types.end();
- QStringList::const_iterator anIt2 = names.begin(),
- anIt3 = ids.begin();
- for( ; anIt1!=aLast; anIt1++, anIt2++, anIt3++ )
- if( obj.myPossibleTypes.contains( *anIt1 ) )
- {
- if( new_types.count()==1 && !multipleSelection( id ) )
- break;
-
- new_names.append( *anIt2 );
- new_types.append( *anIt1 );
- new_ids.append( *anIt3 );
- }
- names = new_names;
- types = new_types;
- ids = new_ids;
-}
-
-/*!
- \return global resource manager
-*/
-SUIT_ResourceMgr* LightApp_Dialog::resMgr() const
-{
- return SUIT_Session::session()->resourceMgr();
-}
-
-/*!
- Sets pixmap for all object selection button
- \param p - image
-*/
-void LightApp_Dialog::setObjectPixmap( const QPixmap& p )
-{
- myPixmap = p;
- ObjectMap::const_iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- ( ( QToolButton* )anIt.data().myBtn )->setIconSet( p );
-}
-
-/*!
- Sets pixmap all for object selection button
- \param section - name of section of resource manager
- \param file - name of file
-*/
-void LightApp_Dialog::setObjectPixmap( const QString& section, const QString& file )
-{
- SUIT_ResourceMgr* mgr = resMgr();
- if( mgr )
- setObjectPixmap( mgr->loadPixmap( section, file ) );
-}
-
-/*!
- \return true, if it is enable multiple selection
- \param id - identificator of object selection widget
-*/
-bool LightApp_Dialog::multipleSelection( const int id ) const
-{
- return nameIndication( id )!=OneName;
-}
-
-/*!
- \return type of name indication
- \param id - identificator of object selection widget
-*/
-LightApp_Dialog::NameIndication LightApp_Dialog::nameIndication( const int id ) const
-{
- if( myObjects.contains( id ) )
- return myObjects[ id ].myNI;
- else
- return OneNameOrCount;
-}
-
-/*!
- Sets type of name indication
- \param id - identificator of object selection widget
- \param ni - new type of name indication
-*/
-void LightApp_Dialog::setNameIndication( const int id, const NameIndication ni )
-{
- if( id==-1 )
- {
- ObjectMap::iterator anIt = myObjects.begin(),
- aNext,
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- {
- anIt.data().myNI = ni;
- setReadOnly( anIt.key(), isReadOnly( anIt.key() ) );
- aNext = anIt; aNext++;
- updateObject( anIt.key(), aNext==aLast );
- }
- }
- else if( myObjects.contains( id ) )
- {
- myObjects[ id ].myNI = ni;
- setReadOnly( id, isReadOnly( id ) );
- updateObject( id, true );
- }
-}
-
-/*!
- \return string representation of selection by selection data
- \param names - list of selected objects names
- \param types - list of selected objects types
- \param ni - type of name indication
-*/
-QString LightApp_Dialog::selectionDescription( const QStringList& names, const TypesList& types, const NameIndication ni ) const
-{
- if( names.count()!=types.count() )
- return "LightApp_Dialog::selectionDescription(): Error!!!";
-
- if( names.isEmpty() )
- return QString::null;
-
- switch( ni )
- {
- case OneName:
- return names.first();
- break;
-
- case OneNameOrCount:
- if( names.count()==1 )
- return names.first();
- else
- return countOfTypes( types );
- break;
-
- case ListOfNames:
- return names.join( " " );
- break;
-
- case Count:
- return countOfTypes( types );
- break;
- };
- return QString::null;
-}
-
-/*!
- \return string representation of count of types
- \param types - list of types
-*/
-QString LightApp_Dialog::countOfTypes( const TypesList& types ) const
-{
- QMap<int, int> typesCount;
- QStringList typeCount;
-
- TypesList::const_iterator anIt = types.begin(),
- aLast = types.end();
- for( ; anIt!=aLast; anIt++ )
- if( typesCount.contains( *anIt ) )
- typesCount[ *anIt ]++;
- else
- typesCount[ *anIt ] = 1;
-
- QMap<int,int>::const_iterator aMIt = typesCount.begin(),
- aMLast = typesCount.end();
- for( ; aMIt!=aMLast; aMIt++ )
- typeCount.append( QString( "%1 %2" ).arg( aMIt.data() ).arg( typeName( aMIt.key() ) ) );
-
- return typeCount.join( ", " );
-}
-
-/*!
- \return reference to type name
- \param type - integer id of type
-*/
-QString& LightApp_Dialog::typeName( const int type )
-{
- return myTypeNames[ type ];
-}
-
-/*!
- \return const reference to type name
- \param type - integer id of type
-*/
-const QString& LightApp_Dialog::typeName( const int type ) const
-{
- return myTypeNames[ type ];
-}
-
-
-/*!
- Activates object selection widget
- \param id - identificator of object selection widget
-*/
-void LightApp_Dialog::activateObject( const int theId )
-{
- if ( myObjects.contains( theId ) && !myObjects[ theId ].myBtn->isOn() )
- myObjects[ theId ].myBtn->toggle();
-}
-
-/*!
- Deactivates all object selection widgets
-*/
-void LightApp_Dialog::deactivateAll()
-{
- ObjectMap::iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QToolButton* btn = ( QToolButton* )anIt.data().myBtn;
- btn->setOn( false );
- }
-}
-
-/*!
- Passes to widget name, type and id of selected object
- \param id - identificator of object selection widget
- \param name - name of selected object
- \param type - type of selected object
- \param selid - id of selected object
- \param update - is need to update selection description string
-*/
-void LightApp_Dialog::selectObject( const int id, const QString& name, const int type, const QString& selid, const bool update )
-{
- QStringList names; names.append( name );
- TypesList types; types.append( type );
- QStringList ids; ids.append( selid );
- selectObject( id, names, types, ids, update );
-}
-
-/*!
- Passes to widget names, types and ids of selected objects
- \param id - identificator of object selection widget
- \param _names - names of selected object
- \param _types - types of selected object
- \param _ids - ids of selected object
- \param update - is need to update selection description string
-*/
-void LightApp_Dialog::selectObject( const int id, const QStringList& _names, const TypesList& _types,
- const QStringList& _ids, const bool update )
-{
- if( !myObjects.contains( id ) )
- return;
-
- QStringList names = _names, ids = _ids;
- TypesList types = _types;
-
- filterTypes( id, names, types, ids );
-
- Object& obj = myObjects[ id ];
- if( update )
- obj.myEdit->setText( selectionDescription( names, types, obj.myNI ) );
- obj.myTypes = types;
- obj.myIds = ids;
- obj.myNames = names;
-
- emit selectionChanged( id );
-}
-
-/*!
- Sets read only state of object selection line edit
- \param id - identificator of object selection widget
- \param ro - new read only state
-*/
-void LightApp_Dialog::setReadOnly( const int id, const bool ro )
-{
- if( myObjects.contains( id ) )
- myObjects[ id ].myEdit->setReadOnly( nameIndication( id )==ListOfNames || nameIndication( id )==OneName ? ro : true );
-}
-
-/*!
- \return read only state of object selection line edit
- \param id - identificator of object selection widget
-*/
-bool LightApp_Dialog::isReadOnly( const int id ) const
-{
- if( myObjects.contains( id ) )
- return myObjects[ id ].myEdit->isReadOnly();
- else
- return true;
-}
-
-/*!
- SLOT: called if text of object selection line edit is changed
-*/
-void LightApp_Dialog::onTextChanged( const QString& text )
-{
- if( myIsBusy )
- return;
-
- myIsBusy = true;
-
- if( sender() && sender()->inherits( "QLineEdit" ) )
- {
- QLineEdit* edit = ( QLineEdit* )sender();
- int id = -1;
- ObjectMap::const_iterator anIt = myObjects.begin(),
- aLast = myObjects.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.data().myEdit == edit )
- id = anIt.key();
-
- if( id>=0 && !isReadOnly( id ) )
- {
- QStringList list = QStringList::split( " ", text );
- emit objectChanged( id, list );
- }
- }
-
- myIsBusy = false;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Dialog.h
-// Author: Alexander SOLOVYOV
-
-#ifndef LIGHTAPP_DIALOG_H
-#define LIGHTAPP_DIALOG_H
-
-#include "LightApp.h"
-#include <QtxDialog.h>
-
-#include <qvaluelist.h>
-#include <qmap.h>
-#include <qpixmap.h>
-
-class QLineEdit;
-class QButton;
-class QLabel;
-
-class SUIT_ResourceMgr;
-
-#ifdef WIN32
-#pragma warning ( disable:4251 )
-#endif
-
-/*!
- \class LightApp_Dialog
- Base class for all LightApp dialogs.
- Provides standard widget for object selection: line edit, button;
- it is necessary to call corresponding methods on selection change.
- Standard dialog provides filtering, selection string representation,
- possibility to indicate necessary selection by text with list of ids.
-*/
-class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
-{
- Q_OBJECT
-
-public:
- typedef QValueList<int> TypesList;
- typedef QMap<int,QStringList> SelectedObjects;
-
- enum ObjectWg
- {
- Label = 0x00000001,
- Btn = 0x00000002,
- Control = 0x00000004
- };
-
- typedef enum
- {
- OneName, //<! only one object can be selected and it's name is shown
- OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
- // "<count> <type>" is shown
- ListOfNames, //! list of all names is shown
- Count //! In every case "<count> <type>" is shown
-
- } NameIndication;
- //! The enumeration describing how names of selected objects will be shown in line edit
- //! For more details see above
-
-public:
- LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
- bool = false, const int = Standard, WFlags = 0 );
- virtual ~LightApp_Dialog();
-
- virtual void show();
-
- //! Check if buttons is exclusive (as radiobuttons)
- bool isExclusive() const;
-
- //! Set exclusive state
- void setExclusive( const bool );
-
- //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
- bool isAutoResumed() const;
-
- //! Set auto resumed state
- void setAutoResumed( const bool );
-
- //! Show widgets corresponding to id
- void showObject( const int );
-
- //! Hide widgets corresponding to id
- void hideObject( const int );
-
- //! Change the shown state of widgets corresponding to id
- void setObjectShown( const int, const bool );
-
- //! Check the shown state
- bool isObjectShown( const int ) const;
-
- //! Change the enabled state of widgets corresponding to id
- void setObjectEnabled( const int, const bool );
-
- //! Check the enabled state
- bool isObjectEnabled( const int ) const;
-
- //! Get widget of object (see ObjectWg enumeration)
- QWidget* objectWg( const int theId, const int theWgId ) const;
-
- //! Pass to all active widgets name, type and id of selected object
- void selectObject( const QString&, const int, const QString&, const bool = true );
-
- /*!
- Pass to all active widgets list of names, types and ids of selected objects
- Every active widget filters list and accept only objects with possible types
- */
- void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
-
- //! Get text of object's control
- QString objectText( const int ) const;
-
- //! Set text of object's control
- void setObjectText( const int, const QString& );
-
- //! Select in certain widget avoiding check if there is active widget
- void selectObject( const int, const QString&, const int, const QString&, const bool = true );
- void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
-
- //! Check if certain widget has selection
- bool hasSelection( const int ) const;
-
- //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
- void clearSelection( const int = -1 );
-
- //! Get ids list of object selected in certain widget
- void selectedObject( const int, QStringList& ) const;
-
- //! Get ids list of object selected in certain widget
- QString selectedObject( const int ) const;
-
- //! Get map "widget id -> ids list"
- void objectSelection( SelectedObjects& ) const;
-
- //! Activate object selection button
- void activateObject( const int );
-
- //! Set all object selection buttons to inactive state
- void deactivateAll();
-
-signals:
- //! selection in certain widget is changed
- void selectionChanged ( int );
-
- //! selection in certain widget is on
- void objectActivated ( int );
-
- //! selection in certain widget is off
- void objectDeactivated( int );
-
- /*
- text representation of selection is changed
- it is emitted only if "read only" state of line edit is false
- */
- void objectChanged( int, const QStringList& );
-
-protected:
- //! Finds and returns resource manager
- SUIT_ResourceMgr* resMgr() const;
-
- /*! Create label, button and line edit for object selection
- * If passed id is negative, then id will be calculated automatically (first free id)
- * Returns the same id (if id>=0) or calculated
- */
- int createObject ( const QString&, QWidget*, const int = -1 );
-
- //! Set pixmap as icon for all selection buttons
- void setObjectPixmap ( const QPixmap& );
-
- //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
- void setObjectPixmap ( const QString&, const QString& );
-
- //! Change label
- void renameObject ( const int, const QString& );
-
- //! Set possible types for certain id. The list of arguments must be finished by negative integer
- void setObjectType ( const int, const int, ... );
-
- //! Set list as possible types for object selection
- void setObjectType ( const int, const TypesList& );
-
- /*!
- Add types to list of possible types
- The list of arguments must be finished by negative integer
- */
- void addObjectType ( const int, const int, const int, ... );
-
- //! Add types to list of possible types
- void addObjectType ( const int, const TypesList& );
-
- //! Add type to list of possible types
- void addObjectType ( const int, const int );
-
- //! Clear list of possible types (it means, that all types are welcome)
- void removeObjectType( const int );
-
- //! Remove types in list from list of possible types
- void removeObjectType( const int, const TypesList& );
-
- //! Remove a type from list of possible types
- void removeObjectType( const int, const int );
-
- //! Check if list of possible types contains this one
- bool hasObjectType ( const int, const int ) const;
-
- //! Return list of possible types
- void objectTypes ( const int, TypesList& ) const;
-
- //!Change and get type name for indicating in selection widget
- QString& typeName( const int );
- const QString& typeName( const int ) const;
-
- //! Create string contains selection list by list of names, list of types and current name indication state
- virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
-
- //! Create string by pattern "<count> <type>" for current list of types
- virtual QString countOfTypes( const TypesList& ) const;
-
- //! Get and set name indication for certain widget
- NameIndication nameIndication( const int ) const;
- void setNameIndication( const int, const NameIndication );
-
- //! Check using name indication if multiple selection in possible
- bool multipleSelection( const int ) const;
-
- //! Set the "read only" state of object selection line edit
- //! The "read only" will be false only if name indication is ListOfNames
- void setReadOnly( const int, const bool );
-
- //! Check the "read only" state of object selection line edit
- bool isReadOnly( const int ) const;
-
-private slots:
- //! emits if the object selection button changes state
- void onToggled( bool );
-
- //! text in some line edit is changed
- void onTextChanged( const QString& );
-
-private:
- /*!
- If buttons are exclusive, set to "off" all buttons except one with id
- If id=-1, then all buttons, except first with "on" state, will be set to "off"
- */
- void updateButtons( const int = -1 );
-
- /*!
- Filter types and update selection string in line edit
- If bool is true, then signal is emitted
- */
- void updateObject( const int, bool = true );
-
- //! Remove from list not possible types and remove from names and ids lists the corresponding items
- void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
-
-private:
- typedef struct
- {
- QLineEdit* myEdit;
- QButton* myBtn;
- QLabel* myLabel;
- QStringList myNames, myIds;
- TypesList myTypes, myPossibleTypes;
- NameIndication myNI;
-
- } Object;
-
- typedef QMap<int, Object> ObjectMap;
-
-private:
- ObjectMap myObjects;
-
- QMap<int,QString> myTypeNames;
- bool myIsExclusive, myIsBusy;
- QPixmap myPixmap;
-};
-
-#ifdef WIN32
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "LightApp_Displayer.h"
-#include "LightApp_Application.h"
-#include "LightApp_Module.h"
-
-#include <CAM_Study.h>
-
-#include <SUIT_Session.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_ViewManager.h>
-#include <SUIT_ViewModel.h>
-#include <SUIT_ViewWindow.h>
-
-#include <qstring.h>
-#ifndef DISABLE_SALOMEOBJECT
- #include "SALOME_InteractiveObject.hxx"
-#endif
-
-/*!
- Default constructor
-*/
-LightApp_Displayer::LightApp_Displayer()
-{
-}
-
-/*!
- Destructor
-*/
-LightApp_Displayer::~LightApp_Displayer()
-{
-}
-
-/*!
- Displays object in view
- \param entry - object entry
- \param updateViewer - is it necessary to update viewer
- \param theViewFrame - view
-*/
-void LightApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
-{
- SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
- if ( vf )
- {
- SALOME_Prs* prs = buildPresentation( entry, vf );
-
- if ( prs )
- {
- vf->BeforeDisplay( this );
- vf->Display( prs );
- vf->AfterDisplay( this );
-
- if ( updateViewer )
- vf->Repaint();
-
- delete prs; // delete presentation because displayer is its owner
- }
- }
-}
-
-/*!
- Redisplays object in view
- \param entry - object entry
- \param updateViewer - is it necessary to update viewer
-*/
-void LightApp_Displayer::Redisplay( const QString& entry, const bool updateViewer )
-{
- // Remove the object permanently (<forced> == true)
- SUIT_Session* ses = SUIT_Session::session();
- SUIT_Application* app = ses->activeApplication();
- if ( app )
- {
- SUIT_Desktop* desk = app->desktop();
- QPtrList<SUIT_ViewWindow> wnds = desk->windows();
- SUIT_ViewWindow* wnd;
- for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
- {
- SUIT_ViewManager* vman = wnd->getViewManager();
- if( !vman )
- continue;
-
- SUIT_ViewModel* vmodel = vman->getViewModel();
- if( !vmodel )
- continue;
-
- SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
- if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
- {
- Erase( entry, true, false, view );
- Display( entry, updateViewer, view );
- }
- }
- }
-}
-
-/*!
- Erases object in view
- \param entry - object entry
- \param forced - deletes object from viewer (otherwise it will be erased, but cached)
- \param updateViewer - is it necessary to update viewer
- \param theViewFrame - view
-*/
-void LightApp_Displayer::Erase( const QString& entry, const bool forced,
- const bool updateViewer, SALOME_View* theViewFrame )
-{
- SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
-
- if ( vf ) {
- SALOME_Prs* prs = vf->CreatePrs( entry.latin1() );
- if ( prs ) {
- vf->Erase( prs, forced );
- if ( updateViewer )
- vf->Repaint();
- delete prs; // delete presentation because displayer is its owner
- }
- }
-}
-
-/*!
- Erases all objects in view
- \param forced - deletes objects from viewer
- \param updateViewer - is it necessary to update viewer
- \param theViewFrame - view
-*/
-void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
-{
- SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
-
- if ( vf ) {
- vf->EraseAll( forced );
- if ( updateViewer )
- vf->Repaint();
- }
-}
-
-/*!
- \return true if object is displayed in viewer
- \param entry - object entry
- \param theViewFrame - view
-*/
-bool LightApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theViewFrame ) const
-{
- SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
- bool res = false;
- if( vf )
- {
-#ifndef DISABLE_SALOMEOBJECT
- Handle( SALOME_InteractiveObject ) temp = new SALOME_InteractiveObject();
- temp->setEntry( entry.latin1() );
- res = vf->isVisible( temp );
-#endif
- }
- return res;
-}
-
-/*!
- Updates active view
-*/
-void LightApp_Displayer::UpdateViewer() const
-{
- SALOME_View* vf = GetActiveView();
- if ( vf )
- vf->Repaint();
-}
-
-/*!
- \return presentation of object, built with help of CreatePrs method
- \param entry - object entry
- \param theViewFrame - view
- \sa CreatePrs()
-*/
-SALOME_Prs* LightApp_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
-{
- SALOME_Prs* prs = 0;
-
- SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
-
- if ( vf )
- prs = vf->CreatePrs( entry.latin1() );
-
- return prs;
-}
-
-/*!
- \return active view
-*/
-SALOME_View* LightApp_Displayer::GetActiveView()
-{
- SUIT_Session* session = SUIT_Session::session();
- if ( SUIT_Application* app = session->activeApplication() ) {
- if ( LightApp_Application* sApp = dynamic_cast<LightApp_Application*>( app ) ) {
- if( SUIT_ViewManager* vman = sApp->activeViewManager() ) {
- if ( SUIT_ViewModel* vmod = vman->getViewModel() )
- return dynamic_cast<SALOME_View*>( vmod );
- }
- }
- }
- return 0;
-}
-
-/*!
- \return true, if object can be displayed in this type of viewer
- \param entry - object entry
- \param viewer_type - type of viewer
-*/
-bool LightApp_Displayer::canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const
-{
- return true;
-}
-
-/*!
- \return true, if object can be displayed in any type of viewer
- \param entry - object entry
-*/
-bool LightApp_Displayer::canBeDisplayed( const QString& entry ) const
-{
- QString viewerType;
- SUIT_Session* session = SUIT_Session::session();
- if( SUIT_Application* app = session->activeApplication() )
- if( LightApp_Application* sApp = dynamic_cast<LightApp_Application*>( app ) )
- if( SUIT_ViewManager* vman = sApp->activeViewManager() )
- if( SUIT_ViewModel* vmod = vman->getViewModel() )
- viewerType = vmod->getType();
- return !viewerType.isNull() && canBeDisplayed( entry, viewerType );
-}
-
-/*!
- \return displayer, corresponding to module
- \param mod_name - name of module
- \param load - is module has to be forced loaded
-*/
-LightApp_Displayer* LightApp_Displayer::FindDisplayer( const QString& mod_name, const bool load )
-{
- SUIT_Session* session = SUIT_Session::session();
- SUIT_Application* sapp = session ? session->activeApplication() : 0;
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( sapp );
- if( !app )
- return 0;
-
- LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
- if( !m && load )
- {
- m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
- if( m )
- app->addModule( m );
- }
-
- if( m )
- {
- m->connectToStudy( dynamic_cast<CAM_Study*>( app->activeStudy() ) );
- if( m!=app->activeModule() && load )
- {
- m->setMenuShown( false );
- m->setToolShown( false );
- }
- }
- return m ? m->displayer() : 0;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef LIGHTAPP_DISPLAYER_HEADER
-#define LIGHTAPP_DISPLAYER_HEADER
-
-#include "LightApp.h"
-
-#include <SALOME_Prs.h>
-
-class QString;
-
-/*!
- \class LightApp_Displayer
- Uniform mechanism of display/erase of objects in different views.
- Objects are specified by string entry
-*/
-class LIGHTAPP_EXPORT LightApp_Displayer : public SALOME_Displayer
-{
-public:
- LightApp_Displayer();
- virtual ~LightApp_Displayer();
-
- void Display( const QString&, const bool = true, SALOME_View* = 0 );
- void Redisplay( const QString&, const bool = true );
- void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 );
- void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
- bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
- void UpdateViewer() const;
-
- static SALOME_View* GetActiveView();
- static LightApp_Displayer* FindDisplayer( const QString&, const bool );
-
- virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
- bool canBeDisplayed( const QString& /*entry*/ ) const;
-
-protected:
- virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_Driver.h"
-
-#include <TCollection_AsciiString.hxx>
-
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Directory.hxx>
-#include <OSD_Process.hxx>
-#include <OSD_Directory.hxx>
-#include <OSD_Protection.hxx>
-#include <OSD_SingleProtection.hxx>
-#include <OSD_FileIterator.hxx>
-
-#include <qfileinfo.h>
-#include <qdir.h>
-
-#ifdef WIN32
-#include <time.h>
-#endif
-
-/*! Constructor.*/
-LightApp_Driver::LightApp_Driver()
-: myIsTemp( false )
-{
-}
-
-/*! Destructor.*/
-LightApp_Driver::~LightApp_Driver()
-{
-}
-
-using namespace std;
-
-/*!
- Save in file 'theFileName' datas from this driver
-*/
-bool LightApp_Driver::SaveDatasInFile( const char* theFileName, bool isMultiFile )
-{
- int aNbModules = 0;
- std::map<std::string, ListOfFiles>::const_iterator it;
- for (it = myMap.begin(); it != myMap.end(); ++it)
- aNbModules++;
-
- unsigned char** aBuffer = new unsigned char*[aNbModules];
- long* aBufferSize = new long[aNbModules];
- char** aModuleName = new char*[aNbModules];
-
- if(aBuffer == NULL || aBufferSize == NULL || aModuleName == NULL)
- return false;
-
- int aFileBufferSize = 4; //4 bytes for a number of the modules that will be written to the stream;
- int i = 0;
- for (it = myMap.begin(); it != myMap.end(); ++it) {
- aModuleName[i] = const_cast<char*>(it->first.c_str());//(it->first);
- aFileBufferSize += 4; //Add 4 bytes: a length of the module name
- aFileBufferSize += strlen(aModuleName[i])+1;
- std::string aName(aModuleName[i]);
- PutFilesToStream(aName, aBuffer[i], aBufferSize[i], isMultiFile);
- aFileBufferSize += 8; //Add 8 bytes: a length of the buffer
- aFileBufferSize += aBufferSize[i];
- i++;
- }
- int n = i;
-
- unsigned char* aFileBuffer = new unsigned char[aFileBufferSize];
- if(aFileBuffer == NULL)
- return false;
-
- myTmpDir = QDir::convertSeparators( QFileInfo( theFileName ).dirPath( true ) + "/" ).latin1() ;
-
- int aCurrentPos = 0;
-
- //Initialize 4 bytes of the buffer by 0
- memset(aFileBuffer, 0, 4);
- //Copy the number of modules that will be written to the stream
- memcpy(aFileBuffer, &aNbModules, ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
-
- int aBufferNameSize = 0;
- for (i = 0; i < n; i++) {
- aBufferNameSize = strlen(aModuleName[i])+1;
- //Initialize 4 bytes of the buffer by 0
- memset((aFileBuffer + aCurrentPos), 0, 4);
- //Copy the length of the module name to the buffer
- memcpy((aFileBuffer + aCurrentPos), &aBufferNameSize, ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
- //Copy the module name to the buffer
- memcpy((aFileBuffer + aCurrentPos), aModuleName[i], aBufferNameSize);
- aCurrentPos += aBufferNameSize;
-
- //Initialize 8 bytes of the buffer by 0
- memset((aFileBuffer + aCurrentPos), 0, 8);
- //Copy the length of the module buffer to the buffer
- memcpy((aFileBuffer + aCurrentPos), (aBufferSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long)));
- aCurrentPos += 8;
- //Copy the module buffer to the buffer
- memcpy((aFileBuffer + aCurrentPos), aBuffer[i], aBufferSize[i]);
- aCurrentPos += aBufferSize[i];
- }
-
-#ifdef WNT
- ofstream aFile(theFileName, ios::out | ios::binary);
-#else
- ofstream aFile(theFileName);
-#endif
- aFile.write((char*)aFileBuffer, aFileBufferSize);
- aFile.close();
-
- delete[] aBuffer;
- delete[] aBufferSize;
- delete[] aModuleName;
- delete[] aFileBuffer;
-
- return true;
-}
-
-/*!
- Filling current driver from file 'theFileName'
-*/
-bool LightApp_Driver::ReadDatasFromFile( const char* theFileName, bool isMultiFile )
-{
-#ifdef WNT
- ifstream aFile(theFileName, ios::binary);
-#else
- ifstream aFile(theFileName);
-#endif
-
- myTmpDir = QDir::convertSeparators( QFileInfo( theFileName ).dirPath( true ) + "/" ).latin1() ;
-
- aFile.seekg(0, ios::end);
- int aFileBufferSize = aFile.tellg();
- unsigned char* aFileBuffer = new unsigned char[aFileBufferSize];
- aFile.seekg(0, ios::beg);
- aFile.read((char*)aFileBuffer, aFileBufferSize);
- aFile.close();
-
- int aNbModules = 0;
- //Copy the number of files in the stream
- memcpy(&aNbModules, aFileBuffer, sizeof(int));
- long aCurrentPos = 4;
- int aModuleNameSize;
-
- for (int i = 0; i < aNbModules; i++) {
- //Put a length of the module name to aModuleNameSize
- memcpy(&aModuleNameSize, (aFileBuffer + aCurrentPos), ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
-
- char *aModuleName = new char[aModuleNameSize];
- //Put a module name to aModuleName
- memcpy(aModuleName, (aFileBuffer + aCurrentPos), aModuleNameSize);
- aCurrentPos += aModuleNameSize;
-
- //Put a length of the file buffer to aBufferSize
- long aBufferSize;
- memcpy(&aBufferSize, (aFileBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
- aCurrentPos += 8;
- unsigned char *aBuffer = new unsigned char[aBufferSize];
-
- //Put a buffer for current module to aBuffer
- memcpy(aBuffer, (aFileBuffer + aCurrentPos), aBufferSize);
- aCurrentPos += aBufferSize;
-
- // Put buffer to aListOfFiles and set to myMap
- ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile);
- SetListOfFiles(aModuleName, aListOfFiles);
-
- delete[] aModuleName;
- delete[] aBuffer;
- }
-
- delete[] aFileBuffer;
-
- return true;
-}
-
-/*!
- \return temp directory for path 'theURL'
-*/
-std::string LightApp_Driver::GetTmpDir (const char* theURL, const bool isMultiFile)
-{
- std::string anURLDir = GetDirFromPath(theURL);
- std::string aTmpDir = isMultiFile ? anURLDir : GetTmpDir();
-
- return aTmpDir;
-}
-
-/*!
- \return list of files for module with name 'theModuleName'
-*/
-LightApp_Driver::ListOfFiles LightApp_Driver::GetListOfFiles( const char* theModuleName )
-{
- ListOfFiles aListOfFiles;
-
- std::string aName(theModuleName);
- if (myMap.count(aName))
- aListOfFiles = myMap[aName];
-
- return aListOfFiles;
-}
-
-/*!
- Sets list of files for module with name 'theModuleName'
-*/
-void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFiles theListOfFiles )
-{
- std::string aName (theModuleName);
- myMap[aName] = theListOfFiles;
-}
-
-/*!
- Converts files which was created from module <theModuleName> into a byte sequence unsigned char
-*/
-void LightApp_Driver::PutFilesToStream( const std::string& theModuleName, unsigned char*& theBuffer,
- long& theBufferSize, bool theNamesOnly )
-{
- ListOfFiles aFiles = myMap[theModuleName];
- // aFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
-
- int i, aLength = aFiles.size() - 1;
- if(aLength <= 0) {
- theBufferSize = 0;
- theBuffer = new unsigned char[theBufferSize];
- return;
- }
- //Get a temporary directory for saved a file
- TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
-
- long aBufferSize = 0;
- long aCurrentPos;
- int aNbFiles = 0;
- int* aFileNameSize= new int[aLength];
- long* aFileSize= new long[aLength];
-
- //Determine the required size of the buffer
- TCollection_AsciiString aFileName;
- for (i = 0; i < aLength; i++) {
- char* aFName = const_cast<char*>(aFiles[i+1].c_str());
- aFileName = aFName;
- //Check if the file exists
- if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero
- TCollection_AsciiString aFullPath = aTmpDir + aFileName;
- OSD_Path anOSDPath(aFullPath);
- OSD_File anOSDFile(anOSDPath);
- if(!anOSDFile.Exists()) continue;
-#ifdef WNT
- ifstream aFile(aFullPath.ToCString(), ios::binary);
-#else
- ifstream aFile(aFullPath.ToCString());
-#endif
- aFile.seekg(0, ios::end);
- aFileSize[i] = aFile.tellg();
- aBufferSize += aFileSize[i]; //Add a space to store the file
- }
- aFileNameSize[i] = strlen(aFName) + 1;
- aBufferSize += aFileNameSize[i]; //Add a space to store the file name
- aBufferSize += (theNamesOnly)?4:12; //Add 4 bytes: a length of the file name,
- // 8 bytes: length of the file itself
- aNbFiles++;
- }
-
- aBufferSize += 4; //4 bytes for a number of the files that will be written to the stream;
- theBuffer = new unsigned char[aBufferSize];
- if(theBuffer == NULL) {
- theBufferSize = 0;
- theBuffer = 0;
- return;
- }
- //Initialize 4 bytes of the buffer by 0
- memset(theBuffer, 0, 4);
- //Copy the number of files that will be written to the stream
- memcpy(theBuffer, &aNbFiles, ((sizeof(int) > 4) ? 4 : sizeof(int)));
-
- aCurrentPos = 4;
-
- for(i = 0; i < aLength; i++) {
- ifstream *aFile;
- if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
- TCollection_AsciiString aName(const_cast<char*>(aFiles[i+1].c_str()));
- TCollection_AsciiString aFullPath = aTmpDir + aName;
- OSD_Path anOSDPath(aFullPath);
- OSD_File anOSDFile(anOSDPath);
- if(!anOSDFile.Exists()) continue;
-#ifdef WNT
- aFile = new ifstream(aFullPath.ToCString(), ios::binary);
-#else
- aFile = new ifstream(aFullPath.ToCString());
-#endif
- }
- //Initialize 4 bytes of the buffer by 0
- memset((theBuffer + aCurrentPos), 0, 4);
- //Copy the length of the file name to the buffer
- memcpy((theBuffer + aCurrentPos), (aFileNameSize + i), ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
-
- //Copy the file name to the buffer
- char* aFName = const_cast<char*>(aFiles[i+1].c_str());
- memcpy((theBuffer + aCurrentPos), aFName, aFileNameSize[i]);
- aCurrentPos += aFileNameSize[i];
-
- if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
- //Initialize 8 bytes of the buffer by 0
- memset((theBuffer + aCurrentPos), 0, 8);
- //Copy the length of the file to the buffer
- memcpy((theBuffer + aCurrentPos), (aFileSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long)));
- aCurrentPos += 8;
-
- aFile->seekg(0, ios::beg);
- aFile->read((char *)(theBuffer + aCurrentPos), aFileSize[i]);
- aFile->close();
- delete(aFile);
- aCurrentPos += aFileSize[i];
- }
- }
- delete[] aFileNameSize;
- delete[] aFileSize;
-
- theBufferSize = aBufferSize;
-}
-
-/*!
- Converts a byte sequence <theBuffer> to files and return list of them
-*/
-LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned char* theBuffer,
- const long theBufferSize, bool theNamesOnly )
-{
- if(theBufferSize == 0 || theBuffer == 0)
- return ListOfFiles();
-
- // Create a temporary directory for the component's data files
- std::string aDir = GetTmpDir();
-
- // Remember that the files are in a temporary location that should be deleted
- // when a study is closed
- SetIsTemporary( true );
-
- //Get a temporary directory for saving a file
- TCollection_AsciiString aTmpDir(const_cast<char*>(aDir.c_str()));
-
- long aFileSize, aCurrentPos = 4;
- int i, aFileNameSize, aNbFiles = 0;
-
- //Copy the number of files in the stream
- memcpy(&aNbFiles, theBuffer, sizeof(int));
-
- const int n = aNbFiles + 1;
- ListOfFiles aFiles(n);
- aFiles[0] = aDir;
-
- for(i = 0; i < aNbFiles; i++) {
- //Put a length of the file name to aFileNameSize
- memcpy(&aFileNameSize, (theBuffer + aCurrentPos), ((sizeof(int) > 4) ? 4 : sizeof(int)));
- aCurrentPos += 4;
-
- char *aFileName = new char[aFileNameSize];
- //Put a file name to aFileName
- memcpy(aFileName, (theBuffer + aCurrentPos), aFileNameSize);
- aCurrentPos += aFileNameSize;
-
- //Put a length of the file to aFileSize
- if (!theNamesOnly) {
- memcpy(&aFileSize, (theBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
- aCurrentPos += 8;
-
- TCollection_AsciiString aFullPath = aTmpDir + aFileName;
-
-#ifdef WNT
- ofstream aFile(aFullPath.ToCString(), ios::out | ios::binary);
-#else
- ofstream aFile(aFullPath.ToCString());
-#endif
-
- aFile.write((char *)(theBuffer+aCurrentPos), aFileSize);
- aFile.close();
- aCurrentPos += aFileSize;
- }
- std::string aStrFileName(aFileName);
- aFiles[i+1] = aStrFileName;
- delete[] aFileName;
- }
- return aFiles;
-}
-
-/*!
- Remove files. First item in <theFiles> is a directory with slash at the end.
- Other items are names of files. If <IsDirDeleted> is true,
- then the directory is also deleted.
-*/
-void LightApp_Driver::RemoveFiles( const ListOfFiles& theFiles, const bool IsDirDeleted)
-{
- int i, aLength = theFiles.size() - 1;
- if(aLength <= 0) {
- return;
- }
- //Get a temporary directory for saved a file
- TCollection_AsciiString aDirName(const_cast<char*>(theFiles[0].c_str()));
-
- for(i = 0; i < aLength; i++) {
- TCollection_AsciiString aFile(aDirName);
- aFile += const_cast<char*>(theFiles[i+1].c_str());
- OSD_Path anOSDPath(aFile);
- OSD_File anOSDFile(anOSDPath);
- if(!anOSDFile.Exists()) continue;
-
- anOSDFile.Remove();
- }
-
- if(IsDirDeleted) {
- OSD_Path aPath(aDirName);
- OSD_Directory aDir(aPath);
- // san -- Using a special code block below is essential - it ensures that
- // OSD_FileIterator instance is destroyed by the moment when
- // OSD_Directory::Remove() is called.
- // Otherwise, the directory remains locked (at least on Windows)
- // by the iterator and cannot be removed.
- {
- OSD_FileIterator anIterator(aPath, '*');
- if(!aDir.Exists() || anIterator.More())
- return;
- }
- aDir.Remove();
- }
-}
-
-/*!
- Removes files which was created from module theModuleName if
- <IsDirDeleted> is true tmp directory is also deleted if it is empty
-*/
-void LightApp_Driver::RemoveTemporaryFiles( const char* theModuleName, const bool IsDirDeleted )
-{
- std::string aModuleName(theModuleName);
- ListOfFiles aFiles = myMap[aModuleName];
- // aFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
- RemoveFiles( aFiles, IsDirDeleted );
-
-}
-
-/*!
- Clears map of list files
-*/
-void LightApp_Driver::ClearDriverContents()
-{
- std::map<std::string, ListOfFiles>::iterator it;
- for ( it = myMap.begin(); it != myMap.end(); ++it )
- {
- const char* aModuleName = const_cast<char*>(it->first.c_str());
- // If the driver contains temporary files -
- // remove them along with the temporary directory
- RemoveTemporaryFiles( aModuleName, IsTemporary() );
- }
- myMap.clear();
- // Reset the "temporary" flag
- SetIsTemporary( false );
-}
-
-/*!
- \return a temp directory to store created files like "/tmp/sub_dir/"
-*/
-std::string LightApp_Driver::GetTmpDir()
-{
- if ( myTmpDir.length() != 0 )
- return myTmpDir;
-
- //Find a temporary directory to store a file
- TCollection_AsciiString aTmpDir;
-
- char *Tmp_dir = getenv("SALOME_TMP_DIR");
- if ( !Tmp_dir )
- Tmp_dir = getenv ( "TEMP" );
- if ( !Tmp_dir )
- Tmp_dir = getenv ( "TMP" );
- if ( Tmp_dir )
- {
- aTmpDir = TCollection_AsciiString(Tmp_dir);
-#ifdef WIN32
- if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
-#else
- if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
-#endif
- }
- else
- {
-#ifdef WIN32
- aTmpDir = TCollection_AsciiString("C:\\");
-#else
- aTmpDir = TCollection_AsciiString("/tmp/");
-#endif
- }
-
- srand((unsigned int)time(NULL));
- int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory
- TCollection_AsciiString aSubDir(aRND);
- if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
-
- aTmpDir += aSubDir; //Get RND sub directory
-
-#ifdef WIN32
- if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
-#else
- if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
-#endif
-
- OSD_Path aPath(aTmpDir);
- OSD_Directory aDir(aPath);
-
- for(aRND = 0; aDir.Exists(); aRND++) {
- aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name
- aPath = OSD_Path(aTmpDir);
- aDir = OSD_Directory(aPath);
- }
-
-#ifdef WIN32
- // Workaround for OSD_Protection bug on Windows
- OSD_Protection aProtection(OSD_RWXD, OSD_RWXD, OSD_RWXD, OSD_RWXD);
-#else
- OSD_Protection aProtection(OSD_RX, OSD_RWXD, OSD_RX, OSD_RX);
-#endif
- aDir.Build(aProtection);
-
- myTmpDir = aTmpDir.ToCString();
-
- return aTmpDir.ToCString();
-}
-
-/*!
- \return the dir by the path
-*/
-std::string LightApp_Driver::GetDirFromPath( const std::string& thePath ) {
- if(thePath == "")
- return "";
- OSD_Path aPath = OSD_Path(TCollection_AsciiString(const_cast<char*>(thePath.c_str())));
- TCollection_AsciiString aDirString(aPath.Trek());
- aDirString.ChangeAll('|','/');
- return aDirString.ToCString();
-}
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_DRIVER_H
-#define LIGHTAPP_DRIVER_H
-
-#include <LightApp.h>
-
-#include "string"
-#include "vector"
-#include "map"
-
-#ifdef WIN32
-#pragma warning( disable:4251 )
-#endif
-
-/*!Description : Driver can save to file and read from file list of files for light modules*/
-
-class LIGHTAPP_EXPORT LightApp_Driver
-{
-public:
- LightApp_Driver();
- virtual ~LightApp_Driver();
-
-
- typedef std::vector<std::string> ListOfFiles;
-
- virtual bool SaveDatasInFile (const char* theFileName, bool isMultiFile);
- virtual bool ReadDatasFromFile (const char* theFileName, bool isMultiFile);
- virtual std::string GetTmpDir (const char* theURL, const bool isMultiFile);
-
- ListOfFiles GetListOfFiles (const char* theModuleName);
- virtual void SetListOfFiles (const char* theModuleName, const ListOfFiles theListOfFiles);
- virtual void RemoveTemporaryFiles(const char* theModuleName, const bool IsDirDeleted);
- void RemoveFiles( const ListOfFiles& theFiles, const bool IsDirDeleted);
-
- virtual void ClearDriverContents();
-
-protected:
- void PutFilesToStream(const std::string& theModuleName, unsigned char*& theBuffer,
- long& theBufferSize, bool theNamesOnly = false);
- ListOfFiles PutStreamToFiles(const unsigned char* theBuffer,
- const long theBufferSize, bool theNamesOnly = false);
-
- std::string GetTmpDir();
- std::string GetDirFromPath(const std::string& thePath);
-
- void SetIsTemporary( bool theFlag ) { myIsTemp = theFlag; }
- bool IsTemporary() const { return myIsTemp; }
-
-protected:
- typedef std::map<std::string, ListOfFiles> MapOfListOfFiles;
- MapOfListOfFiles myMap;
- std::string myTmpDir;
-
-private:
- bool myIsTemp;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "LightApp_EventFilter.h"
-
-#include <SUIT_Desktop.h>
-
-#include <qapplication.h>
-
-LightApp_EventFilter* LightApp_EventFilter::myFilter = NULL;
-
-/*!Constructor.*/
-LightApp_EventFilter::LightApp_EventFilter()
-: QObject()
-{
- qApp->installEventFilter( this );
-}
-
-/*!Destructor.*/
-LightApp_EventFilter::~LightApp_EventFilter()
-{
- qApp->removeEventFilter( this );
-}
-
-/*!
- Custom event filter
-*/
-bool LightApp_EventFilter::eventFilter( QObject* o, QEvent* e )
-{
- if ( e->type() == QEvent::WindowActivate && o->inherits("QDialog") )
- {
- QWidget* parent = ((QWidget*)o)->parentWidget();
-
- SUIT_Desktop* aDesktop = 0;
-
- while( parent )
- {
- if ( aDesktop = dynamic_cast<SUIT_Desktop*>(parent) )
- break;
- parent = parent->parentWidget();
- }
-
- if ( aDesktop )
- aDesktop->emitActivated();
- }
-
- return QObject::eventFilter( o, e );
-}
-
-/*!Create new instance of LightApp_EventFilter*/
-void LightApp_EventFilter::Init()
-{
- if( myFilter==NULL )
- myFilter = new LightApp_EventFilter();
-}
-
-/*!Destroy filter.*/
-void LightApp_EventFilter::Destroy()
-{
- if( myFilter )
- {
- delete myFilter;
- myFilter = NULL;
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef LIGHTAPP_EVENTFILTER_H
-#define LIGHTAPP_EVENTFILTER_H
-
-#include "LightApp.h"
-
-#include <qobject.h>
-
-#if defined WNT
-#pragma warning( disable: 4251 )
-#endif
-
-/*!
- Class provide event filter.
-*/
-class LIGHTAPP_EXPORT LightApp_EventFilter: public QObject
-{
-public:
- static void Init();
- static void Destroy();
-
-protected:
- LightApp_EventFilter();
- virtual ~LightApp_EventFilter();
-
-private:
- /*! global event filter for qapplication */
- virtual bool eventFilter( QObject* o, QEvent* e );
-
-private:
- static LightApp_EventFilter* myFilter;
-};
-
-#if defined WNT
-#pragma warning( default: 4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_GLSelector.h"
-
-#include "LightApp_DataOwner.h"
-#include "LightApp_DataObject.h"
-
-#include <GLViewer_Context.h>
-
-/*!Constructor. Initialize by GLViewer_Viewer2d and SUIT_SelectionMgr.*/
-LightApp_GLSelector::LightApp_GLSelector( GLViewer_Viewer2d* viewer, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, viewer ),
- myViewer( viewer )
-{
- if ( myViewer )
- connect( myViewer, SIGNAL( selectionChanged( SelectionChangeStatus ) ),
- this, SLOT( onSelectionChanged() ) );
-}
-
-/*!Destructor. Do nothing.*/
-LightApp_GLSelector::~LightApp_GLSelector()
-{
-}
-
-/*!Gets viewer*/
-GLViewer_Viewer2d* LightApp_GLSelector::viewer() const
-{
- return myViewer;
-}
-
-/*!On selection changed event.*/
-void LightApp_GLSelector::onSelectionChanged()
-{
- selectionChanged();
-}
-
-/*!Gets list of selected Data Owner objects.*/
-void LightApp_GLSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
-{
- if ( !myViewer )
- return;
-
- GLViewer_Context* cont = myViewer->getGLContext();
- if ( !cont )
- return;
-
- for ( cont->InitSelected(); cont->MoreSelected(); cont->NextSelected() )
- {
- GLViewer_Object* obj = cont->SelectedObject();
- if ( obj )
- {
- LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( obj->owner() );
- if ( owner )
- aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( owner->entry() ) ) );
- }
- }
-}
-
-/*!Sets to selected list of Data Owner objects.*/
-void LightApp_GLSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
-{
- if ( !myViewer )
- return;
-
- GLViewer_Context* cont = myViewer->getGLContext();
- if ( !cont )
- return;
-
- QMap<QString, int> aSelected;
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
-
- if ( owner )
- aSelected.insert( owner->entry(), 0 );
- }
-
- bool changed = false;
- const ObjList& displayed = cont->getObjects();
- for ( ObjList::const_iterator it = displayed.begin(); it != displayed.end(); ++it )
- {
- GLViewer_Object* obj = *it;
- if ( obj && obj->getVisible() )
- {
- LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( obj->owner() );
- bool sel = owner && aSelected.contains( owner->entry() );
- changed = changed || sel != (bool)obj->isSelected();
- if ( sel && !obj->isSelected() )
- cont->setSelected( obj, false );
- else if ( !sel && obj->isSelected() )
- cont->remSelected( obj, false );
- }
- }
-
- if ( changed )
- myViewer->updateAll();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_GLSELECTOR_H
-#define LIGHTAPP_GLSELECTOR_H
-
-#include "LightApp.h"
-
-#include <SUIT_Selector.h>
-
-#include <GLViewer_Viewer2d.h>
-
-#include <string>
-#include <GLViewer_Object.h>
-
-class LightApp_DataObject;
-
-/*!
- \class LightApp_GLSelector
- Custom selector to get/set selection from GL viewer
-*/
-class LIGHTAPP_EXPORT LightApp_GLSelector : public SUIT_Selector
-{
- Q_OBJECT
-
-public:
- LightApp_GLSelector( GLViewer_Viewer2d*, SUIT_SelectionMgr* );
- virtual ~LightApp_GLSelector();
-
- GLViewer_Viewer2d* viewer() const;
-
- virtual QString type() const { return GLViewer_Viewer2d::Type(); }
-
-private slots:
- void onSelectionChanged();
-
-protected:
- virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
- virtual void setSelection( const SUIT_DataOwnerPtrList& );
-
-private:
- GLViewer_Viewer2d* myViewer;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_HDFDriver.h"
-
-#include "HDFexplorer.hxx"
-#include "HDFOI.hxx"
-
-// OCCT Includes
-#include <TCollection_AsciiString.hxx>
-
-/*! Constructor.*/
-LightApp_HDFDriver::LightApp_HDFDriver()
-{
-}
-
-/*! Destructor.*/
-LightApp_HDFDriver::~LightApp_HDFDriver()
-{
-}
-
-using namespace std;
-
-/*!
- Saves in file 'theFileName' datas from this driver
-*/
-bool LightApp_HDFDriver::SaveDatasInFile( const char* theFileName, bool isMultiFile )
-{
- bool isASCII = false;
- bool isError = false;
-
- HDFfile *hdf_file = 0;
- HDFgroup *hdf_group_datacomponent = 0;
- HDFgroup *hdf_group_study_structure = 0;
- HDFgroup *hdf_sco_group = 0;
- HDFgroup *hdf_sco_group2 = 0;
- HDFdataset *hdf_dataset = 0;
- hdf_size aHDFSize[1];
-
- try {
- hdf_file = new HDFfile ((char*)theFileName);
- hdf_file->CreateOnDisk();
-
- //-----------------------------------------------------------------------
- // 1 - Create a groupe for each SComponent and Update the PersistanceRef
- //-----------------------------------------------------------------------
- hdf_group_datacomponent = new HDFgroup ("DATACOMPONENT", hdf_file);
- hdf_group_datacomponent->CreateOnDisk();
-
- std::map<std::string, std::string> mapNameEntry;
-
- int tag = 1;
- std::map<std::string, ListOfFiles>::const_iterator it;
- for (it = myMap.begin(); it != myMap.end(); ++it, ++tag) {
- std::string aName (it->first);
- char* aModuleName = const_cast<char*>(aName.c_str());
- unsigned char* aBuffer;
- long aBufferSize;
- PutFilesToStream(aName, aBuffer, aBufferSize, isMultiFile);
-
- //Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value();
- //TCollection_AsciiString scoid = sco->GetID();
- //hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent);
-
- TCollection_AsciiString entry ("0:1:");
- entry += TCollection_AsciiString(tag);
- mapNameEntry[aModuleName] = entry.ToCString();
-
- //hdf_sco_group = new HDFgroup (aModuleName, hdf_group_datacomponent);
- hdf_sco_group = new HDFgroup (entry.ToCString(), hdf_group_datacomponent);
- hdf_sco_group->CreateOnDisk();
-
- aHDFSize[0] = aBufferSize;
-
- hdf_dataset = new HDFdataset ("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(aBuffer); //Save the stream in the HDF file
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
-
- // store multifile state
- aHDFSize[0] = 2;
- hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((void*)(isMultiFile ? "M" : "S")); // save: multi or single
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
-
- // store ASCII state
- aHDFSize[0] = 2;
- hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((void*)(isASCII ? "A" : "B")); // save: ASCII or BINARY
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
-
- hdf_sco_group->CloseOnDisk();
- hdf_sco_group = 0; // will be deleted by hdf_group_datacomponent destructor
-
- delete [] aBuffer;
- }
-
- hdf_group_datacomponent->CloseOnDisk();
- hdf_group_datacomponent = 0; // will be deleted by hdf_file destructor
-
- //-----------------------------------------------------------------------
- // 3 - Write the Study Structure
- //-----------------------------------------------------------------------
- hdf_group_study_structure = new HDFgroup ("STUDY_STRUCTURE", hdf_file);
- hdf_group_study_structure->CreateOnDisk();
-
- for (it = myMap.begin(); it != myMap.end(); ++it) {
- std::string aName (it->first);
- char* aModuleName = const_cast<char*>(aName.c_str());
-
- //hdf_sco_group2 = new HDFgroup(scid.ToCString(), hdf_group_study_structure);
- char* entry = (char*)(mapNameEntry[aModuleName].c_str());
- hdf_sco_group2 = new HDFgroup (entry, hdf_group_study_structure);
- hdf_sco_group2->CreateOnDisk();
-
- // ComponentDataType treatment
- hdf_int32 name_len = (hdf_int32)strlen(aModuleName);
- aHDFSize[0] = name_len + 1;
- hdf_dataset = new HDFdataset ("COMPONENTDATATYPE", hdf_sco_group2, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(aModuleName);
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0; //will be deleted by hdf_sco_group2 destructor
-
- hdf_sco_group2->CloseOnDisk();
- hdf_sco_group2 = 0; // will be deleted by hdf_group_study_structure destructor
- }
-
- hdf_group_study_structure->CloseOnDisk();
- hdf_group_study_structure = 0; // will be deleted by hdf_file destructor
-
- hdf_file->CloseOnDisk();
- delete hdf_file; // recursively deletes all hdf objects...
-
- } catch (HDFexception) {
- isError = true;
- }
- if (isASCII && !isError) { // save file in ASCII format
- HDFascii::ConvertFromHDFToASCII(theFileName, true);
- }
-
- return !isError;
-}
-
-/*!
- Filling current driver from file 'theFileName'
-*/
-bool LightApp_HDFDriver::ReadDatasFromFile( const char* theFileName, bool isMultiFile )
-{
- bool isASCII = false;
- bool isError = false;
- TCollection_AsciiString aHDFUrl;
-
- HDFfile *hdf_file = 0;
- HDFgroup *hdf_group_datacomponent = 0;
- HDFgroup *hdf_group_study_structure = 0;
- HDFgroup *hdf_sco_group = 0;
- HDFgroup *hdf_sco_group2 = 0;
-
- std::map<std::string, std::string> mapEntryName;
-
- if (HDFascii::isASCII(theFileName)) {
- isASCII = true;
- char* aResultPath = HDFascii::ConvertFromASCIIToHDF(theFileName);
- aHDFUrl = aResultPath;
- aHDFUrl += "hdf_from_ascii.hdf";
- delete(aResultPath);
- } else {
- aHDFUrl = (char*)theFileName;
- }
-
- hdf_file = new HDFfile((char*)aHDFUrl.ToCString());
-
- char aMultifileState[2];
- char ASCIIfileState[2];
-
- try {
- hdf_file->OpenOnDisk(HDF_RDONLY);
-
- } catch (HDFexception) {
- //char *eStr = new char[strlen(aUrl.ToCString()) + 17];
- //sprintf(eStr,"Can't open file %s", aUrl.ToCString());
- //_errorCode = TCollection_AsciiString(eStr);
- //delete [] eStr;
- return false;
- }
-
- try {
- if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) {
- //_errorCode = "Study is empty";
- isError = true;
- } else {
- hdf_group_study_structure = new HDFgroup ("STUDY_STRUCTURE", hdf_file);
- hdf_group_study_structure->OpenOnDisk();
-
- char name[HDF_NAME_MAX_LEN + 1];
- Standard_Integer nbsons = hdf_group_study_structure->nInternalObjects();
- for (Standard_Integer i = 0; i < nbsons; i++) {
- hdf_group_study_structure->InternalObjectIndentify(i, name);
- if (strncmp(name, "INTERNAL_COMPLEX", 16) == 0) continue;
- hdf_object_type type = hdf_group_study_structure->InternalObjectType(name);
- if (type == HDF_GROUP) {
- hdf_sco_group2 = new HDFgroup (name, hdf_group_study_structure);
- hdf_sco_group2->OpenOnDisk();
-
- // Read component data
- char* aCompDataType = NULL;
- int aDataSize = 0;
-
- if (hdf_sco_group2->ExistInternalObject("COMPONENTDATATYPE")) {
- HDFdataset *hdf_dataset = new HDFdataset("COMPONENTDATATYPE", hdf_sco_group2);
- hdf_dataset->OpenOnDisk();
- aDataSize = hdf_dataset->GetSize();
- aCompDataType = new char[aDataSize];
- if (aCompDataType == NULL) {
- isError = true;
- } else {
- hdf_dataset->ReadFromDisk(aCompDataType);
-
- mapEntryName[name] = aCompDataType;
-
- delete [] aCompDataType;
- }
-
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0;
- }
-
- hdf_sco_group2->CloseOnDisk();
- }
- }
-
- hdf_group_study_structure->CloseOnDisk();
- }
-
- if (!hdf_file->ExistInternalObject("DATACOMPONENT")) {
- //_errorCode = "No components stored";
- isError = true;
- } else {
- hdf_group_datacomponent = new HDFgroup ("DATACOMPONENT", hdf_file);
- hdf_group_datacomponent->OpenOnDisk();
-
- char name[HDF_NAME_MAX_LEN + 1];
- Standard_Integer nbsons = hdf_group_datacomponent->nInternalObjects();
- for (Standard_Integer i = 0; i < nbsons; i++) {
- hdf_group_datacomponent->InternalObjectIndentify(i, name);
- if (strncmp(name, "INTERNAL_COMPLEX", 16) == 0) continue;
- hdf_object_type type = hdf_group_datacomponent->InternalObjectType(name);
- if (type == HDF_GROUP) {
- hdf_sco_group = new HDFgroup (name, hdf_group_datacomponent);
- hdf_sco_group->OpenOnDisk();
-
- // Read component data
- unsigned char* aStreamFile = NULL;
- int aStreamSize = 0;
-
- if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
- HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
- hdf_dataset->OpenOnDisk();
- aStreamSize = hdf_dataset->GetSize();
- aStreamFile = new unsigned char[aStreamSize];
- if (aStreamFile == NULL) {
- isError = true;
- } else {
- hdf_dataset->ReadFromDisk(aStreamFile);
- }
-
- hdf_dataset->CloseOnDisk();
- hdf_dataset = 0;
- }
-
- HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
- multifile_hdf_dataset->OpenOnDisk();
- multifile_hdf_dataset->ReadFromDisk(aMultifileState);
- multifile_hdf_dataset->CloseOnDisk();
- multifile_hdf_dataset = 0;
-
- HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
- ascii_hdf_dataset->OpenOnDisk();
- ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
- ascii_hdf_dataset->CloseOnDisk();
- ascii_hdf_dataset = 0;
-
- isASCII = (ASCIIfileState[0] == 'A') ? true : false;
-
- if (aStreamFile != NULL) {
- // Put buffer to aListOfFiles and set to myMap
- ListOfFiles aListOfFiles = PutStreamToFiles(aStreamFile, aStreamSize, isMultiFile);
- char* aCompDataType = (char*)(mapEntryName[name].c_str());
- SetListOfFiles(aCompDataType, aListOfFiles);
-
- delete [] aStreamFile;
- }
-
- hdf_sco_group->CloseOnDisk();
- }
- }
-
- hdf_group_datacomponent->CloseOnDisk();
- }
- } catch (HDFexception) {
- isError = true;
-
- //Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString;
- //aFilesToRemove->Append(aHDFUrl);
- //RemoveFiles(aFilesToRemove, true);
- }
-
- hdf_file->CloseOnDisk();
- delete hdf_file; // all related hdf objects will be deleted
-
- if (isASCII && !isError) {
- //Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString;
- //aFilesToRemove->Append(aHDFUrl);
- //RemoveFiles(aFilesToRemove, true);
- }
-
- //std::map<std::string, std::string>::const_iterator it;
- //for (it = mapEntryName.begin(); it != mapEntryName.end(); ++it) {
- // cout << "Read Component: entry = " << it->first
- // << ", Component data type = " << it->second << endl;
- //}
-
- return !isError;
-}
+++ /dev/null
-// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_HDFDRIVER_H
-#define LIGHTAPP_HDFDRIVER_H
-
-#include <LightApp.h>
-#include <LightApp_Driver.h>
-
-#ifdef WIN32
-#pragma warning( disable:4251 )
-#endif
-
-/*!Description : Driver can save to file and read from file list of files for light modules*/
-
-class LIGHTAPP_EXPORT LightApp_HDFDriver : public LightApp_Driver
-{
-public:
- LightApp_HDFDriver();
- virtual ~LightApp_HDFDriver();
-
- virtual bool SaveDatasInFile (const char* theFileName, bool isMultiFile);
- virtual bool ReadDatasFromFile (const char* theFileName, bool isMultiFile);
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Module.cxx
-// Created: 6/20/2005 16:30:56 AM
-// Author: OCC team
-// Copyright (C) CEA 2005
-
-#include "LightApp_Module.h"
-
-#include "CAM_Application.h"
-
-#include "LightApp_Application.h"
-#include "LightApp_DataModel.h"
-#include "LightApp_DataObject.h"
-#include "LightApp_Study.h"
-#include "LightApp_Preferences.h"
-#include "LightApp_Selection.h"
-#include "LightApp_Operation.h"
-#include "LightApp_SwitchOp.h"
-#include "LightApp_UpdateFlags.h"
-#include "LightApp_ShowHideOp.h"
-
-#include "SUIT_Operation.h"
-#include <SUIT_Study.h>
-#include <SUIT_DataObject.h>
-#include <SUIT_ResourceMgr.h>
-
-#ifndef DISABLE_VTKVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- #include <SVTK_ViewWindow.h>
- #include <SVTK_ViewModel.h>
-#else
- #include <VTKViewer_ViewWindow.h>
-#endif
- #include <VTKViewer_ViewModel.h>
-#endif
-#ifndef DISABLE_OCCVIEWER
- #include <OCCViewer_ViewWindow.h>
- #include <OCCViewer_ViewPort3d.h>
-#ifndef DISABLE_SALOMEOBJECT
- #include <SOCC_ViewModel.h>
-#else
- #include <OCCViewer_ViewModel.h>
-#endif
-#endif
-#ifndef DISABLE_GLVIEWER
- #include <GLViewer_ViewFrame.h>
- #include <GLViewer_ViewPort.h>
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
- #include <Plot2d_ViewWindow.h>
- #include <Plot2d_ViewFrame.h>
-#ifndef DISABLE_SALOMEOBJECT
- #include <SPlot2d_ViewModel.h>
-#else
- #include <Plot2d_ViewModel.h>
-#endif
-#endif
-
-#include <OB_Browser.h>
-
-#include <QtxPopupMgr.h>
-
-#include <qvariant.h>
-#include <qstring.h>
-#include <qstringlist.h>
-
-/*!Constructor.*/
-LightApp_Module::LightApp_Module( const QString& name )
-: CAM_Module( name ),
- myPopupMgr( 0 ),
- mySwitchOp( 0 ),
- myDisplay( -1 ),
- myErase( -1 ),
- myDisplayOnly( -1 ),
- myEraseAll( -1 )
-{
-}
-
-/*!Destructor.*/
-LightApp_Module::~LightApp_Module()
-{
- if ( mySwitchOp )
- delete mySwitchOp;
-}
-
-/*!Initialize module.*/
-void LightApp_Module::initialize( CAM_Application* app )
-{
- CAM_Module::initialize( app );
-
- SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
- if ( resMgr )
- resMgr->raiseTranslators( name() );
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::windows( QMap<int, int>& ) const
-{
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::viewManagers( QStringList& ) const
-{
-}
-
-/*!Context menu popup.*/
-void LightApp_Module::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
-{
- LightApp_Selection* sel = createSelection();
- sel->init( client, getApp()->selectionMgr() );
- popupMgr()->updatePopup( menu, sel );
- delete sel;
-}
-
-/*!Update object browser.
- * For updating model or whole object browser use update() method can be used.
-*/
-void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel,
- SUIT_DataObject* theDataObject )
-{
- bool upd = getApp()->objectBrowser()->isAutoUpdate();
- getApp()->objectBrowser()->setAutoUpdate( false );
-
- if( theIsUpdateDataModel ){
- if( CAM_DataModel* aDataModel = dataModel() ){
- if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
- SUIT_DataObject* aParent = NULL;
- if(theDataObject && theDataObject != aDataModel->root())
- aParent = theDataObject->parent();
-
- LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
- LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
- aModel->update( anObject, aStudy );
- }
- }
- }
- getApp()->objectBrowser()->setAutoUpdate( upd );
- getApp()->objectBrowser()->updateTree( 0, false );
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::selectionChanged()
-{
-}
-
-/*!Activate module.*/
-bool LightApp_Module::activateModule( SUIT_Study* study )
-{
- bool res = CAM_Module::activateModule( study );
-
- if ( res && application() && application()->resourceMgr() )
- application()->resourceMgr()->raiseTranslators( name() );
-
- connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
- connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
-
- if ( mySwitchOp == 0 )
- mySwitchOp = new LightApp_SwitchOp( this );
-
- return res;
-}
-
-/*!Deactivate module.*/
-bool LightApp_Module::deactivateModule( SUIT_Study* study )
-{
- delete mySwitchOp;
- mySwitchOp = 0;
-
- disconnect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
- disconnect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
-
- // abort all operations
- MapOfOperation::const_iterator anIt;
- for( anIt = myOperations.begin(); anIt != myOperations.end(); anIt++ ) {
- anIt.data()->abort();
- }
-
- return CAM_Module::activateModule( study );
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::MenuItem()
-{
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::createPreferences()
-{
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::preferencesChanged( const QString&, const QString& )
-{
-}
-
-/*!Gets application.*/
-LightApp_Application* LightApp_Module::getApp() const
-{
- return (LightApp_Application*)application();
-}
-
-/*!
- * \brief Update something in accordance with update flags
- * \param theFlags - update flags
-*
-* Update viewer or/and object browser etc. in accordance with update flags ( see
-* LightApp_UpdateFlags enumeration ). Derived modules can redefine this method for their
-* own purposes
-*/
-void LightApp_Module::update( const int theFlags )
-{
- if ( theFlags & UF_Model )
- {
- if( CAM_DataModel* aDataModel = dataModel() )
- if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
- aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
- }
- if ( theFlags & UF_ObjBrowser )
- getApp()->objectBrowser()->updateTree( 0 );
- if ( theFlags & UF_Controls )
- updateControls();
- if ( theFlags & UF_Viewer )
- {
- if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() )
- if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() )
- {
-#ifndef DISABLE_VTKVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- if ( viewWnd->inherits( "SVTK_ViewWindow" ) )
- ( (SVTK_ViewWindow*)viewWnd )->Repaint();
-#else
- if ( viewWnd->inherits( "VTKViewer_ViewWindow" ) )
- ( (VTKViewer_ViewWindow*)viewWnd )->Repaint();
-#endif
-#endif
-#ifndef DISABLE_OCCVIEWER
- if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) )
- ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate();
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
- if ( viewWnd->inherits( "Plot2d_ViewWindow" ) )
- ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint();
-#endif
-#ifndef DISABLE_GLVIEWER
- if ( viewWnd->inherits( "GLViewer_ViewFrame" ) )
- ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate();
-#endif
- }
- }
-}
-/*!
- * \brief Updates controls
-*
-* Updates (i.e. disable/enable) controls states (menus, tool bars etc.). This method is
-* called from update( UF_Controls ). You may redefine it in concrete module.
-*/
-void LightApp_Module::updateControls()
-{
-}
-
-/*!Create new instance of data model and return it.*/
-CAM_DataModel* LightApp_Module::createDataModel()
-{
- return new LightApp_DataModel(this);
-}
-
-/*!Create and return instance of LightApp_Selection.*/
-LightApp_Selection* LightApp_Module::createSelection() const
-{
- return new LightApp_Selection();
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::onModelOpened()
-{
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::onModelSaved()
-{
-}
-
-/*!NOT IMPLEMENTED*/
-void LightApp_Module::onModelClosed()
-{
-}
-
-/*!Gets popup manager.(create if not exist)*/
-QtxPopupMgr* LightApp_Module::popupMgr()
-{
- if ( !myPopupMgr )
- {
- myPopupMgr = new QtxPopupMgr( 0, this );
-
- QPixmap p;
- SUIT_Desktop* d = application()->desktop();
-
- QAction
- *disp = createAction( -1, tr( "TOP_DISPLAY" ), p, tr( "MEN_DISPLAY" ), tr( "STB_DISPLAY" ),
- 0, d, false, this, SLOT( onShowHide() ) ),
- *erase = createAction( -1, tr( "TOP_ERASE" ), p, tr( "MEN_ERASE" ), tr( "STB_ERASE" ),
- 0, d, false, this, SLOT( onShowHide() ) ),
- *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
- 0, d, false, this, SLOT( onShowHide() ) ),
- *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
- 0, d, false, this, SLOT( onShowHide() ) );
- myDisplay = actionId( disp );
- myErase = actionId( erase );
- myDisplayOnly = actionId( dispOnly );
- myEraseAll = actionId( eraseAll );
-
- myPopupMgr->insert( disp, -1, 0 );
- myPopupMgr->insert( erase, -1, 0 );
- myPopupMgr->insert( dispOnly, -1, 0 );
- myPopupMgr->insert( eraseAll, -1, 0 );
- myPopupMgr->insert( separator(), -1, 0 );
-
- QString oneAndNotActive = "( count( $component ) = 1 ) and ( component != activeModule )";
- QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )";
- uniform = uniform.arg( oneAndNotActive ).arg( name() );
- myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, true );
- myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, true );
- myPopupMgr->setRule( dispOnly, uniform, true );
-
- QStringList viewers;
-
-#ifndef DISABLE_OCCVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- viewers.append( SOCC_Viewer::Type() );
-#else
- viewers.append( OCCViewer_Viewer::Type() );
-#endif
-#endif
-#ifndef DISABLE_VTKVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- viewers.append( SVTK_Viewer::Type() );
-#else
- viewers.append( VTKViewer_Viewer::Type() );
-#endif
-#endif
-#ifndef DISABLE_PLOT2DVIEWER
-#ifndef DISABLE_SALOMEOBJECT
- viewers.append( SPlot2d_Viewer::Type() );
-#else
- viewers.append( Plot2d_Viewer::Type() );
-#endif
-#endif
-
- if( !viewers.isEmpty() )
- {
- QString strViewers = "{ ", temp = "'%1' ";
- QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end();
- for( ; anIt!=aLast; anIt++ )
- strViewers+=temp.arg( *anIt );
- strViewers+="}";
- myPopupMgr->setRule( eraseAll, QString( "client in %1" ).arg( strViewers ), true );
- }
- }
- return myPopupMgr;
-}
-
-/*!Gets preferences.*/
-LightApp_Preferences* LightApp_Module::preferences() const
-{
- LightApp_Preferences* pref = 0;
- if ( getApp() )
- pref = getApp()->preferences();
- return pref;
-}
-
-/*!Add preference to preferences.*/
-int LightApp_Module::addPreference( const QString& label )
-{
- LightApp_Preferences* pref = preferences();
- if ( !pref )
- return -1;
-
- int catId = pref->addPreference( moduleName(), -1 );
- if ( catId == -1 )
- return -1;
-
- return pref->addPreference( label, catId );
-}
-
-/*!Add preference to preferences.*/
-int LightApp_Module::addPreference( const QString& label, const int pId, const int type,
- const QString& section, const QString& param )
-{
- LightApp_Preferences* pref = preferences();
- if ( !pref )
- return -1;
-
- return pref->addPreference( moduleName(), label, pId, type, section, param );
-}
-
-/*!Gets property of preferences.*/
-QVariant LightApp_Module::preferenceProperty( const int id, const QString& prop ) const
-{
- QVariant var;
- LightApp_Preferences* pref = preferences();
- if ( pref )
- var = pref->itemProperty( id, prop );
- return var;
-}
-
-/*!Set property of preferences.*/
-void LightApp_Module::setPreferenceProperty( const int id, const QString& prop, const QVariant& var )
-{
- LightApp_Preferences* pref = preferences();
- if ( pref )
- pref->setItemProperty( id, prop, var );
-}
-
-/*!
- * \brief Starts operation with given identifier
- * \param id - identifier of operation to be started
-*
-* Module stores operations in map. This method starts operation by id.
-* If operation isn't in map, then it will be created by createOperation method
-* and will be inserted to map
-*/
-void LightApp_Module::startOperation( const int id )
-{
- LightApp_Operation* op = 0;
- if( myOperations.contains( id ) )
- op = myOperations[ id ];
- else
- {
- op = createOperation( id );
- if( op )
- {
- myOperations.insert( id, op );
- op->setModule( this );
- connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) );
- connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) );
- }
- }
-
- if( op )
- {
- // be sure that operation has correct study pointer
- op->setStudy( application() ? application()->activeStudy() : 0 );
- op->start();
- }
-}
-
-/*!
- * \brief Creates operation with given identifier
- * \param id - identifier of operation to be started
- * \return Pointer on created operation or NULL if operation is not created
-*
-* Creates operation with given id. You should not call this method, it will be called
-* automatically from startOperation. You may redefine this method in concrete module to
-* create operations.
-*/
-LightApp_Operation* LightApp_Module::createOperation( const int id ) const
-{
- if( id==-1 )
- return 0;
-
- if( id==myDisplay )
- return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY );
- else if( id==myErase )
- return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE );
- else if( id==myDisplayOnly )
- return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY_ONLY );
- else if( id==myEraseAll )
- return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE_ALL );
- else
- return 0;
-}
-
-/*!
- * \brief Virtual protected slot called when operation stopped
- * \param theOp - stopped operation
-*
-* Virtual protected slot called when operation stopped. Redefine this slot if you want to
-* perform actions after stopping operation
-*/
-void LightApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ )
-{
-}
-
-/*!
- * \brief Virtual protected slot called when operation destroyed
- * \param theOp - destroyed operation
-*
-* Virtual protected slot called when operation destroyed. Redefine this slot if you want to
-* perform actions after destroying operation. Base implementation removes pointer on
-* destroyed operation from the map of operations
-*/
-void LightApp_Module::onOperationDestroyed()
-{
- const QObject* s = sender();
- if( s && s->inherits( "LightApp_Operation" ) )
- {
- const LightApp_Operation* op = ( LightApp_Operation* )s;
- MapOfOperation::const_iterator anIt = myOperations.begin(),
- aLast = myOperations.end();
- for( ; anIt!=aLast; anIt++ )
- if( anIt.data()==op )
- {
- myOperations.remove( anIt.key() );
- break;
- }
- }
-}
-
-/*!
- Must be redefined in order to use standard displayer mechanism
- \return displayer of module
-*/
-LightApp_Displayer* LightApp_Module::displayer()
-{
- return 0;
-}
-
-/*!
- SLOT: called on activating of standard operations show/hide
-*/
-void LightApp_Module::onShowHide()
-{
- if( !sender()->inherits( "QAction" ) || !popupMgr() )
- return;
-
- QAction* act = ( QAction* )sender();
- int id = actionId( act );
- if( id!=-1 )
- startOperation( id );
-}
-
-/*!
- virtual SLOT: called on view manager adding
-*/
-void LightApp_Module::onViewManagerAdded( SUIT_ViewManager* )
-{
-}
-
-/*!
- virtual SLOT: called on view manager removing
-*/
-void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* )
-{
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Module.h
-// Created: 6/20/2005 16:25:06 AM
-// Author: OCC team
-// Copyright (C) CEA 2005
-
-#ifndef LIGHTAPP_MODULE_H
-#define LIGHTAPP_MODULE_H
-
-#include "LightApp.h"
-#include <CAM_Module.h>
-
-class LightApp_Application;
-class LightApp_Preferences;
-class LightApp_Selection;
-class LightApp_Operation;
-class LightApp_SwitchOp;
-class LightApp_ShowHideOp;
-class LightApp_Displayer;
-
-class SUIT_Study;
-class SUIT_DataObject;
-class SUIT_Operation;
-class SUIT_ViewManager;
-class CAM_Application;
-
-class QtxPopupMgr;
-
-class QString;
-class QVariant;
-
-#ifdef WIN32
-#pragma warning ( disable:4251 )
-#endif
-
-/*!
- \class LightApp_Module
- Base class for all light modules
-*/
-
-class LIGHTAPP_EXPORT LightApp_Module : public CAM_Module
-{
- Q_OBJECT
-
-public:
- LightApp_Module( const QString& );
- virtual ~LightApp_Module();
-
- virtual void initialize( CAM_Application* );
- virtual void windows( QMap<int, int>& ) const;
- virtual void viewManagers( QStringList& ) const;
-
- virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
-
- virtual void createPreferences();
-
- LightApp_Application* getApp() const;
-
- virtual void update( const int );
- // Update viewer or/and object browser etc. in accordance with update flags
- // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
- // for their own purposes
-
- virtual void updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
- // Update object bropwser ( for updating model or whole object browser use update() method
- // can be used )
-
- virtual void selectionChanged();
- virtual void preferencesChanged( const QString&, const QString& );
-
- virtual void studyActivated() {};
-
- virtual LightApp_Displayer* displayer();
-
-public slots:
- virtual bool activateModule( SUIT_Study* );
- virtual bool deactivateModule( SUIT_Study* );
-
- void MenuItem();
-
-protected slots:
- virtual void onModelSaved();
- virtual void onModelOpened();
- virtual void onModelClosed();
-
- virtual void onOperationStopped( SUIT_Operation* );
- virtual void onOperationDestroyed();
- virtual void onShowHide();
- virtual void onViewManagerAdded( SUIT_ViewManager* );
- virtual void onViewManagerRemoved( SUIT_ViewManager* );
-
-protected:
- virtual QtxPopupMgr* popupMgr();
- LightApp_Preferences* preferences() const;
-
- virtual CAM_DataModel* createDataModel();
- virtual LightApp_Selection* createSelection() const;
-
- int addPreference( const QString& label );
- int addPreference( const QString& label, const int pId, const int = -1,
- const QString& section = QString::null,
- const QString& param = QString::null );
- QVariant preferenceProperty( const int, const QString& ) const;
- void setPreferenceProperty( const int, const QString&, const QVariant& );
-
- /*! Module stores operations in map. This method starts operation by id.
- * If operation isn't in map, then it will be created by createOperation method
- * and will be inserted to map
- */
- void startOperation( const int );
- /*! Create operation by its id. You must not call this method, it will be called automatically
- * by startOperation. Please redefine this method in current module
- */
- virtual LightApp_Operation* createOperation( const int ) const;
-
- virtual void updateControls();
-
-private:
- typedef QMap<int,LightApp_Operation*> MapOfOperation;
-
-private:
- QtxPopupMgr* myPopupMgr;
- MapOfOperation myOperations;
- LightApp_SwitchOp* mySwitchOp;
-
-protected:
- int myDisplay, myErase, myDisplayOnly, myEraseAll;
-};
-
-#ifdef WIN32
-#pragma warning ( default:4251 )
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : LightApp_ModuleDlg.cxx
-// Author : Michael Zorin (mzn)
-// Module : LightApp
-
-#include <LightApp_ModuleDlg.h>
-
-#include <qframe.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-
-#ifndef WIN32
-using namespace std;
-#endif
-
-/*!Default icon*/
-static const char* const default_icon[] = {
-"48 48 17 1",
-". c None",
-"# c #161e4c",
-"b c #1d3638",
-"e c #2f585b",
-"i c #345b5e",
-"c c #386266",
-"g c #3f7477",
-"d c #4d8589",
-"m c #519099",
-"o c #6abbc1",
-"a c #70c9d3",
-"f c #79ddea",
-"n c #7adff2",
-"k c #7ce2f4",
-"j c #993550",
-"h c #d84b71",
-"l c #ef537d",
-"................................................",
-"................................................",
-"................................................",
-"................................................",
-"................................................",
-"................########.########.########......",
-"...............#aaaaaa###aaaaaa###aaaaaa##......",
-"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
-".............########b########b########cc#......",
-".............#dddddd#b#dddddd#b#dddddd#cc#......",
-"...........########d########d########d#cc#......",
-"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
-".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
-"........########b########e########cc#d#c#.......",
-"........#dddddd#b#dddddd#e#ffffff#cc#d####......",
-"......########d########d########f#cc###g##......",
-".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
-"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
-"...########b########i########jj#f#c#gg#cc#......",
-"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
-"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
-"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
-"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
-"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
-"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
-"...########g########g########o##d#cc#gg#c#......",
-"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
-"...########b########b########cc#d#c#gg#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
-"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
-"...########g########g########g##g#cc#...........",
-"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
-"...########b########b########cc#g#c#............",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
-"...#kkkkkk###kkkkkk###kkkkkk##..................",
-"...########.########.########...................",
-"................................................",
-"................................................",
-"................................................",
-"................................................"};
-
-//==============================================================================================================================
-/*!
- * LightApp_ModuleDlg::LightApp_ModuleDlg \n
- *
- * Constructor.
- */
-//==============================================================================================================================
-LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )
- : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- QPixmap defaultIcon( ( const char** ) default_icon );
- setCaption( tr( "CAPTION" ) );
- setSizeGripEnabled( TRUE );
-
- QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
- ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
-
- // Module's name and icon
- myComponentFrame = new QFrame( this, "myComponentFrame" );
- myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
- myComponentFrame->setMinimumHeight( 100 );
- myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
-
- QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
- myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
-
- // --> icon
- myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
- myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
- myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
- myComponentIcon->setScaledContents( false );
- myComponentIcon->setAlignment( AlignCenter );
- // --> name
- myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
- QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
- myComponentLab->setAlignment( AlignCenter );
-
- myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
- myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
-
- // Info
- QVBoxLayout* infoLayout = new QVBoxLayout();
- infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
-
- // --> top line
- QFrame* myLine1 = new QFrame( this, "myLine1" );
- myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
- // --> info label
- myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
- myInfoLabel->setAlignment( AlignCenter );
- // --> bottom line
- QFrame* myLine2 = new QFrame( this, "myLine2" );
- myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
-
- infoLayout->addStretch();
- infoLayout->addWidget( myLine1 );
- infoLayout->addWidget( myInfoLabel );
- infoLayout->addWidget( myLine2 );
- infoLayout->addStretch();
-
- // Buttons
- QHBoxLayout* btnLayout = new QHBoxLayout();
- btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
-
- // --> New
- myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
- myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
- // --> Open
- myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
- myOpenBtn->setAutoDefault( true );
- // --> Load
- myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
- myLoadBtn->setAutoDefault( true );
- // --> Cancel
- myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
- myCancelBtn->setAutoDefault( true );
-
- btnLayout->addWidget( myNewBtn );
- btnLayout->addWidget( myOpenBtn );
- btnLayout->addWidget( myLoadBtn );
- btnLayout->addStretch();
- btnLayout->addSpacing( 70 );
- btnLayout->addStretch();
- btnLayout->addWidget( myCancelBtn );
-
- ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
- ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
- ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
-
- // signals and slots connections
- connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
-}
-
-//==============================================================================================================================
-/*!
- * LightApp_ModuleDlg::onButtonClicked
- *
- * Buttons slot
- */
-//==============================================================================================================================
-void LightApp_ModuleDlg::onButtonClicked()
-{
- QPushButton* btn = ( QPushButton* )sender();
- if ( btn == myNewBtn )
- done( 1 );
- if ( btn == myOpenBtn )
- done( 2 );
- if ( btn == myLoadBtn )
- done( 3 );
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
-// File : LightApp_ModuleDlg.h
-// Author : Michael ZORIN (mzn)
-// Module : SALOME
-
-#ifndef LIGHTAPP_MODULEDLG_H
-#define LIGHTAPP_MODULEDLG_H
-
-#include "LightApp.h"
-#include <qdialog.h>
-#include <qpixmap.h>
-
-class QFrame;
-class QLabel;
-class QPushButton;
-
-/*!
- \class LightApp_ModuleDlg
- Dialog allows to choose action on module activation when there is no document.
- It is possible to create new document, to open existing or to cancel module activation
-*/
-class LIGHTAPP_EXPORT LightApp_ModuleDlg : public QDialog
-{
- Q_OBJECT
-
-public:
- LightApp_ModuleDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ;
- ~LightApp_ModuleDlg ( ) { };
-
-private slots:
- void onButtonClicked();
-
-private:
- QFrame* myComponentFrame;
- QLabel* myComponentLab;
- QLabel* myComponentIcon;
- QLabel* myInfoLabel;
- QPushButton* myNewBtn;
- QPushButton* myOpenBtn;
- QPushButton* myLoadBtn;
- QPushButton* myCancelBtn;
-};
-
-#endif
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : LightApp_NameDlg.cxx
-// Author : Vadim SANDLER
-// $Header$
-
-#include <LightApp_NameDlg.h>
-#include <SUIT_Application.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_Tools.h>
-
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-
-#ifndef WIN32
-using namespace std;
-#endif
-
-/*!
- Constructor
-*/
-LightApp_NameDlg::LightApp_NameDlg( QWidget* parent )
-: QDialog( parent ? parent : NULL,//application()->desktop(),
-"LightApp_NameDlg",
-true,
-WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- setCaption( tr("TLT_RENAME") );
- setSizeGripEnabled( TRUE );
-
- QVBoxLayout* topLayout = new QVBoxLayout( this );
- topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
-
- /***************************************************************/
- QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
- GroupC1->setColumnLayout(0, Qt::Vertical );
- GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 );
- QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() );
- GroupC1Layout->setAlignment( Qt::AlignTop );
- GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 );
-
- QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" );
- TextLabel->setText( tr( "NAME_LBL" ) );
- GroupC1Layout->addWidget( TextLabel );
-
- myLineEdit = new QLineEdit( GroupC1, "LineEdit1" );
- myLineEdit->setMinimumSize( 250, 0 );
- GroupC1Layout->addWidget( myLineEdit );
-
- /***************************************************************/
- QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 );
- QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
-
- myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
- myButtonOk->setText( tr( "BUT_OK" ) );
- myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( myButtonOk );
-
- GroupButtonsLayout->addStretch();
-
- myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
- myButtonCancel->setText( tr( "BUT_CANCEL" ) );
- myButtonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( myButtonCancel );
- /***************************************************************/
-
- topLayout->addWidget( GroupC1 );
- topLayout->addWidget( GroupButtons );
-
- // signals and slots connections
- connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
-
- /* Move widget on the botton right corner of main widget */
- SUIT_Tools::centerWidget( this, parent );
-}
-
-/*!
- Destructor
-*/
-LightApp_NameDlg::~LightApp_NameDlg()
-{
-}
-
-/*!
- Sets name
-*/
-void LightApp_NameDlg::setName( const QString& name )
-{
- myLineEdit->setText( name );
- myLineEdit->end(false);
- myLineEdit->home(true);
-}
-
-/*!
- Returns name entered by user
-*/
-QString LightApp_NameDlg::name()
-{
- return myLineEdit->text();
-}
-
-/*!
- Accepts if name isn't empty
-*/
-void LightApp_NameDlg::accept()
-{
- if ( name().stripWhiteSpace().isEmpty() )
- return;
- QDialog::accept();
-}
-
-/*!
- Creates modal <Rename> dialog and returns name entered [ static ]
-*/
-QString LightApp_NameDlg::getName( QWidget* parent, const QString& oldName )
-{
- QString n;
- LightApp_NameDlg* dlg = new LightApp_NameDlg( parent );
- if ( !oldName.isNull() )
- dlg->setName( oldName );
- if ( dlg->exec() == QDialog::Accepted )
- n = dlg->name();
- delete dlg;
- return n;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// SALOME SalomeApp : implementation of desktop and GUI kernel
-//
-// File : LightApp_NameDlg.h
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
-
-#ifndef LIGHTAPP_NAMEDLG_H
-#define LIGHTAPP_NAMEDLG_H
-
-#include "LightApp.h"
-#include <qdialog.h>
-
-class QLineEdit;
-class QPushButton;
-
-/*!
- \class LightApp_NameDlg
- Common <Rename> dialog box class
-*/
-class LIGHTAPP_EXPORT LightApp_NameDlg : public QDialog
-{
- Q_OBJECT
-
-public:
- LightApp_NameDlg( QWidget* parent = 0 );
- ~LightApp_NameDlg();
-
- void setName( const QString& name );
- QString name();
-
- static QString getName( QWidget* parent = 0, const QString& oldName = QString::null );
-
-protected slots:
- void accept();
-
-private:
- QPushButton* myButtonOk;
- QPushButton* myButtonCancel;
- QLineEdit* myLineEdit;
-};
-
-#endif // LightApp_NAMEDLG_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_OBFilter.h"
-
-#include "LightApp_SelectionMgr.h"
-#include "LightApp_DataObject.h"
-#include "LightApp_DataOwner.h"
-
-/*!
- Constructor.
-*/
-LightApp_OBFilter::LightApp_OBFilter( LightApp_SelectionMgr* theSelMgr )
-{
- mySelMgr = theSelMgr;
-}
-
-/*!Destructor.*/
-LightApp_OBFilter::~LightApp_OBFilter()
-{
-}
-
-/*!Checks: data object is ok?*/
-bool LightApp_OBFilter::isOk( const SUIT_DataObject* theDataObj ) const
-{
- const LightApp_DataObject* obj = dynamic_cast<const LightApp_DataObject*>( theDataObj );
- if ( obj )
- return mySelMgr->isOk( new LightApp_DataOwner( obj->entry() ) );
-
- return true;
-}
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_OBFILTER_H
-#define LIGHTAPP_OBFILTER_H
-
-#include "LightApp.h"
-#include "OB_Filter.h"
-
-class LightApp_SelectionMgr;
-
-/*!
- \class LightApp_OBFilter
- Custom Object Browser filter, that checks correctness of object by all filters set in selection manager
-*/
-class LIGHTAPP_EXPORT LightApp_OBFilter: public OB_Filter
-{
-public:
- LightApp_OBFilter( LightApp_SelectionMgr* theSelMgr );
- ~LightApp_OBFilter();
-
- virtual bool isOk( const SUIT_DataObject* ) const;
-
-private:
- LightApp_SelectionMgr* mySelMgr;
-
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_OBSelector.h"
-
-#include "LightApp_DataOwner.h"
-#include "LightApp_DataObject.h"
-
-#include <OB_Browser.h>
-
-#include <SUIT_DataObjectIterator.h>
-
-#include <qdatetime.h>
-
-#include <time.h>
-
-/*!
- Constructor
-*/
-LightApp_OBSelector::LightApp_OBSelector( OB_Browser* ob, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, ob ),
- myBrowser( ob )
-{
- if ( myBrowser ) {
- connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
- }
-
- setModified();
-}
-
-/*!
- Destructor
-*/
-LightApp_OBSelector::~LightApp_OBSelector()
-{
-}
-
-/*!
- Gets browser.
-*/
-OB_Browser* LightApp_OBSelector::browser() const
-{
- return myBrowser;
-}
-
-/*!
- Gets selection.
-*/
-void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
-{
- if (mySelectedList.count() == 0 ) {
- if ( !myBrowser )
- return;
- DataObjectList objlist;
- myBrowser->getSelected( objlist );
- LightApp_OBSelector* that = (LightApp_OBSelector*)this;
- for ( DataObjectListIterator it( objlist ); it.current(); ++it )
- {
- LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
- if ( obj )
- {
-#ifndef DISABLE_SALOMEOBJECT
- Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
- ( obj->entry(), obj->componentDataType(), obj->name() );
- LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
-#else
- LightApp_DataOwner* owner = new LightApp_DataOwner( obj->entry() );
-#endif
- that->mySelectedList.append( SUIT_DataOwnerPtr( owner ) );
- }
- }
- }
- theList = mySelectedList;
-}
-
-/*!Sets selection.*/
-void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
-{
- if ( !myBrowser )
- return;
-
- if( myEntries.count() == 0 ||
- myModifiedTime < myBrowser->getModifiedTime() )
- fillEntries( myEntries );
-
- DataObjectList objList;
- for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it )
- {
- const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
- if ( owner && myEntries.contains( owner->entry() ) )
- objList.append( myEntries[owner->entry()] );
- }
-
- myBrowser->setSelected( objList );
- mySelectedList.clear();
-}
-
-/*!On selection changed.*/
-void LightApp_OBSelector::onSelectionChanged()
-{
- QTime t1 = QTime::currentTime();
- mySelectedList.clear();
- selectionChanged();
- QTime t2 = QTime::currentTime();
- qDebug( QString( "selection time = %1 msecs" ).arg( t1.msecsTo( t2 ) ) );
-}
-
-/*!Fill entries.*/
-void LightApp_OBSelector::fillEntries( QMap<QString, LightApp_DataObject*>& entires )
-{
- entires.clear();
-
- if ( !myBrowser )
- return;
-
- for ( SUIT_DataObjectIterator it( myBrowser->getRootObject(),
- SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it )
- {
- LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
- if ( obj )
- entires.insert( obj->entry(), obj );
- }
-
- setModified();
-}
-
-/*!Update modified time.*/
-void LightApp_OBSelector::setModified()
-{
- myModifiedTime = clock();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_OBSELECTOR_H
-#define LIGHTAPP_OBSELECTOR_H
-
-#include "LightApp.h"
-
-#include <SUIT_Selector.h>
-#include <SUIT_DataOwner.h>
-
-class OB_Browser;
-class LightApp_DataObject;
-
-/*!
- \class LightApp_OBSelector
- Custom selector to get/set selection from object browser
-*/
-class LIGHTAPP_EXPORT LightApp_OBSelector : public SUIT_Selector
-{
- Q_OBJECT
-
-public:
- LightApp_OBSelector( OB_Browser*, SUIT_SelectionMgr* );
- virtual ~LightApp_OBSelector();
-
- OB_Browser* browser() const;
-
- /*!Return "ObjectBrowser"*/
- virtual QString type() const { return "ObjectBrowser"; }
-
- void setModified();
- unsigned long getModifiedTime() { return myModifiedTime; }
-
-private slots:
- void onSelectionChanged();
-
-protected:
- virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
- virtual void setSelection( const SUIT_DataOwnerPtrList& );
-
-private:
- void fillEntries( QMap<QString, LightApp_DataObject*>& );
-
-private:
- OB_Browser* myBrowser;
- SUIT_DataOwnerPtrList mySelectedList;
-
- QMap<QString, LightApp_DataObject*> myEntries;
-
- unsigned long myModifiedTime;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "LightApp_DataOwner.h"
-#include "LightApp_OCCSelector.h"
-
-#ifndef DISABLE_SALOMEOBJECT
- #include <SALOME_InteractiveObject.hxx>
-#endif
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-
-/*!
- Constructor
-*/
-LightApp_OCCSelector::LightApp_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, viewer ),
- myViewer( viewer )
-{
- if ( myViewer )
- connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
-}
-
-/*!
- Destructor.
-*/
-LightApp_OCCSelector::~LightApp_OCCSelector()
-{
-}
-
-/*!
- Gets viewer.
-*/
-OCCViewer_Viewer* LightApp_OCCSelector::viewer() const
-{
- return myViewer;
-}
-
-/*!On selection changed.*/
-void LightApp_OCCSelector::onSelectionChanged()
-{
- selectionChanged();
-}
-
-/*!Gets selection list.*/
-void LightApp_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
-{
- if ( !myViewer )
- return;
-
- AIS_ListOfInteractive aSelList;
- myViewer->getSelectedObjects( aSelList );
- for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() )
- if ( !anIt.Value().IsNull() )
- {
-#ifndef DISABLE_SALOMEOBJECT
- Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anIt.Value()->GetOwner());
- if( !anObj.IsNull() )
- aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( anObj ) ) );
-#else
- aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) );
-#endif
- }
-}
-
-/*!Sets selection list.*/
-void LightApp_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
-{
- if ( !myViewer )
- return;
-
- QMap<QString, Handle(AIS_InteractiveObject)> aDisplayed;
- Handle(AIS_InteractiveContext) aContext = myViewer->getAISContext();
- if ( aContext.IsNull() )
- return;
-
- AIS_ListOfInteractive aDispList, aSelList;
- aContext->DisplayedObjects( aDispList );
-
- for ( AIS_ListIteratorOfListOfInteractive it( aDispList ); it.More(); it.Next() )
- {
- QString entryStr = entry( it.Value() );
- if ( !entryStr.isEmpty() )
- aDisplayed.insert( entryStr, it.Value() );
- }
-
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
- if ( owner && aDisplayed.contains( owner->entry() ) )
- aSelList.Append( aDisplayed[owner->entry()] );
- }
-
- myViewer->unHighlightAll( false );
- myViewer->setObjectsSelected( aSelList );
-}
-
-/*!Gets entry ob object.*/
-QString LightApp_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS ) const
-{
- if ( anAIS.IsNull() || !anAIS->HasOwner() )
- return QString::null;
-
- QString res;
-
-#ifndef DISABLE_SALOMEOBJECT
- Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anAIS->GetOwner());
- if ( !anObj.IsNull() )
- res = QString( anObj->getEntry() );
-#endif
-
- return res;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_OCCSELECTOR_H
-#define LIGHTAPP_OCCSELECTOR_H
-
-#include "LightApp.h"
-
-#include <SUIT_Selector.h>
-
-#include <OCCViewer_ViewModel.h>
-
-class Handle_AIS_InteractiveObject;
-
-/*!
- \class LightApp_OCCSelector
- Custom selector to get/set selection from OCC viewer
-*/
-class LIGHTAPP_EXPORT LightApp_OCCSelector : public SUIT_Selector
-{
- Q_OBJECT
-
-public:
- LightApp_OCCSelector( OCCViewer_Viewer*, SUIT_SelectionMgr* );
- virtual ~LightApp_OCCSelector();
-
- OCCViewer_Viewer* viewer() const;
-
- virtual QString type() const { return OCCViewer_Viewer::Type(); }
-
-private slots:
- virtual void onSelectionChanged();
-
-protected:
- virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
- virtual void setSelection( const SUIT_DataOwnerPtrList& );
-
- QString entry( const Handle_AIS_InteractiveObject& ) const;
-
-private:
- OCCViewer_Viewer* myViewer;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : LightApp_Operation.h
-// Author : Sergey LITONIN
-// Module : LightApp
-
-#include <LightApp_Operation.h>
-#include <LightApp_Module.h>
-#include <LightApp_Application.h>
-#include <LightApp_Operation.h>
-#include <LightApp_SelectionMgr.h>
-#include <LightApp_Dialog.h>
-
-#include <SUIT_Desktop.h>
-
-#include <qapplication.h>
-
-
-/*!
- * \brief Constructor
-*
-* Constructor sets myModule in NULL and myIsAutoResumed in TRUE
-*/
-LightApp_Operation::LightApp_Operation()
-: SUIT_Operation( 0 ),
- myModule( 0 ),
- myIsAutoResumed( true )
-{
-}
-
-/*!
- * \brief Destructor
-*
-* Destructor does nothing
-*/
-LightApp_Operation::~LightApp_Operation()
-{
-
-}
-
-/*!
- * \brief Gets module of operation
- * \return Pointer to the module
-*
-* Gets pointer to the module or NULL if module was not set. It is strongly recomended to
-* set valid pointer on the module before start of operation
-*/
-LightApp_Module* LightApp_Operation::module() const
-{
- return myModule;
-}
-
-
-/*!
- * \brief Sets module of operation
- * \param theModule - module to be set
-*
-* Sets pointer to the module. It is strongly recomended to set valid pointer on the
-* module before start of operation
-*/
-void LightApp_Operation::setModule( LightApp_Module* theModule )
-{
- myModule = theModule;
- setApplication( myModule ? myModule->application() : 0 );
- setStudy( application() ? application()->activeStudy() : 0 );
-}
-
-/*!
- * \brief Gets desktop of operation
- * \return Pointer to the desktop
-*
-* Gets pointer to the desktop or NULL if application was not set. It is strongly recomended
-* to set valid pointer on the application before start of operation
-*/
-SUIT_Desktop* LightApp_Operation::desktop() const
-{
- return application() != 0 ? application()->desktop() : 0;
-}
-
-/*!
- * \brief Enable dialog of operation
-*
-* Virtual method redefined from the base class. Enable dialog if it was desabled (in
-* suspend method) and activate selection
-*/
-void LightApp_Operation::resumeOperation()
-{
- SUIT_Operation::resumeOperation();
- setDialogActive( true );
-}
-
-/*!
- * \brief Performs actions needed for starting operation
-*
-* Virtual method redefined from the base class. Connect signal of selection manager to
-* onSelectionDone() slot
-*/
-void LightApp_Operation::startOperation()
-{
- if( selectionMgr() )
- connect( selectionMgr(), SIGNAL( selectionChanged() ), SLOT( onSelectionDone() ) );
-
- //If suspended operation was stopped during starting other operation,
- //the dialog is inactive now, We must activate it
- setDialogActive( true );
-}
-
-/*!
- * \brief Performs actions needed for suspending operation
-*
-* Virtual method redefined from the base class. This implementation calls corresponding
-* method of base class and cals setDialogActive( false )
-*/
-void LightApp_Operation::suspendOperation()
-{
- SUIT_Operation::suspendOperation();
- setDialogActive( false );
-}
-
-/*!
- * \brief Performs actions needed for aborting operation
-*
-* Virtual method redefined from the base class calls corresponding method of base class
-* and hides dialog box (if it is exists), disconnect slots from selection manager
-*/
-void LightApp_Operation::abortOperation()
-{
- SUIT_Operation::abortOperation();
- setDialogActive( true );
- if ( dlg() )
- dlg()->hide();
-
- if( selectionMgr() )
- disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
-}
-
-/*!
- * \brief Performs actions needed for committing operation
-*
-* Virtual method redefined from the base class calls corresponding method of base class
-* and hides dialog box (if it is exists), disconnect slots from selection manager
-*/
-void LightApp_Operation::commitOperation()
-{
- SUIT_Operation::commitOperation();
- setDialogActive( true );
- if ( dlg() )
- dlg()->hide();
-
- if( selectionMgr() )
- disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
-}
-
-/*!
- * \brief Gets dialog
- * \return Pointer to the dialog of this operation or NULL if it does not exist
-*
-* This method should be redefined in derived classes if they use dialogs. If this
-* function returns pointer to dialog then dialog will be correctly
-* -# deactivated in suspendOperation method
-* -# activated in resumeOperation method
-* -# hidden in abortOperation and commitOperation methods
-*/
-LightApp_Dialog* LightApp_Operation::dlg() const
-{
- return 0;
-}
-
-/*!
- * \brief Activates selection
-*
-* Virtual method should be redefined in derived classes if they use own selection modes
-* (different from default)
-*/
-void LightApp_Operation::activateSelection()
-{
-}
-
-/*!
- * \brief Virtual method called when selection is changed
-*
-* Virtual method should be redefined in derived classes if they works with selection
-* to provide reaction on the change of selection
-*/
-void LightApp_Operation::selectionDone()
-{
-}
-
-/*!
- * \brief Gets active operation
-*
-* This method provided for convinience calls SUIT_Study::activeOperation() one
-*/
-SUIT_Operation* LightApp_Operation::activeOperation() const
-{
- return study() != 0 ? study()->activeOperation() : 0;
-}
-
-/*!
- * \brief Gets selection manager
-*
-* This method provided for convinience calls LightApp_Application::selectionMgr() one
-*/
-LightApp_SelectionMgr* LightApp_Operation::selectionMgr() const
-{
- SUIT_Application* app = application();
- if ( app != 0 && app->inherits( "LightApp_Application" ) )
- return ( (LightApp_Application*)app )->selectionMgr();
- else
- return 0;
-}
-
-/*!
- * \brief Call selectionDone() method
-*
-* Call selectionDone() method if operator is an active one (see selectionDone() for more
-* description )
-*/
-void LightApp_Operation::onSelectionDone()
-{
- if ( isActive() )
- selectionDone();
-}
-
-/*!
- * \brief Update object browser or/and viewer etc.
- * \param flags - update flags
-*
-* This method provided for convinience calls LightApp_Module::update() one (see
-* LightApp_Module::update() for more description)
-*/
-void LightApp_Operation::update( const int flags )
-{
- if ( myModule != 0 )
- myModule->update( flags );
-}
-
-/*!
- * \brief Activate/Deactivate dialog of operation
- * \param active - State of the dialog to be set
-*
-* Activate/Deactivate dialog of operation. This method called from startOperation(),
-* suspendOperation() ones and so on
-*/
-void LightApp_Operation::setDialogActive( const bool active )
-{
- if( dlg() )
- {
- if( active )
- {
- activateSelection();
- dlg()->setActiveWindow();
- }
- }
-}
-
-/*!
- * \brief Gets autoresume property
- * \return Autoresume property.
-*
-* Autoresume property is used during automatic resuming operation. If operation is
-* suspended and cursor is moved above dialog of the operation then operation is resumed
-* automatically (if possible). It can be resumed only program call otherwise (see
-* LightApp_SwitchOp for more description). This property is TRUE by default and may be
-* changed with setAutoResumed() method call.
-*/
-bool LightApp_Operation::isAutoResumed() const
-{
- return myIsAutoResumed;
-}
-
-/*!
- * \brief Sets autoresume property
- * \param on - Value to be set
- * \return Autoresume property.
-*
-* Sets autoresume property (see isAutoResumed() for more description)
-*/
-void LightApp_Operation::setAutoResumed( const bool on )
-{
- myIsAutoResumed = on;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : LightApp_Operation.h
-// Author : Sergey LITONIN
-// Module : LIGHT
-
-
-#ifndef LightApp_Operation_H
-#define LightApp_Operation_H
-
-#include "LightApp.h"
-#include <SUIT_Operation.h>
-
-class LightApp_Module;
-class LightApp_Application;
-class LightApp_Operation;
-class LightApp_SelectionMgr;
-class LightApp_Dialog;
-class SUIT_Desktop;
-
-/*!
- \class LightApp_Operation
- \brief Base class for all operations
- Base class for all operations (see SUIT_Operation for more description)
-*/
-class LIGHTAPP_EXPORT LightApp_Operation : public SUIT_Operation
-{
- Q_OBJECT
-
-public:
- LightApp_Operation();
- virtual ~LightApp_Operation();
-
- virtual void setModule( LightApp_Module* );
- LightApp_Module* module() const;
-
- bool isAutoResumed() const;
-
- virtual LightApp_Dialog* dlg() const;
-
-protected:
-
- // Methods redefined from base class
-
- virtual void startOperation();
- virtual void suspendOperation();
- virtual void resumeOperation();
- virtual void abortOperation();
- virtual void commitOperation();
-
- // Additional virtual methods may be redefined by derived classes
-
- virtual void setDialogActive( const bool );
- virtual void activateSelection();
- virtual void selectionDone();
-
-
- // Axiluary methods
-
- SUIT_Desktop* desktop() const;
- SUIT_Operation* activeOperation() const;
- LightApp_SelectionMgr* selectionMgr() const;
- void update( const int );
- void setAutoResumed( const bool );
-
-private slots:
-
- virtual void onSelectionDone();
-
-private:
-
- LightApp_Module* myModule;
- bool myIsAutoResumed;
-};
-
-#endif
-
-
-
-
-
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Preferences.cxx
-// Author: Sergey TELKOV
-
-#include "LightApp_Preferences.h"
-
-#include <QtxListResourceEdit.h>
-
-#include <qlayout.h>
-
-/*!
- Constructor.Initialize by resource manager and parent QWidget.
-*/
-LightApp_Preferences::LightApp_Preferences( QtxResourceMgr* resMgr, QWidget* parent )
-: QtxListResourceEdit( resMgr, parent )
-{
-}
-
-/*!
- Destructor.
-*/
-LightApp_Preferences::~LightApp_Preferences()
-{
-}
-
-/*!
- Adds preference.
-*/
-int LightApp_Preferences::addPreference( const QString& label, const int pId, const int type,
- const QString& section, const QString& param )
-{
- return addItem( label, pId, type, section, param );
-}
-
-/*!
- Adds preference.
-*/
-int LightApp_Preferences::addPreference( const QString& mod, const QString& label, const int pId,
- const int type, const QString& section, const QString& param )
-{
- int id = addItem( label, pId, type, section, param );
- if ( id != -1 && !mod.isEmpty() )
- myPrefMod.insert( id, mod );
- return id;
-}
-
-/*!
- Checks: is preferences has module with name \a mod.
-*/
-bool LightApp_Preferences::hasModule( const QString& mod ) const
-{
- bool res = false;
- for ( PrefModuleMap::ConstIterator it = myPrefMod.begin(); it != myPrefMod.end() && !res; ++it )
- res = it.data() == mod;
- return res;
-}
-
-/*!Do nothing.*/
-void LightApp_Preferences::onHelp()
-{
-}
-
-/*!Store preferences on apply.*/
-void LightApp_Preferences::onApply()
-{
- store();
-}
-
-/*!Emit preference changed.*/
-void LightApp_Preferences::changedResources( const QMap<Item*, QString>& map )
-{
- for ( QMap<Item*, QString>::ConstIterator it = map.begin(); it != map.end(); ++it )
- {
- QString sec, param;
- it.key()->resource( sec, param );
- QString mod = module( it.key()->id() );
- emit preferenceChanged( mod, sec, param );
- }
-}
-
-/*!Gets module name by \a id, if exist.*/
-QString LightApp_Preferences::module( const int id ) const
-{
- QString mod;
- if ( myPrefMod.contains( id ) )
- mod = myPrefMod[id];
- return mod;
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_Preferences.h
-// Author: Sergey TELKOV
-
-#ifndef LIGHTAPP_PREFERENCES_H
-#define LIGHTAPP_PREFERENCES_H
-
-#include <LightApp.h>
-
-#include <QtxDialog.h>
-#include <QtxListResourceEdit.h>
-
-#include <qmap.h>
-
-class QtxResourceMgr;
-
-/*!
- \class LightApp_Preferences
- Custom preference container. Assign each preference category with module.
- Emits signal on preference changing
-*/
-class LIGHTAPP_EXPORT LightApp_Preferences : public QtxListResourceEdit
-{
- Q_OBJECT
-
-public:
- LightApp_Preferences( QtxResourceMgr*, QWidget* = 0 );
- virtual ~LightApp_Preferences();
-
- int addPreference( const QString& label, const int pId = -1, const int = -1,
- const QString& section = QString::null, const QString& param = QString::null );
- int addPreference( const QString& modName, const QString& label, const int pId = -1, const int = -1,
- const QString& section = QString::null, const QString& param = QString::null );
-
- bool hasModule( const QString& ) const;
-
-signals:
- void preferenceChanged( QString&, QString&, QString& );
-
-private slots:
- void onHelp();
- void onApply();
- virtual void changedResources( const QMap<Item*, QString>& );
-
-private:
- QString module( const int ) const;
-
-private:
- typedef QMap<int, QString> PrefModuleMap;
-
-private:
- PrefModuleMap myPrefMod;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_PreferencesDlg.cxx
-// Author: Sergey TELKOV
-
-#include "LightApp_PreferencesDlg.h"
-#include "LightApp_Preferences.h"
-
-#include "QtxResourceMgr.h"
-
-#include <qbutton.h>
-#include <qlayout.h>
-#include <qmessagebox.h>
-#include <qvbox.h>
-#include <qfiledialog.h>
-
-/*!
- Constructor.
-*/
-LightApp_PreferencesDlg::LightApp_PreferencesDlg( LightApp_Preferences* prefs, QWidget* parent )
-: QtxDialog( parent, 0, true, true, OK | Close | Apply ),
-myPrefs( prefs ), mySaved ( false )
-{
- setCaption( tr( "CAPTION" ) );
-
- QVBoxLayout* main = new QVBoxLayout( mainFrame(), 5 );
-
- QVBox* base = new QVBox( mainFrame() );
- main->addWidget( base );
-
- myPrefs->reparent( base, QPoint( 0, 0 ), true );
-
- setFocusProxy( myPrefs );
-
- setButtonPosition( Right, Close );
-
- setDialogFlags( AlignOnce );
-
- connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
- connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
-
- QButton* defBtn = userButton( insertButton( tr( "DEFAULT_BTN_TEXT" ) ) );
- if ( defBtn )
- connect( defBtn, SIGNAL( clicked() ), this, SLOT( onDefault() ) );
- QButton* impBtn = userButton( insertButton( tr( "IMPORT_BTN_TEXT" ) ) );
- if( impBtn )
- connect( impBtn, SIGNAL( clicked() ), this, SLOT( onImportPref() ) );
-}
-
-/*!
- Destructor.
-*/
-LightApp_PreferencesDlg::~LightApp_PreferencesDlg()
-{
- if ( !myPrefs )
- return;
-
- myPrefs->reparent( 0, QPoint( 0, 0 ), false );
- myPrefs = 0;
-}
-
-/*!Show dialog.*/
-void LightApp_PreferencesDlg::show()
-{
- myPrefs->retrieve();
- myPrefs->toBackup();
-
- QtxDialog::show();
-}
-
-/*!Store preferences on accept.*/
-void LightApp_PreferencesDlg::accept()
-{
- QtxDialog::accept();
-
- myPrefs->store();
- mySaved = true;
-}
-
-/*!Reject. Restore preferences from backup.*/
-void LightApp_PreferencesDlg::reject()
-{
- QtxDialog::reject();
-
- myPrefs->fromBackup();
-}
-
-/*!Do nothing.*/
-void LightApp_PreferencesDlg::onHelp()
-{
-}
-
-/*!Store preferences on apply.*/
-void LightApp_PreferencesDlg::onApply()
-{
- myPrefs->store();
-
- // Fix for Bug PAL11197: Restoring the corrected values from resource manager.
- // (Correcting in VisuGUI.cxx and SMESHGUI.cxx in methods
- // ::preferencesChanged( const QString& sect, const QString& name ))
- myPrefs->retrieve();
- //
-
- myPrefs->toBackup();
- mySaved = true;
-}
-
-/*! Restore default preferences*/
-void LightApp_PreferencesDlg::onDefault()
-{
- if( QMessageBox::Ok == QMessageBox::information( this, tr( "WARNING" ), tr( "DEFAULT_QUESTION" ), QMessageBox::Ok, QMessageBox::Cancel ) )
- {
- if ( myPrefs && myPrefs->resourceMgr() )
- {
- bool prev = myPrefs->resourceMgr()->ignoreUserValues();
- myPrefs->resourceMgr()->setIgnoreUserValues( true );
- myPrefs->retrieve();
- myPrefs->resourceMgr()->setIgnoreUserValues( prev );
- }
- }
-}
-
-/*! Import preferences from some file */
-void LightApp_PreferencesDlg::onImportPref()
-{
- QtxResourceMgr* mgr = myPrefs->resourceMgr();
- if( !mgr )
- return;
-
- QFileDialog dlg( ".", "*", this, "", tr( "IMPORT_PREFERENCES" ) );
- dlg.setShowHiddenFiles( true );
- dlg.exec();
- QString fname = dlg.selectedFile();
- if( fname.isEmpty() )
- return;
-
- if( mgr->import( fname ) )
- {
- myPrefs->retrieve();
- myPrefs->toBackup();
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_PreferencesDlg.h
-// Author: Sergey TELKOV
-
-#ifndef LIGHTAPP_PREFERENCESDLG_H
-#define LIGHTAPP_PREFERENCESDLG_H
-
-#include <LightApp.h>
-
-#include <QtxDialog.h>
-
-class LightApp_Preferences;
-
-/*!
- \class LightApp_PreferencesDlg
- Dialog for preferences edition
-*/
-class LIGHTAPP_EXPORT LightApp_PreferencesDlg : public QtxDialog
-{
- Q_OBJECT
-
-public:
- LightApp_PreferencesDlg( LightApp_Preferences*, QWidget* = 0 );
- virtual ~LightApp_PreferencesDlg();
-
- virtual void show();
- virtual void accept();
- virtual void reject();
-
- bool isSaved() { return mySaved; }
- void setSaved( bool saved ) { mySaved = saved; }
-
-private slots:
- void onHelp();
- void onApply();
- void onDefault();
- void onImportPref();
-
-private:
- LightApp_Preferences* myPrefs;
- bool mySaved;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_ROOTOBJECT_H
-#define LIGHTAPP_ROOTOBJECT_H
-
-#include "LightApp.h"
-#include "SUIT_DataObject.h"
-
-class LightApp_Study;
-
-/*!
- LightApp_RootObject - class to be instanciated by only one object -
- root object of LightApp data object tree. This object is not shown
- in object browser (invisible), so it has no re-definition of name(), icon(),
- etc. methods. The goal of this class is to provide a unified access
- to LightApp_Study object from LightApp_DataObject instances.
-*/
-class LIGHTAPP_EXPORT LightApp_RootObject : public SUIT_DataObject
-{
-public:
- LightApp_RootObject( LightApp_Study* study )
- : myStudy( study )
- {}
-
- virtual ~LightApp_RootObject() {}
-
- void setStudy( LightApp_Study* study ) { myStudy = study; }
- LightApp_Study* study() const { return myStudy; }
-
-private:
- LightApp_Study* myStudy;
-
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "LightApp_Selection.h"
-#include "LightApp_SelectionMgr.h"
-#include "LightApp_DataOwner.h"
-#include "LightApp_Study.h"
-#include "LightApp_Application.h"
-#include "LightApp_Displayer.h"
-
-#include "SUIT_Session.h"
-#include "SUIT_ViewWindow.h"
-
-/*!
- Constructor
-*/
-LightApp_Selection::LightApp_Selection()
-: myStudy( 0 )
-{
-}
-
-/*!
- Destructor.
-*/
-LightApp_Selection::~LightApp_Selection()
-{
-}
-
-/*!
- Initialization.
-*/
-void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr)
-{
- myPopupClient = client;
- myStudy = 0;
-
- if( mgr )
- {
- if( mgr->application() )
- myStudy = dynamic_cast<LightApp_Study*>( mgr->application()->activeStudy() );
- if( !myStudy )
- return;
-
- //1) to take owners from current popup client
- SUIT_DataOwnerPtrList sel( true ), cur_sel( true );
- mgr->selected( sel, client );
-
- //2) to take such owners from other popup clients that it's entry is different with every entry from current list
- QPtrList<SUIT_Selector> aSelectors;
- mgr->selectors( aSelectors );
- for( SUIT_Selector* selector = aSelectors.first(); selector; selector = aSelectors.next() )
- {
- qDebug( selector->type() );
- if( selector->type()!=client )
- {
- mgr->selected( cur_sel, selector->type() );
- SUIT_DataOwnerPtrList::const_iterator aLIt = cur_sel.begin(), aLLast = cur_sel.end();
- for( ; aLIt!=aLLast; aLIt++ )
- sel.append( *aLIt ); //check entry and don't append if such entry is in list already
- }
- }
-
- //3) to analyse owner and fill internal data structures
- SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
- QMap<QString,int> entries;
- QString entry;
- int num=0;
- for( ; anIt!=aLast; anIt++ )
- {
- LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>( (*anIt ).get() );
- if( sowner )
- {
- entry = myStudy->referencedToEntry( sowner->entry() );
- if( entries.contains( entry ) )
- continue;
-
- entries.insert( entry, 0 );
- myEntries.insert( num, entry );
- myIsReferences.insert( num, sowner->entry() != entry );
- processOwner( sowner );
- num++;
- }
- }
- }
-}
-
-/*!
- Gets count of entries.
-*/
-int LightApp_Selection::count() const
-{
- return myEntries.count();
-}
-
-/*!
- Gets QtxValue();
-*/
-QtxValue LightApp_Selection::param( const int ind, const QString& p ) const
-{
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( myStudy ? myStudy->application() : 0 );
- if( !( ind>=0 && ind<count() ) || !app )
- return QtxValue();
-
- if( p=="isVisible" )
- {
- QString mod_name = app->moduleTitle( param( ind, "component" ).toString() );
- LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false );
- // false in last parameter means that now we doesn't load module, if it isn't loaded
-
- bool vis = false;
- if( d )
- vis = d->IsDisplayed( myEntries[ ind ] );
- else
- {
- LightApp_Displayer local_d;
- vis = local_d.IsDisplayed( myEntries[ ind ] );
- }
- return QtxValue( vis, 0 );
- }
-
- else if( p=="component" )
- {
- return myStudy->componentDataType( myEntries[ ind ] );
- }
-
- else if( p=="isComponent" )
- {
- return QtxValue( myStudy->isComponent( myEntries[ ind ] ), 0 );
- }
-
- else if( p=="isReference" )
- return QtxValue( isReference( ind ), false );
-
- else if( p=="canBeDisplayed" )
- {
- QString mod_name = app->moduleTitle( param( ind, "component" ).toString() );
- LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false );
- // false in last parameter means that now we doesn't load module, if it isn't loaded
-
- if ( d )
- return d->canBeDisplayed( myEntries[ ind ] );
- else if ( myEntries[ ind ].startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) ) // object is a Save Point object
- return false;
-
- return true;
- //now if displayer is null, it means, that according module isn't loaded, so that we allow to all display/erase
- //operations under object
- }
-
- return QtxValue();
-}
-
-/*!
- Gets global parameters. client, isActiveView, activeView etc.
-*/
-QtxValue LightApp_Selection::globalParam( const QString& p ) const
-{
- if ( p == "client" ) return QtxValue( myPopupClient );
- else if ( p == "activeModule" )
- {
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( myStudy->application() );
- QString mod_name = app ? QString( app->activeModule()->name() ) : QString::null;
- //cout << "activeModule : " << mod_name.latin1() << endl;
- if( !mod_name.isEmpty() )
- return mod_name;
- else
- return QtxValue();
- }
- else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
- else if ( p == "activeView" ) return QtxValue( activeViewType() );
-#ifndef WNT
- else return QtxPopupMgr::Selection::globalParam( p );
-#else
- else return Selection::globalParam( p );
-#endif
-}
-
-/*!
- Do nothing. To be redefined by successors
-*/
-void LightApp_Selection::processOwner( const LightApp_DataOwner* )
-{
-}
-
-/*!
- Gets entry with index \a index.
-*/
-QString LightApp_Selection::entry( const int index ) const
-{
- if ( index >= 0 && index < count() )
- return myEntries[ index ];
- return QString();
-}
-
-/*!
- Returns true if i-th selected object was reference to object with entry( i )
-*/
-bool LightApp_Selection::isReference( const int index ) const
-{
- if( index >= 0 && index < count() )
- return myIsReferences[ index ];
- else
- return false;
-}
-
-/*!
- Gets type of active view manager.
-*/
-QString LightApp_Selection::activeViewType() const
-{
- SUIT_ViewWindow* win = activeVW();
- if ( win ) {
- SUIT_ViewManager* vm = win->getViewManager();
- if ( vm )
- return vm->getType();
- }
- return QString::null;
-}
-
-/*!
- Gets active view window.
-*/
-SUIT_ViewWindow* LightApp_Selection::activeVW() const
-{
- SUIT_Session* session = SUIT_Session::session();
- if ( session ) {
- SUIT_Application* app = session->activeApplication();
- if ( app ) {
- SUIT_Desktop* desk = app->desktop();
- if ( desk )
- return desk->activeWindow();
- }
- }
- return 0;
-}
+++ /dev/null
-// LightApp_Selection
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//
-//
-// File : LightApp_Selection.h
-// Author : Alexander SOLOVYOV
-// Module : GUI
-// $Header$
-
-#ifndef LIGHTAPP_SELECTION_HeaderFile
-#define LIGHTAPP_SELECTION_HeaderFile
-
-#include "LightApp.h"
-#include <QtxPopupMgr.h>
-
-class LightApp_SelectionMgr;
-class LightApp_DataOwner;
-class LightApp_Study;
-class SUIT_ViewWindow;
-
-/*!
- \class LightApp_Selection
- Custom selection class, allowing to build popup with rules on the base
- of owners selected in all selectors (popup client has more priority).
- It is able to return values of standard object properties
- (isVisible,isComponent,canBeDisplayed,isReference, etc)
-*/
-class LIGHTAPP_EXPORT LightApp_Selection : public QtxPopupMgr::Selection
-{
-public:
- LightApp_Selection();
- virtual ~LightApp_Selection();
-
- virtual void init( const QString&, LightApp_SelectionMgr* );
- virtual void processOwner( const LightApp_DataOwner* );
-
- virtual int count() const;
- virtual QtxValue param( const int, const QString& ) const;
- virtual QtxValue globalParam( const QString& ) const;
- void setModuleName( const QString );
-
-protected:
- QString entry( const int ) const;
- bool isReference( const int ) const;
- /*!Gets study.*/
- LightApp_Study* study() const { return myStudy; }
- QString activeViewType() const;
- SUIT_ViewWindow* activeVW() const;
-
-private:
- QString myPopupClient;
- QMap<int,QString> myEntries; // entries of selected objects
- QMap<int,bool> myIsReferences; // whether i-th selected object was a reference
- LightApp_Study* myStudy;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_SelectionMgr.h"
-
-#include "LightApp_Study.h"
-#include "LightApp_DataOwner.h"
-#include "LightApp_DataSubOwner.h"
-#include "LightApp_Application.h"
-
-#include <SUIT_Session.h>
-
-#ifndef DISABLE_SALOMEOBJECT
- #include <SALOME_ListIO.hxx>
- #include <SALOME_ListIteratorOfListIO.hxx>
-
- // Open CASCADE Include
- #include <TColStd_MapOfInteger.hxx>
- #include <TColStd_MapIteratorOfMapOfInteger.hxx>
- #include <TColStd_IndexedMapOfInteger.hxx>
-#endif
-
-/*!
- Constructor.
-*/
-LightApp_SelectionMgr::LightApp_SelectionMgr( LightApp_Application* app, const bool fb )
-: SUIT_SelectionMgr( fb ),
-myApp( app )
-{
-}
-
-/*!
- Destructor.
-*/
-LightApp_SelectionMgr::~LightApp_SelectionMgr()
-{
-}
-
-/*!
- Gets application.
-*/
-LightApp_Application* LightApp_SelectionMgr::application() const
-{
- return myApp;
-}
-
-#ifndef DISABLE_SALOMEOBJECT
-/*!
- Get all selected objects from selection manager
-*/
-void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType,
- const bool convertReferences ) const
-{
- theList.Clear();
-
- SUIT_DataOwnerPtrList aList;
- selected( aList, theType );
-
- QMap<QString,int> entryMap;
-
- QString entry, checkEntry;
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
- if( !owner )
- continue;
-
- LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
- if ( !study )
- return;
-
- entry = owner->entry();
- // Entry to check object uniqueness.
- // It is selected owner entry in the case, when we do not convert references,
- // and entry of a real object, when we convert references.
- checkEntry = entry;
- if ( convertReferences ) {
- QString refEntry = study->referencedToEntry( entry );
- checkEntry = refEntry;
- if ( !entryMap.contains( checkEntry ) ) {
- if ( refEntry != entry ) {
- QString component = study->componentDataType( refEntry );
- theList.Append( new SALOME_InteractiveObject( refEntry, component, ""/*refobj->Name().c_str()*/ ) );
- }
- else if( !owner->IO().IsNull() )
- theList.Append( owner->IO() );
- }
- }
- else {
- if( !entryMap.contains( entry ) && !owner->IO().IsNull() )
- theList.Append( owner->IO() );
- }
-
- entryMap.insert(checkEntry, 1);
- }
-}
-
-/*!
- Append selected objects.
-*/
-void LightApp_SelectionMgr::setSelectedObjects( const SALOME_ListIO& lst, const bool append )
-{
- SUIT_DataOwnerPtrList owners;
- for ( SALOME_ListIteratorOfListIO it( lst ); it.More(); it.Next() )
- {
- if ( it.Value()->hasEntry() )
- owners.append( new LightApp_DataOwner( it.Value() ) );
- }
-
- setSelected( owners, append );
-}
-
-#else
-/*!
- Get all selected objects from selection manager
-*/
-void LightApp_SelectionMgr::selectedObjects( QStringList& theList, const QString& theType,
- const bool convertReferences ) const
-{
- theList.clear();
-
- SUIT_DataOwnerPtrList aList;
- selected( aList, theType );
-
- QString entry;
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
- if( !owner )
- continue;
-
- LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
- if ( !study )
- return;
-
- entry = owner->entry();
- if( !theList.contains( entry ) )
- theList.append( entry );
- }
-}
-
-#endif
-
-/*!
- Emit current selection changed.
-*/
-void LightApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel )
-{
- SUIT_SelectionMgr::selectionChanged( theSel );
-
- emit currentSelectionChanged();
-}
-
-#ifndef DISABLE_SALOMEOBJECT
-
-/*!
- get map of indexes for the given SALOME_InteractiveObject
-*/
-void LightApp_SelectionMgr::GetIndexes( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger& theIndex)
-{
- theIndex.Clear();
-
- SUIT_DataOwnerPtrList aList;
- selected( aList );
-
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr).operator->() );
- if ( subOwner )
- if ( subOwner->entry() == QString(IObject->getEntry()) )
- theIndex.Add( subOwner->index() );
- }
-
-}
-
-/*!
- get map of indexes for the given entry of SALOME_InteractiveObject
-*/
-void LightApp_SelectionMgr::GetIndexes( const QString& theEntry, TColStd_IndexedMapOfInteger& theIndex )
-{
- theIndex.Clear();
-
- SUIT_DataOwnerPtrList aList;
- selected( aList );
-
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr).operator->() );
- if ( subOwner )
- if ( subOwner->entry() == theEntry )
- theIndex.Add( subOwner->index() );
- }
-
-}
-
-/*!
- Add or remove interactive objects from selection manager.
-*/
-bool LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
- const TColStd_MapOfInteger& theIndexes,
- bool modeShift)
-{
- SUIT_DataOwnerPtrList remainsOwners;
-
- SUIT_DataOwnerPtrList aList;
- selected( aList );
-
- if ( !modeShift ) {
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
- if ( owner )
- {
- if ( owner->entry() != QString(IObject->getEntry()) )
- {
- const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( owner );
- if ( subOwner )
- remainsOwners.append( new LightApp_DataSubOwner( subOwner->entry(), subOwner->index() ) );
- else
- remainsOwners.append( new LightApp_DataOwner( owner->entry() ) );
- }
- }
- }
- }
- else
- remainsOwners = aList;
-
- TColStd_MapIteratorOfMapOfInteger It;
- It.Initialize(theIndexes);
- for(;It.More();It.Next())
- remainsOwners.append( new LightApp_DataSubOwner( QString(IObject->getEntry()), It.Key() ) );
-
- bool append = false;
- setSelected( remainsOwners, append );
-
- emit currentSelectionChanged();
-
- TColStd_IndexedMapOfInteger anIndexes;
- GetIndexes( IObject, anIndexes );
- return !anIndexes.IsEmpty();
-
-}
-
-/*!
- select 'subobjects' with given indexes
-*/
-void LightApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger theIndex, bool append )
-{
- SUIT_DataOwnerPtrList aList;
-
- if ( theIndex.IsEmpty() )
- aList.append( new LightApp_DataOwner( QString(IObject->getEntry()) ) );
- else
- {
- int i;
- for ( i = 1; i <= theIndex.Extent(); i++ )
- aList.append( new LightApp_DataSubOwner( QString(IObject->getEntry()), theIndex( i ) ) );
- }
-
- setSelected( aList, append );
-
-}
-
-/*!
- select 'subobjects' with given indexes
-*/
-void LightApp_SelectionMgr::selectObjects( MapIOOfMapOfInteger theMapIO, bool append )
-{
- SUIT_DataOwnerPtrList aList;
-
- MapIOOfMapOfInteger::Iterator it;
- for ( it = theMapIO.begin(); it != theMapIO.end(); ++it )
- {
- if ( it.data().IsEmpty() )
- aList.append( new LightApp_DataOwner( QString(it.key()->getEntry()) ) );
- else
- {
- int i;
- for ( i = 1; i <= it.data().Extent(); i++ )
- aList.append( new LightApp_DataSubOwner( QString(it.key()->getEntry()), it.data()( i ) ) );
- }
- }
-
- setSelected( aList, append );
-
-}
-
-/*!
- get map of selected subowners : object's entry <-> map of indexes
-*/
-void LightApp_SelectionMgr::selectedSubOwners( MapEntryOfMapOfInteger& theMap )
-{
- theMap.clear();
-
- TColStd_IndexedMapOfInteger anIndexes;
-
- SUIT_DataOwnerPtrList aList;
- selected( aList );
-
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr).operator->() );
- if ( subOwner )
- {
- if ( !theMap.contains( subOwner->entry() ) )
- {
- anIndexes.Clear();
- GetIndexes( subOwner->entry(), anIndexes );
- theMap.insert( subOwner->entry(), anIndexes );
- }
- }
- }
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_SELECTIONMGR_H
-#define LIGHTAPP_SELECTIONMGR_H
-
-#include "LightApp.h"
-
-#include <SUIT_SelectionMgr.h>
-
-#ifndef DISABLE_SALOMEOBJECT
- #include <SALOME_InteractiveObject.hxx>
- #include <qmap.h>
-
- class SALOME_ListIO;
- class TColStd_IndexedMapOfInteger;
- class TColStd_MapOfInteger;
-#else
-#include <qstringlist.h>
-#endif
-
-class LightApp_Application;
-
-/*!
- Custom selection manager, allowing to work with object selection
- (additionally to data owners) and to access to sub-selection of objects
-*/
-class LIGHTAPP_EXPORT LightApp_SelectionMgr : public SUIT_SelectionMgr
-{
- Q_OBJECT
-
-public:
- LightApp_SelectionMgr( LightApp_Application*, const bool = true );
- virtual ~LightApp_SelectionMgr();
-
- LightApp_Application* application() const;
-
-#ifndef DISABLE_SALOMEOBJECT
- typedef QMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
- typedef QMap< QString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
-
- void selectedObjects( SALOME_ListIO&, const QString& = QString::null, const bool = true ) const;
- void setSelectedObjects( const SALOME_ListIO&, const bool = false );
-
- void GetIndexes( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger& theIndex );
- void GetIndexes( const QString& theEntry,
- TColStd_IndexedMapOfInteger& theIndex );
-
- bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
- const TColStd_MapOfInteger& theIndices,
- bool modeShift );
-
- void selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger theIndex, bool append );
- void selectObjects( MapIOOfMapOfInteger theMapIO, bool append );
-
- void selectedSubOwners( MapEntryOfMapOfInteger& theMap );
-#else
- void selectedObjects( QStringList&, const QString& = QString::null, const bool = true ) const;
-#endif
-
-signals:
- void currentSelectionChanged();
-
-private:
- virtual void selectionChanged( SUIT_Selector* );
-
-private:
- LightApp_Application* myApp;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "LightApp_ShowHideOp.h"
-#include "LightApp_Application.h"
-#include "LightApp_DataOwner.h"
-#include "LightApp_Module.h"
-#include "LightApp_Study.h"
-#include "LightApp_Displayer.h"
-#include "CAM_Study.h"
-
-#include "LightApp_SelectionMgr.h"
-#include "LightApp_Selection.h"
-
-#ifndef DISABLE_SALOMEOBJECT
- #include <SALOME_ListIO.hxx>
- #include <SALOME_ListIteratorOfListIO.hxx>
-#endif
-
-/*!
- Constructor
-*/
-LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type )
-: LightApp_Operation(),
- myActionType( type )
-{
-}
-
-/*!
- Destructor
-*/
-LightApp_ShowHideOp::~LightApp_ShowHideOp()
-{
-}
-
-/*!
- Makes show/hide operation
-*/
-void LightApp_ShowHideOp::startOperation()
-{
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
- LightApp_Study* study = app ? dynamic_cast<LightApp_Study*>( app->activeStudy() ) : 0;
- if( !app || !study )
- {
- abort();
- return;
- }
-
- LightApp_SelectionMgr* mgr = app->selectionMgr();
- LightApp_Selection sel; sel.init( "", mgr );
- if( sel.count()==0 && myActionType!=ERASE_ALL )
- {
- abort();
- return;
- }
-
- QString mod_name;
- if( sel.count()>0 )
- {
- QString aStr = sel.param( 0, "component" ).toString();
- mod_name = app->moduleTitle( aStr );
- }
- else if( app->activeModule() )
- mod_name = app->moduleTitle( app->activeModule()->name() );
-
- LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, true );
- if( !d )
- {
- abort();
- return;
- }
-
- if( myActionType==DISPLAY_ONLY || myActionType==ERASE_ALL )
- {
- //ERASE ALL
- QStringList comps;
- study->components( comps );
- QStringList::const_iterator anIt = comps.begin(), aLast = comps.end();
- for( ; anIt!=aLast; anIt++ )
- {
- LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), true );
- if( disp )
- disp->EraseAll( false, false, 0 );
- }
- if( myActionType==ERASE_ALL )
- {
- d->UpdateViewer();
- commit();
- return;
- }
- }
-
- QStringList entries;
-
-#ifndef DISABLE_SALOMEOBJECT
- SALOME_ListIO selObjs;
- mgr->selectedObjects( selObjs );
- SALOME_ListIteratorOfListIO anIt( selObjs );
- for( ; anIt.More(); anIt.Next() )
- if( !anIt.Value().IsNull() )
-#else
- QStringList selObjs;
- mgr->selectedObjects( selObjs );
- QStringList::const_iterator anIt = selObjs.begin(), aLast = selObjs.end();
- for( ; ; anIt!=aLast )
-#endif
- {
- QString entry =
-#ifndef DISABLE_SALOMEOBJECT
- anIt.Value()->getEntry();
-#else
- *anIt;
-#endif
-
- if( study->isComponent( entry ) )
- study->children( entry, entries );
- else
- entries.append( entry );
- }
-
- for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ )
- {
- QString e = study->referencedToEntry( *it );
- if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
- d->Display( e, false, 0 );
- else if( myActionType==ERASE )
- d->Erase( e, false, false, 0 );
- }
- d->UpdateViewer();
- commit();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef LIGHTAPP_SHOW_HIDE_OPERATION_HEADER
-#define LIGHTAPP_SHOW_HIDE_OPERATION_HEADER
-
-#include "LightApp_Operation.h"
-
-class LightApp_Displayer;
-
-/*!
- \class LightApp_ShowHideOp
- Standard operation allowing to show/hide selected objects
- corresponding to any module with help of module displayer
-*/
-class LIGHTAPP_EXPORT LightApp_ShowHideOp : public LightApp_Operation
-{
- Q_OBJECT
-
-public:
- typedef enum { DISPLAY, ERASE, DISPLAY_ONLY, ERASE_ALL } ActionType;
-
-public:
- LightApp_ShowHideOp( ActionType );
- ~LightApp_ShowHideOp();
-
-protected:
- virtual void startOperation();
-
-private:
- ActionType myActionType;
-};
-
-#endif
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_Study.h"
-
-#include "CAM_DataModel.h"
-#include "LightApp_Application.h"
-#include "LightApp_DataModel.h"
-#include "LightApp_DataObject.h"
-#include "LightApp_RootObject.h"
-#include "LightApp_HDFDriver.h"
-
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_DataObjectIterator.h"
-
-#include <OB_Browser.h>
-
-#include <TCollection_AsciiString.hxx>
-
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Directory.hxx>
-#include <OSD_Process.hxx>
-#include <OSD_Directory.hxx>
-#include <OSD_Protection.hxx>
-#include <OSD_SingleProtection.hxx>
-#include <OSD_FileIterator.hxx>
-
-#include <set>
-#include <qstring.h>
-
-/*!
- Constructor.
-*/
-LightApp_Study::LightApp_Study( SUIT_Application* app )
-: CAM_Study( app )
-{
- // HDF persistence
- myDriver = new LightApp_HDFDriver();
- //myDriver = new LightApp_Driver();
-}
-
-/*!
- Destructor.
-*/
-LightApp_Study::~LightApp_Study()
-{
-}
-
-/*!
- Create document.
-*/
-void LightApp_Study::createDocument()
-{
- setStudyName( QString( "Study%1" ).arg( LightApp_Application::studyId() ) );
-
- // create myRoot
- setRoot( new LightApp_RootObject( this ) );
-
- CAM_Study::createDocument();
-
- emit created( this );
-}
-
-/*!
- Opens document
-*/
-bool LightApp_Study::openDocument( const QString& theFileName )
-{
- myDriver->ClearDriverContents();
- // create files for models from theFileName
- if( !openStudyData(theFileName))
- return false;
-
- setRoot( new LightApp_RootObject( this ) ); // create myRoot
-
- // update loaded data models: call open() and update() on them.
- ModelList dm_s;
- dataModels( dm_s );
- for ( ModelListIterator it( dm_s ); it.current(); ++it )
- openDataModel( studyName(), it.current() );
- // this will build a SUIT_DataObject-s tree under myRoot member field
- // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
- // but tree that corresponds to not-loaded data models will be updated any way.
- ((LightApp_Application*)application())->updateObjectBrowser( false );
-
- bool res = CAM_Study::openDocument( theFileName );
-
- emit opened( this );
- return res;
-}
-
-/*!
- Loads document
-*/
-bool LightApp_Study::loadDocument( const QString& theStudyName )
-{
- myDriver->ClearDriverContents();
- if( !openStudyData(theStudyName))
- return false;
-
- setRoot( new LightApp_RootObject( this ) ); // create myRoot
-
- //SRN: BugID IPAL9021, put there the same code as in a method openDocument
-
- // update loaded data models: call open() and update() on them.
- ModelList dm_s;
- dataModels( dm_s );
-
- for ( ModelListIterator it( dm_s ); it.current(); ++it )
- openDataModel( studyName(), it.current() );
-
- // this will build a SUIT_DataObject-s tree under myRoot member field
- // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
- // but tree that corresponds to not-loaded data models will be updated any way.
- ((LightApp_Application*)application())->updateObjectBrowser( false );
-
- bool res = CAM_Study::openDocument( theStudyName );
- emit opened( this );
- //SRN: BugID IPAL9021: End
- return res;
-}
-
-/*!
- Saves document
-*/
-bool LightApp_Study::saveDocumentAs( const QString& theFileName )
-{
- SUIT_ResourceMgr* resMgr = application()->resourceMgr();
- if( !resMgr )
- return false;
-
- ModelList list;
- dataModels( list );
-
- LightApp_DataModel* aModel = (LightApp_DataModel*)list.first();
-
- QStringList listOfFiles;
- bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
- for ( ; aModel; aModel = (LightApp_DataModel*)list.next() )
- {
- std::vector<std::string> anOldList = myDriver->GetListOfFiles( aModel->module()->name() );
- listOfFiles.clear();
- aModel->saveAs( theFileName, this, listOfFiles );
- if ( !listOfFiles.isEmpty() )
- saveModuleData(aModel->module()->name(), listOfFiles);
-
- // Remove files if necessary. File is removed if it was in the list of files before
- // saving and it is not contained in the list after saving. This provides correct
- // removing previous temporary files. These files are not removed before saving
- // because they may be required for it.
-
- std::vector<std::string> aNewList = myDriver->GetListOfFiles( aModel->module()->name() );
-
- std::set<std::string> aNewNames;
- std::set<std::string> toRemove;
- int i, n;
- for( i = 0, n = aNewList.size(); i < n; i++ )
- aNewNames.insert( aNewList[ i ] );
- for( i = 0, n = anOldList.size(); i < n; i++ )
- {
- if ( i == 0 ) // directory is always inserted in list
- toRemove.insert( anOldList[ i ] );
- else if ( aNewNames.find( anOldList[ i ] ) == aNewNames.end() )
- toRemove.insert( anOldList[ i ] );
- }
-
- std::vector<std::string> toRemoveList( toRemove.size() );
- std::set<std::string>::iterator anIter;
- for( anIter = toRemove.begin(), i = 0; anIter != toRemove.end(); ++anIter, ++i )
- toRemoveList[ i ] = *anIter;
-
-
- myDriver->RemoveFiles( toRemoveList, isMultiFile );
- }
-
- bool res = saveStudyData(theFileName);
- res = res && CAM_Study::saveDocumentAs( theFileName );
- //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
- if ( res )
- emit saved( this );
-
- return res;
-}
-
-/*!
- Saves document
-*/
-bool LightApp_Study::saveDocument()
-{
- ModelList list; dataModels( list );
-
- LightApp_DataModel* aModel = (LightApp_DataModel*)list.first();
-
- myDriver->ClearDriverContents();
- QStringList listOfFiles;
- for ( ; aModel; aModel = (LightApp_DataModel*)list.next() ) {
- listOfFiles.clear();
- aModel->save( listOfFiles );
- saveModuleData(aModel->module()->name(), listOfFiles);
- }
-
- bool res = saveStudyData(studyName());
- res = res && CAM_Study::saveDocument();
- if (res)
- emit saved( this );
-
- return res;
-}
-
-/*!
- Closes document
-*/
-void LightApp_Study::closeDocument(bool permanently)
-{
- // Inform everybody that this study is going to close when it's most safe to,
- // i.e. in the very beginning
- emit closed( this );
-
- CAM_Study::closeDocument(permanently);
-
- // Remove temporary files
- myDriver->ClearDriverContents();
-}
-
-/*!
- \return real entry by entry of reference
- \param entry - entry of reference object
-*/
-QString LightApp_Study::referencedToEntry( const QString& entry ) const
-{
- return entry;
-}
-
-/*!
- \return entries of object children
-*/
-void LightApp_Study::children( const QString&, QStringList& ) const
-{
-}
-
-/*!
- \return true if entry corresponds to component
-*/
-bool LightApp_Study::isComponent( const QString& entry ) const
-{
- if( !root() )
- return false;
-
- DataObjectList ch;
- root()->children( ch );
- DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
- for( ; anIt!=aLast; anIt++ )
- {
- LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( *anIt );
- if( obj && obj->entry()==entry )
- return true;
- }
- return false;
-}
-
-/*!
- \return component data type for entry
-*/
-QString LightApp_Study::componentDataType( const QString& entry ) const
-{
- LightApp_DataObject* aCurObj;
- for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
- aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
- if ( aCurObj && aCurObj->entry() == entry ) {
- return aCurObj->componentDataType();
- }
- }
- return "";
-}
-
-/*!
- \return true if study is modified
-*/
-bool LightApp_Study::isModified() const
-{
- bool isAnyChanged = CAM_Study::isModified();
- ModelList list; dataModels( list );
-
- LightApp_DataModel* aModel = 0;
- for ( QPtrListIterator<CAM_DataModel> it( list ); it.current() && !isAnyChanged; ++it ){
- aModel = dynamic_cast<LightApp_DataModel*>( it.current() );
- if ( aModel )
- isAnyChanged = aModel->isModified();
- }
- return isAnyChanged;
-}
-
-/*!
- \return true if data model is saved
-*/
-bool LightApp_Study::isSaved() const
-{
- return CAM_Study::isSaved();
-}
-
-/*!
- Creates SComponent for module, necessary for SalomeApp study
-*/
-void LightApp_Study::addComponent(const CAM_DataModel* dm)
-{
-}
-
-/*!
- Saves list file for module 'theModuleName'
-*/
-void LightApp_Study::saveModuleData(QString theModuleName, QStringList theListOfFiles)
-{
- int aNb = theListOfFiles.count();
- if ( aNb == 0 )
- return;
-
- std::vector<std::string> aListOfFiles ( aNb );
- int anIndex = 0;
- for ( QStringList::Iterator it = theListOfFiles.begin(); it != theListOfFiles.end(); ++it ) {
- if ( (*it).isEmpty() )
- continue;
- aListOfFiles[anIndex] = (*it).latin1();
- anIndex++;
- }
- myDriver->SetListOfFiles(theModuleName, aListOfFiles);
-}
-
-/*!
- Gets list of file for module 'theModuleNam'
-*/
-void LightApp_Study::openModuleData(QString theModuleName, QStringList& theListOfFiles)
-{
- std::vector<std::string> aListOfFiles = myDriver->GetListOfFiles(theModuleName);
- int i, aLength = aListOfFiles.size() - 1;
- if (aLength < 0)
- return;
-
- //Get a temporary directory for saved a file
- theListOfFiles.append(aListOfFiles[0].c_str());
- for(i = 0; i < aLength; i++)
- theListOfFiles.append(aListOfFiles[i+1].c_str());
-}
-
-/*!
- Saves data from study
-*/
-bool LightApp_Study::saveStudyData( const QString& theFileName )
-{
- ModelList list; dataModels( list );
- SUIT_ResourceMgr* resMgr = application()->resourceMgr();
- if( !resMgr )
- return false;
- bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
-
- bool aRes = myDriver->SaveDatasInFile(theFileName.latin1(), isMultiFile);
- return aRes;
-}
-
-/*!
- Opens data for study
-*/
-bool LightApp_Study::openStudyData( const QString& theFileName )
-{
- SUIT_ResourceMgr* resMgr = application()->resourceMgr();
- if( !resMgr )
- return false;
- bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
-
- bool aRes = myDriver->ReadDatasFromFile(theFileName.latin1(), isMultiFile);
- return aRes;
-}
-
-/*!
- Opens data model
-*/
-bool LightApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm )
-{
- if (!dm)
- return false;
-
- QStringList listOfFiles;
- openModuleData(dm->module()->name(), listOfFiles);
- if (dm && dm->open(studyName, this, listOfFiles)) {
- // Something has been read -> create data model tree
- LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>( dm );
- if ( aDM )
- aDM->update(NULL, this);
- return true;
- }
- return false;
-}
-
-/*!
- \return temporary directory for saving files of modules
-*/
-std::string LightApp_Study::GetTmpDir (const char* theURL,
- const bool isMultiFile)
-{
- return myDriver->GetTmpDir(theURL, isMultiFile);
-}
-
-/*!
- \return list of files necessary for module
- \param theModuleName - name of module
-*/
-std::vector<std::string> LightApp_Study::GetListOfFiles(const char* theModuleName) const
-{
- std::vector<std::string> aListOfFiles;
- aListOfFiles = myDriver->GetListOfFiles(theModuleName);
- return aListOfFiles;
-}
-
-/*!
- Sets list of files necessary for module
- \param theModuleName - name of module
- \param theListOfFiles - list of files
-*/
-void LightApp_Study::SetListOfFiles (const char* theModuleName, const std::vector<std::string> theListOfFiles)
-{
- myDriver->SetListOfFiles(theModuleName, theListOfFiles);
-}
-
-/*!
- Removes temporary files
-*/
-void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, const bool isMultiFile) const
-{
- if (isMultiFile)
- return;
- bool isDirDeleted = true;
- myDriver->RemoveTemporaryFiles(theModuleName, isDirDeleted);
-}
-
-/*!
- Fills list with components names
- \param comp - list to be filled
-*/
-void LightApp_Study::components( QStringList& comp ) const
-{
- DataObjectList children = root()->children();
- DataObjectList::const_iterator anIt = children.begin(), aLast = children.end();
- for( ; anIt!=aLast; anIt++ )
- {
- LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( *anIt );
- if( obj && obj->entry()!="Interface Applicative" )
- comp.append( obj->entry() );
- }
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_STUDY_H
-#define LIGHTAPP_STUDY_H
-
-#include <LightApp.h>
-#include <LightApp_Driver.h>
-
-#include <CAM_Study.h>
-#include <CAM_DataModel.h>
-#include <SUIT_Study.h>
-
-#include "string"
-#include "vector"
-
-class SUIT_Application;
-class CAM_DataModel;
-
-/*!
- Custom study, using for open/close of documents HDF format.
- Data of each module can be saved to different files, those
- after that are combined into one HDF file
-*/
-class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study
-{
- Q_OBJECT
-
-public:
- LightApp_Study( SUIT_Application* );
- virtual ~LightApp_Study();
-
- virtual void createDocument();
- virtual bool openDocument( const QString& );
- virtual bool loadDocument( const QString& );
-
- virtual bool saveDocument();
- virtual bool saveDocumentAs( const QString& );
-
- virtual void closeDocument(bool permanently = true);
-
- virtual bool isSaved() const;
- virtual bool isModified() const;
-
- virtual void addComponent ( const CAM_DataModel* dm);
-
- virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile );
-
- virtual QString componentDataType( const QString& ) const;
- virtual QString referencedToEntry( const QString& ) const;
- virtual bool isComponent( const QString& ) const;
- virtual void children( const QString&, QStringList& ) const;
- virtual void components( QStringList& ) const;
-
-protected:
- virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );
- virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles );
- virtual bool saveStudyData ( const QString& theFileName );
- virtual bool openStudyData ( const QString& theFileName );
-
- virtual std::vector<std::string> GetListOfFiles ( const char* theModuleName ) const;
- virtual void SetListOfFiles ( const char* theModuleName,
- const std::vector<std::string> theListOfFiles );
-
- virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const;
-
-protected:
- virtual bool openDataModel ( const QString&, CAM_DataModel* );
-
-signals:
- void saved ( SUIT_Study* );
- void opened ( SUIT_Study* );
- void closed ( SUIT_Study* );
- void created( SUIT_Study* );
-
-
-private:
- LightApp_Driver* myDriver;
-
- friend class LightApp_Application;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "LightApp_SwitchOp.h"
-#include "LightApp_Module.h"
-#include "LightApp_Operation.h"
-#include "LightApp_Dialog.h"
-#include <CAM_Application.h>
-#include <SUIT_Operation.h>
-#include <SUIT_Study.h>
-#include <qevent.h>
-#include <qwidget.h>
-#include <qptrlist.h>
-#include <qapplication.h>
-
-/*!
- * \brief Constructor
- * \param theParent - parent of object
-*
-* Creates instance of the object. Connects signals and slots. Install eveny filter
-* on application
-*/
-LightApp_SwitchOp::LightApp_SwitchOp( LightApp_Module* theModule )
-: QObject( 0 ),
- myModule( theModule )
-{
- qApp->installEventFilter( this );
-}
-
-/*!
- * \brief Destructor
-*/
-LightApp_SwitchOp::~LightApp_SwitchOp()
-{
-
-}
-
-/*!
- * \brief Get module
-*
-* Get module. Module is a parent of this class
-*/
-LightApp_Module* LightApp_SwitchOp::module() const
-{
- return myModule;
-}
-
-/*!
- * \brief Get study
- * \return Active study of application (in current realisation)
-*
-* Get study
-*/
-SUIT_Study* LightApp_SwitchOp::study() const
-{
- return module()->application()->activeStudy();
-}
-
-/*!
- * \brief Get operation by widget
- * \param theWg - key widget to find operation
- * \return Pointer to the operations if it is found or zero
-*
-* Find operation containing dialog with given widget
-*/
-LightApp_Operation* LightApp_SwitchOp::operation( QWidget* theWg ) const
-{
- // get dialog from widget
- LightApp_Dialog* aDlg = 0;
- QWidget* aParent = theWg;
- while( aParent && !aParent->inherits( "LightApp_Dialog" ) )
- aParent = aParent->parentWidget();
-
- if ( aParent && aParent->inherits( "LightApp_Dialog" ) )
- aDlg = (LightApp_Dialog*)aParent;
-
- // try to find operation corresponding to the dialog
- if ( aDlg != 0 && study() != 0 )
- {
- QPtrListIterator<SUIT_Operation> anIter( study()->operations() );
- while( SUIT_Operation* anOp = anIter.current() )
- {
- if ( anOp->inherits( "LightApp_Operation" ) &&
- ((LightApp_Operation*)anOp)->dlg() == aDlg )
- return ((LightApp_Operation*)anOp);
- ++anIter;
- }
- }
-
- return 0;
-}
-
-/*!
- * \brief Event filter
- * \param theObj - object
- * \param theEv - event
-*
-* Event filter. Catched signals off application. If event concerns to dialog then
-* corresponding operation is found and activated.
-*/
-bool LightApp_SwitchOp::eventFilter( QObject* theObj, QEvent* theEv )
-{
- if ( theObj->inherits( "QWidget" ) && ( theEv->type() == QEvent::Enter ) )
- {
- QEvent::Type aType = theEv->type();
- LightApp_Operation* anOp = operation( (QWidget*)theObj );
- if ( anOp )
- {
- switch ( aType )
- {
- case QEvent::Enter:
- {
- if ( !anOp->isActive() && anOp->isAutoResumed() &&
- study() && !study()->blockingOperation( anOp ) )
- study()->resume( anOp );
- }
- break;
-
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- {
- if ( !anOp->isActive() )
- return true;
- }
- break;
-
- }
- }
- }
-
- return QObject::eventFilter( theObj, theEv );
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef LightApp_SwitchOp_H
-#define LightApp_SwitchOp_H
-
-#include "LightApp.h"
-#include <qobject.h>
-
-class LightApp_Module;
-class LightApp_Operation;
-class QEvent;
-class SUIT_Study;
-
-/*!
- * \brief This class is intended for controling switching between operation
- *
- * Several operation may be launched simultaneously. This class is intended for
- * controlling switching between such operations. This class works with operations having
- * dialogs (activation of other operations is performed by SUIT_Study). When several
- * operations is launched simultaneously corresponding dialogs are shown on the screen.
- * Only one operation from the launched ones can be active (active operation). Other
- * operations are suspended. As result only one dialog from shown ones can be active too.
- * Other dialogs are disabled. This class installs event filter on application. When mouse
- * cursor is moved above disabled dialog corresponding event is catched by this class.
- * It finds corresponding operation and verify whether operation can be resumed (see
- * SUIT_Study::isDenied( SUIT_Operation* ) method). If yes then current active
- * operation is suspended and new operation activated. Module contains this class as a
- * field. Then module is created instance of this class created too.
- */
-class LIGHTAPP_EXPORT LightApp_SwitchOp : public QObject
-{
- Q_OBJECT
-
-public:
-
- LightApp_SwitchOp( LightApp_Module* );
- virtual ~LightApp_SwitchOp();
-
- // Redefined from base class
- bool eventFilter( QObject*, QEvent* );
-
-private:
-
- LightApp_Module* module() const;
- LightApp_Operation* operation( QWidget* ) const;
- SUIT_Study* study() const;
-
-private:
-
- LightApp_Module* myModule;
-
-};
-
-#endif
-
-
-
-
-
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File : LightApp_UpdateFlags.h
-// Author : Sergey LITONIN
-// Module : LIGHT
-
-
-#ifndef LightApp_UpdateFlags_H
-#define LightApp_UpdateFlags_H
-
-/*!
- \enum UpdateFlags
- Enumeration for update flags. First byte is reserved for LightApp_Module.
- Modules derived from this model must use other 3 bytes to define their
- own update flags
-*/
-
-typedef enum
-{
- UF_Forced = 0x00000001,
- UF_Model = 0x00000002,
- UF_Viewer = 0x00000004,
- UF_ObjBrowser = 0x00000008,
- UF_Controls = 0x00000010,
-} UpdateFlags;
-
-#endif
-
-
-
-
-
-
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D\r
-// \r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either \r
-// version 2.1 of the License.\r
-// \r
-// This library is distributed in the hope that it will be useful \r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public \r
-// License along with this library; if not, write to the Free Software \r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-#include "LightApp_VTKSelector.h"\r
-#include "LightApp_DataOwner.h"\r
-\r
-#ifndef DISABLE_VTKVIEWER\r
- #include "SVTK_ViewModelBase.h"\r
- #include "SVTK_ViewManager.h"\r
- #include "SVTK_Selector.h"\r
- #include "SVTK_ViewWindow.h"\r
- #include "SVTK_Functor.h"\r
- #include "VTKViewer_Algorithm.h"\r
- #include <vtkRenderer.h>\r
-#endif\r
-\r
-#ifndef DISABLE_SALOMEOBJECT\r
- #include "SALOME_Actor.h"\r
- #include "SALOME_ListIteratorOfListIO.hxx"\r
-#endif\r
-\r
-\r
-\r
-#ifndef DISABLE_VTKVIEWER\r
-#ifndef DISABLE_SALOMEOBJECT\r
-/*!\r
- Constructor.\r
-*/\r
-LightApp_SVTKDataOwner::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,\r
- SUIT_Desktop* theDesktop )\r
-: LightApp_DataOwner( theIO ),\r
-myDesktop( theDesktop )\r
-{\r
-}\r
-#else\r
-LightApp_SVTKDataOwner::LightApp_SVTKDataOwner( const QString& theEntry )\r
-: LightApp_DataOwner( theEntry )\r
-{\r
-}\r
-#endif\r
-\r
-/*!\r
- \return active SVTK view window\r
-*/\r
-SVTK_ViewWindow* \r
-LightApp_SVTKDataOwner\r
-::GetActiveViewWindow() const\r
-{\r
- if(SUIT_ViewWindow* aViewWindow = myDesktop->activeWindow())\r
- return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);\r
-\r
- return NULL;\r
-}\r
-\r
-/*!\r
- Gets dataowners ids list.\r
-*/\r
-const TColStd_IndexedMapOfInteger& \r
-LightApp_SVTKDataOwner\r
-::GetIds() const\r
-{\r
- if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){\r
- if(SVTK_Selector* aSelector = aViewWindow->GetSelector()){\r
- aSelector->GetIndex(IO(),myIds);\r
- }\r
- }\r
-\r
- return myIds;\r
-}\r
-\r
-/*!\r
- Gets selection mode.\r
-*/\r
-Selection_Mode\r
-LightApp_SVTKDataOwner\r
-::GetMode() const\r
-{\r
- if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){\r
- if(SVTK_Selector* aSelector = aViewWindow->GetSelector()){\r
- return aSelector->SelectionMode();\r
- }\r
- }\r
- \r
- return -1;\r
-}\r
-\r
-/*!\r
- Gets actor pointer.\r
-*/\r
-SALOME_Actor* \r
-LightApp_SVTKDataOwner\r
-::GetActor() const\r
-{\r
- if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){\r
- using namespace SVTK;\r
- return Find<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(IO()));\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-#endif\r
-\r
-/*!\r
- Destuctor.\r
-*/\r
-/*\r
-LightApp_SVTKDataOwner::~LightApp_SVTKDataOwner()\r
-{\r
-}\r
-*/\r
-\r
-#ifndef DISABLE_VTKVIEWER\r
-/*!\r
- Constructor.\r
-*/\r
-LightApp_VTKSelector\r
-::LightApp_VTKSelector( SVTK_ViewModelBase* viewer, \r
- SUIT_SelectionMgr* mgr ): \r
- SUIT_Selector( mgr, viewer ),\r
- myViewer( viewer )\r
-{\r
- if ( myViewer )\r
- connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );\r
-}\r
-\r
-/*!\r
- Gets viewer.\r
-*/\r
-SVTK_ViewModelBase* \r
-LightApp_VTKSelector\r
-::viewer() const\r
-{\r
- return myViewer;\r
-}\r
-\r
-/*!\r
- Gets type of salome vtk viewer.\r
-*/\r
-QString\r
-LightApp_VTKSelector\r
-::type() const\r
-{ \r
- return myViewer->getType(); \r
-}\r
-\r
-#endif\r
-/*!\r
- On selection changed.\r
-*/\r
-void\r
-LightApp_VTKSelector\r
-::onSelectionChanged()\r
-{\r
- selectionChanged();\r
-}\r
-\r
-#ifndef DISABLE_VTKVIEWER\r
-\r
-/*!\r
- Gets list of selected data owners.(output \a aList).\r
-*/\r
-void\r
-LightApp_VTKSelector\r
-::getSelection( SUIT_DataOwnerPtrList& aList ) const\r
-{\r
- if(myViewer){\r
- if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){\r
- if(SVTK_ViewManager* aViewMgr = dynamic_cast<SVTK_ViewManager*>(aViewManager)){\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){\r
- if(SVTK_Selector* aSelector = aView->GetSelector()){\r
- const SALOME_ListIO& aListIO = aSelector->StoredIObjects();\r
- SALOME_ListIteratorOfListIO anIter(aListIO);\r
- for(; anIter.More(); anIter.Next()){\r
- Handle(SALOME_InteractiveObject) anIO = anIter.Value();\r
- if(anIO->hasEntry())\r
- aList.append(new LightApp_SVTKDataOwner(anIO,aViewMgr->getDesktop()));\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-/*!\r
- Sets selection to selector from data owner list \a theList.\r
-*/\r
-void \r
-LightApp_VTKSelector\r
-::setSelection( const SUIT_DataOwnerPtrList& theList )\r
-{\r
- if(myViewer){\r
- if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){\r
- if(SVTK_Selector* aSelector = aView->GetSelector()){\r
- SALOME_ListIO anAppendList;\r
- const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();\r
- SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();\r
- for(; anIter != theList.end(); ++anIter){\r
- const SUIT_DataOwner* aDataOwner = (*anIter).get();\r
- if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){\r
- aSelector->SetSelectionMode(anOwner->GetMode());\r
- Handle(SALOME_InteractiveObject) anIO = anOwner->IO();\r
-\r
- aSelector->AddIObject(anIO);\r
-\r
- anAppendList.Append(anIO);\r
- aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);\r
- }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){\r
- Handle(SALOME_InteractiveObject) anIO = \r
- new SALOME_InteractiveObject(anOwner->entry().latin1(),"");\r
- aSelector->AddIObject(anIO);\r
- anAppendList.Append(anIO);\r
- }\r
- }\r
- // To remove IOs, which is not selected.\r
- QMap< QString, Handle( SALOME_InteractiveObject )> toRemove;\r
- SALOME_ListIteratorOfListIO anIt( aStoredList );\r
- for( ; anIt.More(); anIt.Next() )\r
- if( !anIt.Value().IsNull() )\r
- toRemove[ anIt.Value()->getEntry() ] = anIt.Value();\r
-\r
- anIt = SALOME_ListIteratorOfListIO(anAppendList);\r
- for( ; anIt.More(); anIt.Next() )\r
- toRemove.remove( anIt.Value()->getEntry() );\r
-\r
- QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),\r
- REnd = toRemove.end();\r
- for( ; RIt!=REnd; RIt++ )\r
- aSelector->RemoveIObject( RIt.data() );\r
- \r
- aView->onSelectionChanged();\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-#endif\r
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D\r
-// \r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either \r
-// version 2.1 of the License.\r
-// \r
-// This library is distributed in the hope that it will be useful \r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public \r
-// License along with this library; if not, write to the Free Software \r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-#ifndef LIGHTAPP_VTKSELECTOR_H\r
-#define LIGHTAPP_VTKSELECTOR_H\r
-\r
-#include "SUIT_Selector.h"\r
-#include "LightApp.h"\r
-#include "LightApp_DataOwner.h"\r
-\r
-class SUIT_Desktop;\r
-\r
-#ifndef DISABLE_VTKVIEWER\r
- #include <vtkSmartPointer.h>\r
- #include <TColStd_IndexedMapOfInteger.hxx>\r
- #include "SVTK_Selection.h"\r
-#ifndef DISABLE_SALOMEOBJECT\r
- #include "SALOME_InteractiveObject.hxx"\r
-#endif\r
- class SALOME_Actor;\r
- class SVTK_ViewWindow;\r
- class SVTK_ViewModelBase;\r
-#endif\r
-\r
-/*!\r
- Provide salome vtk data owner list.\r
-*/\r
-class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner\r
-{\r
- public:\r
- virtual ~LightApp_SVTKDataOwner() {};\r
-#ifndef DISABLE_VTKVIEWER\r
- #ifndef DISABLE_SALOMEOBJECT\r
- LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)&, SUIT_Desktop* );\r
- #else\r
- LightApp_SVTKDataOwner( const QString& );\r
- #endif\r
-\r
- /*!Gets dataowners ids list.*/\r
- const TColStd_IndexedMapOfInteger& GetIds() const;\r
-\r
- /*!Gets selection mode.*/\r
- Selection_Mode GetMode() const;\r
-\r
- /*!Finds corresponding actor in the active viewer.*/\r
- SALOME_Actor* GetActor() const;\r
-\r
- protected:\r
- mutable TColStd_IndexedMapOfInteger myIds;\r
-\r
- SVTK_ViewWindow* GetActiveViewWindow() const;\r
- SUIT_Desktop* myDesktop;\r
-#endif\r
-};\r
-\r
-\r
-/*!\r
- \class LightApp_VTKSelector\r
- Custom selector to get/set selection from object browser\r
-*/\r
-class LIGHTAPP_EXPORT LightApp_VTKSelector : public SUIT_Selector\r
-{\r
- Q_OBJECT;\r
-\r
-public:\r
- virtual ~LightApp_VTKSelector() {};\r
-#ifndef DISABLE_VTKVIEWER\r
- LightApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* );\r
-\r
- SVTK_ViewModelBase* viewer() const;\r
-\r
- virtual QString type() const;\r
-#else\r
- LightApp_VTKSelector( SUIT_SelectionMgr* );\r
-#endif\r
-\r
-private slots:\r
- void onSelectionChanged();\r
-\r
-#ifndef DISABLE_VTKVIEWER\r
-protected:\r
- virtual void getSelection( SUIT_DataOwnerPtrList& ) const;\r
- virtual void setSelection( const SUIT_DataOwnerPtrList& );\r
-\r
-private:\r
- SVTK_ViewModelBase* myViewer;\r
-\r
-#endif\r
-};\r
-\r
-#endif\r
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "LightApp_WidgetContainer.h"
-
-#include <qobjectlist.h>
-#include <qwidgetstack.h>
-
-/*!
- Constructor.
-*/
-LightApp_WidgetContainer::LightApp_WidgetContainer( const int type, QWidget* parent )
-: QDockWindow( QDockWindow::InDock, parent ),
-myType( type )
-{
- setWidget( myStack = new QWidgetStack( this ) );
- myStack->show();
-}
-
-/*!
- Destructor.
-*/
-LightApp_WidgetContainer::~LightApp_WidgetContainer()
-{
-}
-
-/*!
- Checks: is widget container is empty?
-*/
-bool LightApp_WidgetContainer::isEmpty() const
-{
- const QObjectList* lst = myStack->children();
- if ( !lst )
- return true;
-
- bool res = true;
- for ( QObjectListIt it( *lst ); it.current() && res; ++it )
- {
- if ( it.current()->isWidgetType() && myStack->id( (QWidget*)it.current() ) != -1 )
- res = false;
- }
- return res;
-}
-
-/*!
- Gets type of widget container.
-*/
-int LightApp_WidgetContainer::type() const
-{
- return myType;
-}
-
-/*!
- Checks: is container contains widget with id \a id.
-*/
-bool LightApp_WidgetContainer::contains( const int id ) const
-{
- return myStack->widget( id ) != 0;
-}
-
-/*!
- * Insert widget(\a wid with id \a id) to container.And return id of widget in stack.
- *\warning remove widget with id = \a id , if it was in container.
- */
-int LightApp_WidgetContainer::insert( const int id, QWidget* wid )
-{
- if ( id == -1 || !wid )
- return -1;
-
- if ( contains( id ) )
- remove( id );
-
- int stackId = myStack->addWidget( wid, id );
- if ( !myStack->visibleWidget() )
- myStack->raiseWidget( wid );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-
- return stackId;
-}
-
-/*!
- Remove widget(\a wid) from stack.
-*/
-void LightApp_WidgetContainer::remove( const int id )
-{
- remove( myStack->widget( id ) );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Remove widget(\a wid) from stack.
-*/
-void LightApp_WidgetContainer::remove( QWidget* wid )
-{
- myStack->removeWidget( wid );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Raise widget with id = \a id.
-*/
-void LightApp_WidgetContainer::activate( const int id )
-{
- myStack->raiseWidget( id );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Raise widget (\a wid).
-*/
-void LightApp_WidgetContainer::activate( QWidget* wid )
-{
- myStack->raiseWidget( wid );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Gets widget from container list(stack) by id = \a id.
-*/
-QWidget* LightApp_WidgetContainer::widget( const int id ) const
-{
- return myStack->widget( id );
-}
-
-/*!
- Gets visible widget.
-*/
-QWidget* LightApp_WidgetContainer::active() const
-{
- return myStack->visibleWidget();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef LIGHTAPP_WIDGETCONTAINER_H
-#define LIGHTAPP_WIDGETCONTAINER_H
-
-#include "LightApp.h"
-
-#include <qdockwindow.h>
-
-class QWidget;
-class QWidgetStack;
-
-/*!
- Class which privade widget container.
-*/
-class LIGHTAPP_EXPORT LightApp_WidgetContainer : public QDockWindow
-{
- Q_OBJECT
-
-public:
- LightApp_WidgetContainer( const int, QWidget* = 0 );
- virtual ~LightApp_WidgetContainer();
-
- bool isEmpty() const;
-
- int type() const;
-
- int insert( const int, QWidget* );
- void remove( QWidget* );
- void remove( const int );
- bool contains( const int ) const;
-
- void activate( QWidget* );
- void activate( const int );
-
- QWidget* active() const;
- QWidget* widget( const int ) const;
-
-private:
- int myType;
- QWidgetStack* myStack;
-};
-
-#endif
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# File : Makefile.in
-# Author : OCC team (OCN)
-# Module : LightApp
-# $Header$
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@srcdir@/resources
-
-
-@COMMENCE@
-
-# header files
-EXPORT_HEADERS= LightApp.h \
- LightApp_AboutDlg.h \
- LightApp_Application.h \
- LightApp_DataModel.h \
- LightApp_DataObject.h \
- LightApp_DataOwner.h \
- LightApp_DataSubOwner.h \
- LightApp_Dialog.h \
- LightApp_Displayer.h \
- LightApp_Driver.h \
- LightApp_EventFilter.h \
- LightApp_HDFDriver.h \
- LightApp_Module.h \
- LightApp_ModuleDlg.h \
- LightApp_NameDlg.h \
- LightApp_OBFilter.h \
- LightApp_OBSelector.h \
- LightApp_Operation.h \
- LightApp_Selection.h \
- LightApp_SelectionMgr.h \
- LightApp_ShowHideOp.h \
- LightApp_Study.h \
- LightApp_SwitchOp.h \
- LightApp_Preferences.h \
- LightApp_PreferencesDlg.h \
- LightApp_RootObject.h \
- LightApp_UpdateFlags.h \
- LightApp_WidgetContainer.h
-
-ifneq ($(DISABLE_VTKVIEWER),yes)
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- EXPORT_HEADERS+= LightApp_VTKSelector.h
-endif
-endif
-ifneq ($(DISABLE_OCCVIEWER),yes)
- EXPORT_HEADERS+= LightApp_OCCSelector.h
-endif
-ifneq ($(DISABLE_GLVIEWER),yes)
- EXPORT_HEADERS+= LightApp_GLSelector.h
-endif
-
-# .po files to transform in .qm
-PO_FILES = LightApp_images.po \
- LightApp_msg_en.po
-
-# Libraries targets
-LIB = libLightApp.la
-
-LIB_SRC= LightApp_AboutDlg.cxx \
- LightApp_Application.cxx \
- LightApp_DataModel.cxx \
- LightApp_DataObject.cxx \
- LightApp_DataOwner.cxx \
- LightApp_DataSubOwner.cxx \
- LightApp_Dialog.cxx \
- LightApp_Displayer.cxx \
- LightApp_Driver.cxx \
- LightApp_EventFilter.cxx \
- LightApp_HDFDriver.cxx \
- LightApp_Module.cxx \
- LightApp_ModuleDlg.cxx \
- LightApp_NameDlg.cxx \
- LightApp_OBFilter.cxx \
- LightApp_OBSelector.cxx \
- LightApp_Operation.cxx \
- LightApp_Selection.cxx \
- LightApp_SelectionMgr.cxx \
- LightApp_ShowHideOp.cxx \
- LightApp_Study.cxx \
- LightApp_SwitchOp.cxx \
- LightApp_Preferences.cxx \
- LightApp_PreferencesDlg.cxx \
- LightApp_WidgetContainer.cxx
-
-ifneq ($(DISABLE_VTKVIEWER),yes)
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- LIB_SRC+= LightApp_VTKSelector.cxx
-endif
-endif
-ifneq ($(DISABLE_OCCVIEWER),yes)
- LIB_SRC+= LightApp_OCCSelector.cxx
-endif
-ifneq ($(DISABLE_GLVIEWER),yes)
- LIB_SRC+= LightApp_GLSelector.cxx
-endif
-
-LIB_MOC = LightApp_AboutDlg.h \
- LightApp_Application.h \
- LightApp_DataModel.h \
- LightApp_Dialog.h \
- LightApp_OBSelector.h \
- LightApp_Operation.h \
- LightApp_Module.h \
- LightApp_ModuleDlg.h \
- LightApp_NameDlg.h \
- LightApp_SelectionMgr.h \
- LightApp_ShowHideOp.h \
- LightApp_Study.h \
- LightApp_SwitchOp.h \
- LightApp_Preferences.h \
- LightApp_PreferencesDlg.h \
- LightApp_WidgetContainer.h
-
-ifneq ($(DISABLE_VTKVIEWER),yes)
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- LIB_MOC+= LightApp_VTKSelector.h
-endif
-endif
-ifneq ($(DISABLE_OCCVIEWER),yes)
- LIB_MOC+= LightApp_OCCSelector.h
-endif
-ifneq ($(DISABLE_GLVIEWER),yes)
- LIB_MOC+= LightApp_GLSelector.h
-endif
-
-RESOURCES_FILES = icon_about.png \
- icon_applogo.png \
- icon_default.png \
- icon_module.png \
- icon_module_big.png \
- icon_select.png \
- LightApp.ini \
- LightApp.xml
-
-CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(OCC_INCLUDES) \
- $(HDF5_INCLUDES) $(KERNEL_CXXFLAGS)
-
-ifneq ($(DISABLE_VTKVIEWER),yes)
- CPPFLAGS+= $(VTK_INCLUDES)
-else
- CPPFLAGS+= -DDISABLE_VTKVIEWER
-endif
-ifneq ($(DISABLE_PLOT2DVIEWER),yes)
- CPPFLAGS+= $(QWT_INCLUDES)
-else
- CPPFLAGS+= -DDISABLE_PLOT2DVIEWER
-endif
-ifeq ($(DISABLE_OCCVIEWER),yes)
- CPPFLAGS+= -DDISABLE_OCCVIEWER
-endif
-ifneq ($(DISABLE_PYCONSOLE),yes)
- CPPFLAGS+= $(PYTHON_INCLUDES)
-else
- CPPFLAGS+= -DDISABLE_PYCONSOLE
-endif
-ifeq ($(DISABLE_GLVIEWER),yes)
- CPPFLAGS+= -DDISABLE_GLVIEWER
-endif
-ifeq ($(DISABLE_SUPERVGRAPHVIEWER),yes)
- CPPFLAGS+= -DDISABLE_SUPERVGRAPHVIEWER
-endif
-ifeq ($(DISABLE_SALOMEOBJECT),yes)
- CPPFLAGS+= -DDISABLE_SALOMEOBJECT
-endif
-
-LDFLAGS+=$(QT_MT_LIBS)
-ifneq ($(DISABLE_PYCONSOLE),yes)
- LDFLAGS+= $(PYTHON_LIBS)
-endif
-
-LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lLogWindow $(CAS_KERNEL) -lSalomePrs \
- $(HDF5_LIBS) $(KERNEL_LDFLAGS) -lSalomeHDFPersist
-
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- LIBS+= -lSalomeObject
-endif
-ifneq ($(DISABLE_VTKVIEWER),yes)
- LIBS+= -lVTKViewer
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- LIBS+= -lSVTK
-endif
-endif
-ifneq ($(DISABLE_OCCVIEWER),yes)
- LIBS+= -lOCCViewer
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- LIBS+= -lSOCC
-endif
-endif
-ifneq ($(DISABLE_GLVIEWER),yes)
- LIBS+= -lGLViewer
-endif
-ifneq ($(DISABLE_PLOT2DVIEWER),yes)
- LIBS+= -lPlot2d
-ifneq ($(DISABLE_SALOMEOBJECT),yes)
- LIBS+= -lSPlot2d
-endif
-endif
-ifneq ($(DISABLE_PYCONSOLE),yes)
- LIBS+= -lPyInterp -lPythonConsole
-endif
-ifneq ($(DISABLE_SUPERVGRAPHVIEWER),yes)
- LIBS+= -lSUPERVGraph
-endif
-
-@CONCLUDE@
+++ /dev/null
-# The resources mapping file for LightApp application
-
-[language]
-language = en
-
-[launch]
-modules = LIGHT
-
-[resources]
-SUIT = $(GUI_ROOT_DIR)/share/salome/resources/gui
-STD = $(GUI_ROOT_DIR)/share/salome/resources/gui
-LightApp = $(GUI_ROOT_DIR)/share/salome/resources/gui
-Plot2d = $(GUI_ROOT_DIR)/share/salome/resources/gui
-GLViewer = $(GUI_ROOT_DIR)/share/salome/resources/gui
-OCCViewer = $(GUI_ROOT_DIR)/share/salome/resources/gui
-VTKViewer = $(GUI_ROOT_DIR)/share/salome/resources/gui
-LIGHT = $(LIGHT_ROOT_DIR)/share/salome/resources/light
-
-[LIGHT]
-name = Light
-icon = LIGHT
+++ /dev/null
-<document>
- <section name="launch">
- <!-- SALOME launching parameters -->
- <parameter name="gui" value="yes"/>
- <parameter name="splash" value="yes"/>
- <parameter name="file" value="no"/>
- <parameter name="key" value="no"/>
- <parameter name="interp" value="no"/>
- <parameter name="modules" value="LIGHT"/>
- </section>
- <section name="language">
- <!-- Language settings (resource manager)-->
- <parameter name="language" value="en"/>
- <parameter name="translators" value="%P_msg_%L.qm|%P_icons.qm|%P_images.qm"/>
- </section>
- <section name="splash" >
- <!-- Splash screen settings -->
- <parameter name="image" value="${GUI_ROOT_DIR}/share/salome/resources/gui/icon_about.png" />
- <parameter name="info" value="%A : %V" />
- <parameter name="text_colors" value="#543AA9|#FFFFFF" />
- </section>
- <section name="resources">
- <!-- Resource directories (resource manager)-->
- <parameter name="SUIT" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="STD" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="Plot2d" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="SPlot2d" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="GLViewer" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="OCCViewer" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="VTKViewer" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="SalomeApp" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="OB" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="CAM" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="LightApp" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="SVTK" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="ToolsGUI" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
- <parameter name="LIGHT" value="${LIGHT_ROOT_DIR}/share/salome/resources/light"/>
- </section>
- <section name="desktop" >
- <!-- Default GUI desktop state, position, size -->
- <parameter name="state" value="normal"/>
- <parameter name="pos_x" value="center"/>
- <parameter name="pos_y" value="center"/>
- <parameter name="width" value="800"/>
- <parameter name="height" value="600"/>
- </section>
- <section name="LIGHT">
- <!-- LIGHT module settings -->
- <parameter name="name" value="Light"/>
- <parameter name="icon" value="LIGHT.png"/>
- </section>
- <section name="PyConsole">
- <!-- Python console preferences -->
- <parameter name="font" value="Helvetic,12" />
- <parameter name="additional_families" value="Helvetic;Helvetica;Helvetica[Adobe];Times;Times[Adobe];Sans Serif;Serif;Monospace;Lucida"/>
- </section>
- <section name="FileDlg">
- <!-- "Open/Save File" dialog box preferences-->
- <parameter name="QuickDirList" value=""/>
- </section>
- <section name="Study">
- <!-- General study settings -->
- <parameter name="store_positions" value="true" />
- </section>
- <section name="OCCViewer" >
- <!-- OCC viewer preferences -->
- <parameter name="background" value="35, 136, 145" />
- <parameter name="iso_number_u" value="1" />
- <parameter name="iso_number_v" value="1" />
- <parameter name="trihedron_size" value="100" />
- </section>
- <section name="VTKViewer" >
- <!-- OCC viewer preferences -->
- <parameter name="background" value="0, 0, 0"/>
- <parameter name="trihedron_size" value="100" />
- </section>
- <section name="Plot2d" >
- <!-- Plot2d viewer preferences -->
- <parameter name="Background" value="255, 255, 255" />
- <parameter name="CurveType" value="1" />
- <parameter name="HorScaleMode" value="0" />
- <parameter name="LegendPos" value="1" />
- <parameter name="MarkerSize" value="9" />
- <parameter name="ShowLegend" value="true" />
- <parameter name="VerScaleMode" value="0" />
- </section>
- <section name="SUPERVGraph" >
- <!-- Supervision viewer preferences -->
- <parameter name="Background" value="144, 208, 211" />
- <parameter name="Title" value="63, 213, 255" />
- </section>
-</document>
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: LightApp_images.po
-// Created: May, 2005
-// Author: OCC team
-// Copyright (C) CEA 2005
-
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
-"PO-Revision-Date: YYYY-MM-DD\n"
-"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-msgid "ABOUT"
-msgstr "icon_about.png"
-
-msgid "ABOUT_SPLASH"
-msgstr "icon_about.png"
-
-msgid "APP_DEFAULT_ICO"
-msgstr "icon_default.png"
-
-msgid "APP_MODULE_ICO"
-msgstr "icon_module.png"
-
-msgid "APP_MODULE_BIG_ICO"
-msgstr "icon_module_big.png"
-
-msgid "ICON_SELECT"
-msgstr "icon_select.png"
-
-msgid "APP_BASE_LOGO"
-msgstr "icon_applogo.png"
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
-# would be translated to "Pub", not "Foo::Pub".
-msgid ""
-msgstr ""
-"Project-Id-Version: example-Qt-message-extraction\n"
-"POT-Creation-Date: 1999-02-23 15:38+0200\n"
-"PO-Revision-Date: 1999-02-23 15:38+0200\n"
-"Last-Translator: \n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-
-//=======================================================================================
-
-msgid "APP_NAME"
-msgstr "SALOME"
-
-msgid "ABOUT_CAPTION"
-msgstr "About %1"
-
-msgid "ABOUT_VERSION"
-msgstr "Version %1"
-
-msgid "ABOUT_COPYRIGHT"
-msgstr "Copyright (C) 2003-2006 OPEN CASCADE, EADS/CCR, LIP6,\nCEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS"
-
-msgid "ABOUT_LICENSE"
-msgstr "GNU LGPL"
-
-//=======================================================================================
-
-msgid "LightApp_Application::ACTIVATING_MODULE"
-msgstr "Trying to activate module \"%1\""
-
-msgid "LightApp_Application::TOT_RENAME"
-msgstr "Rename"
-
-msgid "LightApp_Application::MEN_DESK_RENAME"
-msgstr "&Rename"
-
-msgid "LightApp_Application::PRP_RENAME"
-msgstr "Rename active window"
-
-msgid "LightApp_Application::TOT_DESK_PREFERENCES"
-msgstr "Preferences"
-
-msgid "LightApp_Application::MEN_DESK_PREFERENCES"
-msgstr "Pre&ferences..."
-
-msgid "LightApp_Application::TOT_DESK_MRU"
-msgstr "Most recently used"
-
-msgid "LightApp_Application::MEN_DESK_MRU"
-msgstr "Most recently used"
-
-msgid "LightApp_Application::PRP_DESK_PREFERENCES"
-msgstr "Allow to change the preferences"
-
-msgid "LightApp_Application::INF_TOOLBAR_MODULES"
-msgstr "Modules"
-
-msgid "LightApp_Application::PRP_APP_MODULE"
-msgstr "Switch to SALOME platform neutral point"
-
-msgid "LightApp_Application::PRP_MODULE"
-msgstr "Switch to the module \"%1\""
-
-msgid "LightApp_Application::NEW_WINDOW_0"
-msgstr "&GL view"
-
-msgid "LightApp_Application::NEW_WINDOW_1"
-msgstr "&Plot2d view"
-
-msgid "LightApp_Application::NEW_WINDOW_2"
-msgstr "&OCC view"
-
-msgid "LightApp_Application::NEW_WINDOW_3"
-msgstr "VT&K view"
-
-msgid "LightApp_Application::INF_CANCELLED"
-msgstr "Module activation cancelled"
-
-msgid "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"
-msgstr "External browser \"%1\" can not show help page \"%2\". Do you want to change it in preferences?"
-
-msgid "LightApp_Application::DEFINE_EXTERNAL_BROWSER"
-msgstr "External browser is not found. Do you want to define it in preferences?"
-
-msgid "LightApp_Application::DATA_MODELS"
-msgstr "Data models"
-
-msgid "LightApp_Application::OBJECT_BROWSER"
-msgstr "Object Browser"
-
-msgid "LightApp_Application::OBJ_BROWSER_NAME"
-msgstr "Object"
-
-msgid "LightApp_Application::LOG_WINDOW"
-msgstr "Message Window"
-
-//=======================================================================================
-
-msgid "LightApp_Application::MEN_DESK_MODULE_HELP"
-msgstr "Module help"
-
-//=======================================================================================
-
-msgid "LightApp_Application::PREFERENCES_NOT_LOADED"
-msgstr "Preferences for module \"<b>%1</b>\" will be available when the module will be loaded"
-
-msgid "LightApp_Application::PREF_CATEGORY_SALOME"
-msgstr "SALOME"
-
-msgid "LightApp_Application::PREF_TAB_GENERAL"
-msgstr "General"
-
-msgid "LightApp_Application::PREF_GROUP_STUDY"
-msgstr "Study properties"
-
-msgid "LightApp_Application::PREF_MULTI_FILE"
-msgstr "Multi file save"
-
-msgid "LightApp_Application::PREF_ASCII_FILE"
-msgstr "ASCII save"
-
-msgid "LightApp_Application::PREF_STORE_POS"
-msgstr "Store positions of windows"
-
-msgid "LightApp_Application::PREF_GROUP_EXT_BROWSER"
-msgstr "External browser"
-
-msgid "LightApp_Application::PREF_APP"
-msgstr "Application"
-
-msgid "LightApp_Application::PREF_PARAM"
-msgstr "Parameters"
-
-msgid "LightApp_Application::PREF_GROUP_PY_CONSOLE"
-msgstr "Python console properties"
-
-msgid "LightApp_Application::PREF_FONT"
-msgstr "Font"
-
-msgid "LightApp_Application::PREF_TAB_OBJBROWSER"
-msgstr "Object browser"
-
-msgid "LightApp_Application::PREF_OBJ_BROWSER_SETTINGS"
-msgstr "Object browser settings"
-
-msgid "LightApp_Application::PREF_GROUP_DEF_COLUMNS"
-msgstr "Default columns"
-
-msgid "LightApp_Application::PREF_TAB_VIEWERS"
-msgstr "Viewers"
-
-msgid "LightApp_Application::PREF_GROUP_OCCVIEWER"
-msgstr "OCC Viewer 3d"
-
-msgid "LightApp_Application::PREF_GROUP_VTKVIEWER"
-msgstr "VTK Viewer 3d"
-
-msgid "LightApp_Application::PREF_VIEWER_BACKGROUND"
-msgstr "Background color"
-
-msgid "LightApp_Application::PREF_TRIHEDRON_SIZE"
-msgstr "Trihedron size"
-
-msgid "LightApp_Application::PREF_RELATIVE_SIZE"
-msgstr "Relative size"
-
-msgid "LightApp_Application::PREF_ISOS_U"
-msgstr "Number of isolines along U"
-msgid "LightApp_Application::PREF_ISOS_V"
-msgstr "Number of isolines along V"
-
-msgid "LightApp_Application::PREF_TRIHEDRON_SHOW"
-msgstr "Show trihedron"
-
-msgid "LightApp_Application::PREF_GROUP_PLOT2DVIEWER"
-msgstr "Plot2d Viewer"
-
-msgid "LightApp_Application::PREF_SHOW_LEGEND"
-msgstr "Show legend"
-
-msgid "LightApp_Application::PREF_LEGEND_POSITION"
-msgstr "Legend position:"
-
-msgid "LightApp_Application::PREF_LEFT"
-msgstr "Left"
-
-msgid "LightApp_Application::PREF_RIGHT"
-msgstr "Right"
-
-msgid "LightApp_Application::PREF_TOP"
-msgstr "Top"
-
-msgid "LightApp_Application::PREF_BOTTOM"
-msgstr "Bottom"
-
-msgid "LightApp_Application::PREF_CURVE_TYPE"
-msgstr "Curve type:"
-
-msgid "LightApp_Application::PREF_POINTS"
-msgstr "Points"
-
-msgid "LightApp_Application::PREF_LINES"
-msgstr "Lines"
-
-msgid "LightApp_Application::PREF_SPLINE"
-msgstr "Spline"
-
-msgid "LightApp_Application::PREF_MARKER_SIZE"
-msgstr "Marker size:"
-
-msgid "LightApp_Application::PREF_LINEAR"
-msgstr "Linear"
-
-msgid "LightApp_Application::PREF_LOGARITHMIC"
-msgstr "Logarithmic"
-
-msgid "LightApp_Application::PREF_HOR_AXIS_SCALE"
-msgstr "Horizontal axis scale:"
-
-msgid "LightApp_Application::PREF_VERT_AXIS_SCALE"
-msgstr "Vertical axis scale:"
-
-msgid "LightApp_Application::PREF_TAB_DIRECTORIES"
-msgstr "Directories"
-
-msgid "LightApp_Application::PREF_GROUP_DIRECTORIES"
-msgstr "Quick directory list"
-
-msgid "LightApp_Application::MEN_REFRESH"
-msgstr "Refresh"
-
-msgid "LightApp_Application::PREF_GROUP_SUPERV"
-msgstr "Graph Supervisor"
-
-msgid "LightApp_Application::PREF_SUPERV_TITLE_COLOR"
-msgstr "Title color"
-
-msgid "LightApp_Application::PREF_SUPERV_CTRL_COLOR"
-msgstr "Ctrl color"
-
-msgid "LightApp_Application::PREF_AUTO_SIZE"
-msgstr "Auto size for other columns"
-
-msgid "LightApp_Application::PREF_AUTO_SIZE_FIRST"
-msgstr "Auto size for first column"
-
-//=======================================================================================
-
-msgid "LightApp_PreferencesDlg::CAPTION"
-msgstr "Preferences"
-
-msgid "LightApp_PreferencesDlg::DEFAULT_BTN_TEXT"
-msgstr "Defaults"
-
-msgid "LightApp_PreferencesDlg::WARNING"
-msgstr "Warning"
-
-msgid "LightApp_PreferencesDlg::DEFAULT_QUESTION"
-msgstr "Do you want to retrieve default preferences?"
-
-msgid "LightApp_PreferencesDlg::IMPORT_PREFERENCES"
-msgstr "Import preferences"
-
-msgid "LightApp_PreferencesDlg::IMPORT_BTN_TEXT"
-msgstr "Import"
-
-//=======================================================================================
-
-msgid "LightApp_Module::TOP_DISPLAY"
-msgstr "Display"
-
-msgid "LightApp_Module::MEN_DISPLAY"
-msgstr "Display"
-
-msgid "LightApp_Module::STB_DISPLAY"
-msgstr "Display"
-
-msgid "LightApp_Module::TOP_ERASE"
-msgstr "Erase"
-
-msgid "LightApp_Module::MEN_ERASE"
-msgstr "Erase"
-
-msgid "LightApp_Module::STB_ERASE"
-msgstr "Erase"
-
-msgid "LightApp_Module::TOP_DISPLAY_ONLY"
-msgstr "Display only"
-
-msgid "LightApp_Module::MEN_DISPLAY_ONLY"
-msgstr "Display only"
-
-msgid "LightApp_Module::STB_DISPLAY_ONLY"
-msgstr "Display only"
-
-msgid "LightApp_Module::TOP_ERASE_ALL"
-msgstr "Erase all"
-
-msgid "LightApp_Module::MEN_ERASE_ALL"
-msgstr "Erase all"
-
-msgid "LightApp_Module::STB_ERASE_ALL"
-msgstr "Erase all"
-//=======================================================================================
-
-
-msgid "LightApp_ModuleDlg::CAPTION"
-msgstr "Activate module"
-
-msgid "LightApp_ModuleDlg::NEW"
-msgstr "&New"
-
-msgid "LightApp_ModuleDlg::OPEN"
-msgstr "&Open"
-
-msgid "LightApp_ModuleDlg::LOAD"
-msgstr "&Load"
-
-msgid "LightApp_ModuleDlg::CANCEL"
-msgstr "&Cancel"
-
-msgid "LightApp_ModuleDlg::ActivateComponent_DESCRIPTION"
-msgstr "Create, open or load study."
-
-msgid "LightApp_NameDlg::TLT_RENAME"
-msgstr "Rename"
-
-msgid "LightApp_NameDlg::NAME_LBL"
-msgstr "Name: "
-
+++ /dev/null
-# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-# File : Makefile.in
-# Author : Vladimir Klyachin (OCN)
-# Module : ObjectBrowser
-# $Header$
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@srcdir@/resources
-
-
-@COMMENCE@
-
-# header files
-EXPORT_HEADERS= OB.h \
- OB_Browser.h \
- OB_ListItem.h \
- OB_ListView.h \
- OB_Filter.h
-
-# Libraries targets
-LIB = libObjBrowser.la
-
-LIB_SRC= OB_Browser.cxx \
- OB_ListItem.cxx \
- OB_ListView.cxx \
- OB_Filter.cxx
-
-LIB_MOC = OB_Browser.h \
- OB_ListView.h
-
-# .po files to transform in .qm
-PO_FILES = OB_msg_en.po
-
-CPPFLAGS+=$(QT_INCLUDES)
-
-LDFLAGS+=$(QT_MT_LIBS)
-LIBS+= -lsuit
-
-@CONCLUDE@
-
-