#include <TDataStd_Integer.hxx>
+#include <TDF_Delta.hxx>
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_Document,MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Document,MMgt_TShared)
myDoc->NewCommand();
}
-void HYDROData_Document::CommitOperation()
+void HYDROData_Document::CommitOperation(const TCollection_ExtendedString& theName)
{
myDoc->CommitCommand();
myTransactionsAfterSave++;
+
+ if( theName.Length() != 0 )
+ {
+ const TDF_DeltaList& aList = GetUndos();
+ if( !aList.IsEmpty() )
+ {
+ Handle(TDF_Delta) aDelta = aList.Last();
+ if( !aDelta.IsNull() )
+ aDelta->SetName( theName );
+ }
+ }
}
void HYDROData_Document::AbortOperation()
return myDoc->GetAvailableUndos() > 0;
}
+const TDF_DeltaList& HYDROData_Document::GetUndos()
+{
+ return myDoc->GetUndos();
+}
+
+void HYDROData_Document::ClearUndos()
+{
+ return myDoc->ClearUndos();
+}
+
void HYDROData_Document::Undo()
{
myDoc->Undo();
return myDoc->GetAvailableRedos() > 0;
}
+const TDF_DeltaList& HYDROData_Document::GetRedos()
+{
+ return myDoc->GetRedos();
+}
+
+void HYDROData_Document::ClearRedos()
+{
+ return myDoc->ClearRedos();
+}
+
void HYDROData_Document::Redo()
{
myDoc->Redo();
//! Starts a new operation (opens a tansaction)
HYDRODATA_EXPORT void StartOperation();
//! Finishes the previously started operation (closes the transaction)
- HYDRODATA_EXPORT void CommitOperation();
+ HYDRODATA_EXPORT void CommitOperation(
+ const TCollection_ExtendedString& theName = TCollection_ExtendedString());
//! Aborts the operation
HYDRODATA_EXPORT void AbortOperation();
//! Returns true if operation has been started, but not yet finished or aborted
//! Returns True if there are available Undos
HYDRODATA_EXPORT bool CanUndo();
+ //! Returns a list of stored undo actions
+ HYDRODATA_EXPORT const TDF_DeltaList& GetUndos();
+ //! Clears a list of stored undo actions
+ HYDRODATA_EXPORT void ClearUndos();
//! Undoes last operation
HYDRODATA_EXPORT void Undo();
+
//! Returns True if there are available Redos
HYDRODATA_EXPORT bool CanRedo();
+ //! Returns a list of stored undo actions
+ HYDRODATA_EXPORT const TDF_DeltaList& GetRedos();
+ //! Clears a list of stored undo actions
+ HYDRODATA_EXPORT void ClearRedos();
//! Redoes last operation
HYDRODATA_EXPORT void Redo();
#include "HYDROGUI_DataModel.h"
-#include "HYDROGUI_Module.h"
#include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROData_Document.h>
+#include <TDF_Delta.hxx>
+#include <TDF_ListIteratorOfDeltaList.hxx>
+
HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
: LightApp_DataModel( theModule )
{
if( !module()->application()->activeStudy() )
return false;
- const int aStudyId = module()->application()->activeStudy()->id();
-
LightApp_DataModel::save( theFileList );
QString aTmpDir;
aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
QString aFullPath = aTmpDir + aFileName;
- Data_DocError res = HYDROData_Document::Document( aStudyId )->Save( (char*)aFullPath.toLatin1().constData() );
+ Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
if( res != DocError_OK )
{
module()->application()->putInfo( tr( "SAVE_ERROR" ) );
return NULL;
}
+bool HYDROGUI_DataModel::canUndo() const
+{
+ return getDocument()->CanUndo();
+}
+
+bool HYDROGUI_DataModel::canRedo() const
+{
+ return getDocument()->CanRedo();
+}
+
+QStringList HYDROGUI_DataModel::undoNames() const
+{
+ QStringList aNames;
+ for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetUndos() ); anIter.More(); anIter.Next() )
+ aNames.prepend( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
+ return aNames;
+}
+
+QStringList HYDROGUI_DataModel::redoNames() const
+{
+ QStringList aNames;
+ for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetRedos() ); anIter.More(); anIter.Next() )
+ aNames.append( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
+ return aNames;
+}
+
+void HYDROGUI_DataModel::clearUndos()
+{
+ getDocument()->ClearUndos();
+}
+
+void HYDROGUI_DataModel::clearRedos()
+{
+ getDocument()->ClearRedos();
+}
+
+bool HYDROGUI_DataModel::undo()
+{
+ try
+ {
+ getDocument()->Undo();
+ }
+ catch ( Standard_Failure )
+ {
+ return false;
+ }
+ return true;
+}
+
+bool HYDROGUI_DataModel::redo()
+{
+ try
+ {
+ getDocument()->Redo();
+ }
+ catch ( Standard_Failure )
+ {
+ return false;
+ }
+ return true;
+}
+
+Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
+{
+ int aStudyId = module()->application()->activeStudy()->id();
+ return HYDROData_Document::Document( aStudyId );
+}
+
LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
Handle(HYDROData_Object) theModelObject )
{
#ifndef HYDROGUI_DATAMODEL_H
#define HYDROGUI_DATAMODEL_H
+#include <HYDROData_Document.h>
#include <HYDROData_Object.h>
#include <QMap>
Handle(HYDROData_Object) objectByEntry( const QString& theEntry,
const ObjectKind theObjectKind );
+ /**
+ * Check if it is possible to perform 'undo' operation
+ */
+ bool canUndo() const;
+ bool canRedo() const;
+
+ /**
+ * Returns the list of names of available 'undo' actions
+ */
+ QStringList undoNames() const;
+ QStringList redoNames() const;
+
+ void clearUndos();
+ void clearRedos();
+
+ bool undo();
+ bool redo();
+
+
protected:
+ /**
+ * Returns the document for the current study
+ */
+ Handle(HYDROData_Document) getDocument() const;
+
/**
* Creates the GUI data object according to the model object.
* \param theParent a created object will be appended as a child of this object
if( GraphicsView_Object* anObject = anIter.next() )
{
aViewPort->removeItem( anObject );
- delete anObject;
+ //delete anObject; // ouv: to do
}
}
}
if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) )
{
aViewPort->removeItem( aPrs );
- delete aPrs;
+ //delete aPrs; // ouv: to do
}
}
}
myPreviewPrs( 0 ),
myPointType( HYDROGUI_PrsImage::None )
{
+ setName( tr( "IMPORT_IMAGE" ) );
}
HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
{
- HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), tr( "IMPORT_IMAGE" ) );
+ HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
connect( aPanel, SIGNAL( createPreview( QString ) ),
this, SLOT( onCreatePreview( QString ) ) );
connect( aPanel, SIGNAL( activatePointSelection( int ) ),
return aPanel;
}
-void HYDROGUI_ImportImageOp::OnApply()
+void HYDROGUI_ImportImageOp::onApply()
{
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
module()->update( UF_Model | UF_Viewer );
}
}
- commit();
+ HYDROGUI_Operation::onApply();
}
-void HYDROGUI_ImportImageOp::OnCancel()
+void HYDROGUI_ImportImageOp::onCancel()
{
closePreview();
- abort();
+ HYDROGUI_Operation::onCancel();
}
void HYDROGUI_ImportImageOp::onCreatePreview( QString theFileName )
virtual HYDROGUI_InputPanel* createInputPanel() const;
protected slots:
- virtual void OnApply();
- virtual void OnCancel();
+ virtual void onApply();
+ virtual void onCancel();
void onCreatePreview( QString );
void onActivatePointSelection( int );
aBtnsLayout->addStretch( 1 );
aBtnsLayout->addWidget( myHelp, 0 );
- connect( myApply, SIGNAL( clicked() ), this, SLOT( OnApply() ) );
- connect( myCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
- connect( myHelp, SIGNAL( clicked() ), this, SLOT( OnHelp() ) );
+ connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
+ connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
+ connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
return myModule;
}
-void HYDROGUI_InputPanel::OnApply()
+void HYDROGUI_InputPanel::onApply()
{
emit panelApply();
}
-void HYDROGUI_InputPanel::OnCancel()
+void HYDROGUI_InputPanel::onCancel()
{
emit panelCancel();
}
-void HYDROGUI_InputPanel::OnHelp()
+void HYDROGUI_InputPanel::onHelp()
{
}
void panelCancel();
protected slots:
- void OnApply();
- void OnCancel();
- void OnHelp();
+ void onApply();
+ void onCancel();
+ void onHelp();
private:
HYDROGUI_Module* myModule;
{
LightApp_Module::initialize( theApp );
- CreateActions();
- CreateMenus();
- CreatePopups();
- CreateToolbars();
+ createActions();
+ createUndoRedoActions();
+ createMenus();
+ createPopups();
+ createToolbars();
setMenuShown( false );
+ setToolShown( false );
myDisplayer = new HYDROGUI_Displayer( this );
}
bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
{
+ bool aRes = LightApp_Module::activateModule( theStudy );
+
setMenuShown( true );
- return LightApp_Module::activateModule( theStudy );
+ setToolShown( true );
+
+ updateCommandsStatus();
+
+ return aRes;
+}
+
+bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
+{
+ setMenuShown( false );
+ setToolShown( false );
+
+ return LightApp_Module::deactivateModule( theStudy );
}
void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
QApplication::restoreOverrideCursor();
}
+void HYDROGUI_Module::updateCommandsStatus()
+{
+ LightApp_Module::updateCommandsStatus();
+
+ updateUndoRedoControls();
+
+ // to do
+ //action( ... )->setEnabled( ... );
+}
+
HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
{
return (HYDROGUI_DataModel*)dataModel();
virtual void viewManagers( QStringList& ) const;
virtual void update( const int );
+ virtual void updateCommandsStatus();
HYDROGUI_DataModel* getDataModel() const;
HYDROGUI_Displayer* getDisplayer() const;
public slots:
virtual bool activateModule( SUIT_Study* );
+ virtual bool deactivateModule( SUIT_Study* );
protected:
virtual LightApp_Operation* createOperation( const int ) const;
protected slots:
void onOperation();
+
+ bool onUndo( int theNumActions );
+ bool onRedo( int theNumActions );
+
virtual void onViewManagerAdded( SUIT_ViewManager* );
virtual void onViewManagerRemoved( SUIT_ViewManager* );
virtual void onViewCreated( SUIT_ViewWindow* );
bool isUpdateEnabled() const;
private:
- void CreateActions();
- void CreateMenus();
- void CreatePopups();
- void CreateToolbars();
+ void createActions();
+ void createMenus();
+ void createPopups();
+ void createToolbars();
+
+ void createUndoRedoActions();
+ void updateUndoRedoControls();
private:
- QAction* CreateAction( const int theId, const QString& theSuffix,
+ QAction* createAction( const int theId, const QString& theSuffix,
const QString& theImg = QString::null,
const int theKey = 0, const bool isToggle = false,
const QString& theSlot = QString::null );
//
#include "HYDROGUI_Operation.h"
-#include "HYDROGUI_Module.h"
+
#include "HYDROGUI_InputPanel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
#include <HYDROData_Document.h>
#include <HYDROData_Iterator.h>
#include <SUIT_Study.h>
HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule )
-: LightApp_Operation(), myModule( theModule ), myPanel( 0 )
+: LightApp_Operation(),
+ myModule( theModule ),
+ myPanel( 0 )
{
}
{
}
+void HYDROGUI_Operation::setName( const QString& theName )
+{
+ myName = theName;
+}
+
+const QString& HYDROGUI_Operation::getName() const
+{
+ return myName;
+}
+
SUIT_SelectionMgr* HYDROGUI_Operation::selectionMgr() const
{
return myModule->getApp()->selectionMgr();
void HYDROGUI_Operation::commitOperation()
{
- doc()->CommitOperation();
+ doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
LightApp_Operation::commitOperation();
if( !myPanel )
{
( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel();
- connect( myPanel, SIGNAL( panelApply() ), this, SLOT( OnApply() ) );
- connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( OnCancel() ) );
+ connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) );
+ connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) );
}
return myPanel;
}
return HYDROData_Document::Document( aStudyId );
}
-void HYDROGUI_Operation::OnApply()
+void HYDROGUI_Operation::onApply()
{
- doc()->CommitOperation();
- inputPanel()->hide();
+ commit();
}
-void HYDROGUI_Operation::OnCancel()
+void HYDROGUI_Operation::onCancel()
{
- doc()->AbortOperation();
- inputPanel()->hide();
+ abort();
}
Handle_HYDROData_Object HYDROGUI_Operation::FindObjectByName( const QString& theName, int theKind ) const
HYDROGUI_Operation( HYDROGUI_Module* theModule );
virtual ~HYDROGUI_Operation();
+ void setName( const QString& theName );
+ const QString& getName() const;
+
HYDROGUI_InputPanel* inputPanel() const;
SUIT_SelectionMgr* selectionMgr() const;
HYDROGUI_Module* module() const;
Handle_HYDROData_Object FindObjectByName( const QString& theName, int theKind ) const;
protected slots:
- virtual void OnApply();
- virtual void OnCancel();
+ virtual void onApply();
+ virtual void onCancel();
private:
HYDROGUI_Module* myModule;
HYDROGUI_InputPanel* myPanel;
+ QString myName;
};
#endif
#include "HYDROGUI_ImportImageOp.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_TwoImagesOp.h"
+#include "HYDROGUI_UpdateFlags.h"
#include <CAM_Application.h>
+#include <QtxListAction.h>
+
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
#include <QAction>
+#include <QApplication>
-QAction* HYDROGUI_Module::CreateAction( const int theId, const QString& theSuffix, const QString& theImg,
+QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffix, const QString& theImg,
const int theKey, const bool isToggle, const QString& theSlot )
{
QString aSlot = theSlot;
if( aSlot.isEmpty() )
aSlot = SLOT( onOperation() );
- SUIT_ResourceMgr* aMgr = application()->resourceMgr();
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
std::string anImg = theImg.toStdString();
- QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aMgr->loadPixmap( "HYDROGUI", tr( anImg.c_str() ) );
+ QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aResMgr->loadPixmap( "HYDRO", tr( anImg.c_str() ) );
std::string aMenu = ( "MEN_" + theSuffix ).toStdString();
std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
}
-void HYDROGUI_Module::CreateActions()
+void HYDROGUI_Module::createActions()
{
- CreateAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
- CreateAction( FuseId, "FUSE_IMAGES" );
- CreateAction( CutId, "CUT_IMAGES" );
+ createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
+ createAction( FuseId, "FUSE_IMAGES" );
+ createAction( CutId, "CUT_IMAGES" );
}
-void HYDROGUI_Module::CreateMenus()
+void HYDROGUI_Module::createMenus()
{
- int aHydroMenuIndex = 6; // Edit menu id == 5, View menu id == 10
- int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenuIndex );
+ int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
+ createMenu( UndoId, anEditMenu );
+ createMenu( RedoId, anEditMenu );
+
+ int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
+ int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
createMenu( ImportImageId, aHydroId, -1, -1 );
createMenu( FuseId, aHydroId, -1, -1 );
createMenu( CutId, aHydroId, -1, -1 );
}
-void HYDROGUI_Module::CreatePopups()
+void HYDROGUI_Module::createPopups()
{
}
-void HYDROGUI_Module::CreateToolbars()
+void HYDROGUI_Module::createToolbars()
{
+ int aToolBar = createTool( tr( "HYDRO_TOOLBAR" ) );
+ createTool( UndoId, aToolBar );
+ createTool( RedoId, aToolBar );
+}
+
+void HYDROGUI_Module::createUndoRedoActions()
+{
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+ QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
+ aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
+ Qt::CTRL + Qt::Key_Z, application()->desktop() );
+
+ QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
+ aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
+ Qt::CTRL + Qt::Key_Y, application()->desktop() );
+
+ registerAction( UndoId, anEditUndo );
+ registerAction( RedoId, anEditRedo );
+
+ anEditUndo->setComment( tr( "STB_UNDO" ) );
+ anEditRedo->setComment( tr( "STB_REDO" ) );
+
+ connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
+ connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
+}
+
+void HYDROGUI_Module::updateUndoRedoControls()
+{
+ HYDROGUI_DataModel* aModel = getDataModel();
+
+ QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
+ QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
+
+ bool aCanUndo = aModel->canUndo();
+ bool aCanRedo = aModel->canRedo();
+
+ if( aCanUndo )
+ aUndoAction->addNames( aModel->undoNames() );
+ aUndoAction->setEnabled( aCanUndo );
+
+ if( aCanRedo )
+ aRedoAction->addNames( aModel->redoNames() );
+ aRedoAction->setEnabled( aCanRedo );
}
void HYDROGUI_Module::onOperation()
startOperation( anId );
}
+bool HYDROGUI_Module::onUndo( int theNumActions )
+{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ bool anIsOk = true;
+ HYDROGUI_DataModel* aModel = getDataModel();
+ if( aModel )
+ {
+ while( theNumActions > 0 )
+ {
+ if( !aModel->undo() )
+ {
+ anIsOk = false;
+ break;
+ }
+ theNumActions--;
+ }
+ update( UF_All | UF_GV_Init | UF_GV_Forced );
+ }
+ QApplication::restoreOverrideCursor();
+ return anIsOk;
+}
+
+bool HYDROGUI_Module::onRedo( int theNumActions )
+{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ bool anIsOk = true;
+ HYDROGUI_DataModel* aModel = getDataModel();
+ if( aModel )
+ {
+ while( theNumActions > 0 )
+ {
+ if( !aModel->redo() )
+ {
+ anIsOk = false;
+ break;
+ }
+ theNumActions--;
+ }
+ update( UF_All | UF_GV_Init | UF_GV_Forced );
+ }
+ QApplication::restoreOverrideCursor();
+ return anIsOk;
+}
+
LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
{
LightApp_Operation* anOp = 0;
anOp = new HYDROGUI_ImportImageOp( aModule );
break;
case FuseId:
- anOp = new HYDROGUI_TwoImagesOp( aModule, tr( "FUSE_OP" ) );
+ anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse );
break;
case CutId:
- anOp = new HYDROGUI_TwoImagesOp( aModule, tr( "CUT_OP" ) );
+ anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut );
break;
}
{
FirstId,
+ UndoId,
+ RedoId,
+
ImportImageId,
FuseId,
CutId,
#include <SUIT_ViewManager.h>
#include <SUIT_ViewWindow.h>
+#include <QTextCodec>
+
+// Definition of this id allows to use 'latin1' (Qt alias for 'ISO-8859-1')
+// encoding instead of default 'System'
+#define USE_LATIN1_ENCODING
+
+QString HYDROGUI_Tool::ToQString( const TCollection_AsciiString& src )
+{
+#ifdef USE_LATIN1_ENCODING
+ QTextCodec* codec = QTextCodec::codecForName( "latin1" ); // alias for ISO-8859-1
+#else
+ QTextCodec* codec = QTextCodec::codecForLocale();
+#endif
+ QString res;
+ if ( !src.IsEmpty() )
+ res = codec ? codec->toUnicode( (char*)src.ToCString(), src.Length() ) :
+ QString( (char*)src.ToCString() );
+ return res;
+}
+
+QString HYDROGUI_Tool::ToQString( const TCollection_ExtendedString& src )
+{
+ return QString( (QChar*)src.ToExtString(), src.Length() );
+}
+
+QString HYDROGUI_Tool::ToQString( const Handle(TCollection_HAsciiString)& src )
+{
+ if( src.IsNull() )
+ return QString();
+ else
+ return ToQString( src->String() );
+}
+
+QString HYDROGUI_Tool::ToQString( const Handle(TCollection_HExtendedString)& src )
+{
+ if( src.IsNull() )
+ return QString();
+ return ToQString( src->String() );
+}
+
+TCollection_AsciiString HYDROGUI_Tool::ToAsciiString( const QString& src )
+{
+ TCollection_AsciiString res;
+ if( !src.isNull() )
+ {
+#ifdef USE_LATIN1_ENCODING
+ QTextCodec* codec = QTextCodec::codecForName( "latin1" ); // alias for ISO-8859-1
+#else
+ QTextCodec* codec = QTextCodec::codecForLocale();
+#endif
+ if( codec )
+ {
+ QByteArray str = codec->fromUnicode( src );
+ res = TCollection_AsciiString( (Standard_CString)str.constData() );
+ }
+ else
+ res = TCollection_AsciiString( src.toLatin1().data() );
+ }
+ return res;
+}
+
+TCollection_ExtendedString HYDROGUI_Tool::ToExtString( const QString& src )
+{
+ if( src.isEmpty() )
+ return TCollection_ExtendedString();
+
+ Standard_Integer len = src.length();
+ Standard_ExtString extStr = new Standard_ExtCharacter[ ( len + 1 ) * 2 ];
+ memcpy( (void*)extStr, src.unicode(), len * 2 );
+ ((short*)extStr)[ len ] = 0;
+
+ TCollection_ExtendedString trg( extStr );
+ delete [] extStr;
+ return trg;
+}
+
+Handle(TCollection_HAsciiString) HYDROGUI_Tool::ToHAsciiString( const QString& src )
+{
+ return new TCollection_HAsciiString( ToAsciiString( src ) );
+}
+
+Handle(TCollection_HExtendedString) HYDROGUI_Tool::ToHExtString( const QString& src )
+{
+ return new TCollection_HExtendedString( ToExtString( src ) );
+}
+
void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
SUIT_ViewManager* theViewManager )
{
aWorkstack->setActiveWindow( aViewWindow );
}
-void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theGUIModel,
+void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theModel,
const int theViewerId, // currently unused
HYDROData_SequenceOfObjects& theSeq )
{
- if( !theGUIModel )
+ if( !theModel )
return;
- const int aStudyId = theGUIModel->module()->application()->activeStudy()->id();
+ const int aStudyId = theModel->module()->application()->activeStudy()->id();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
if( aDocument.IsNull() )
#include <GraphicsView_Defs.h>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TCollection_HExtendedString.hxx>
+
class SUIT_ViewManager;
class HYDROGUI_DataModel;
class HYDROGUI_Tool
{
public:
+ /**
+ * \brief Convert \a TCollection_AsciiString to \a QString
+ */
+ static QString ToQString( const TCollection_AsciiString& );
+
+ /**
+ * \brief Convert \a TCollection_ExtendedString to \a QString
+ */
+ static QString ToQString( const TCollection_ExtendedString& );
+
+ /**
+ * \brief Convert \a Handle_TCollection_HAsciiString to \a QString
+ */
+ static QString ToQString( const Handle(TCollection_HAsciiString)& );
+
+ /**
+ * \brief Convert \a Handle_TCollection_HExtendedString to \a QString
+ */
+ static QString ToQString( const Handle(TCollection_HExtendedString)& );
+
+ /**
+ * \brief Convert \a QString to \a TCollection_AsciiString
+ */
+ static TCollection_AsciiString ToAsciiString( const QString& );
+
+ /**
+ * \brief Convert \a QString to \a TCollection_ExtendedString
+ */
+ static TCollection_ExtendedString ToExtString( const QString& );
+
+ /**
+ * \brief Convert \a QString to \a Handle_TCollection_HAsciiString
+ */
+ static Handle(TCollection_HAsciiString) ToHAsciiString( const QString& );
+
+ /**
+ * \brief Convert \a QString to \a Handle_TCollection_HExtendedString
+ */
+ static Handle(TCollection_HExtendedString) ToHExtString( const QString& );
+
/**
* \brief Set the specified view manager to be active on the desktop.
* \param theModule module
/**
* \brief Get sub-objects to build presentations.
- * \param theGUIModel data model
+ * \param theModel data model
* \param theViewerId viewer id
* \param theSeq sequence of sub-objects
*/
- static void GetPrsSubObjects( const HYDROGUI_DataModel* theGUIModel,
+ static void GetPrsSubObjects( const HYDROGUI_DataModel* theModel,
const int theViewerId,
HYDROData_SequenceOfObjects& theSeq );
#include <HYDROOperations_Factory.h>
-HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const QString& theTitle )
- : HYDROGUI_Operation( theModule ), myTitle( theTitle )
+HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType )
+: HYDROGUI_Operation( theModule ),
+ myType( theType )
{
+ QString aName;
+ switch( myType )
+ {
+ case Fuse: aName = tr( "FUSE" ); break;
+ case Cut: aName = tr( "CUT" ); break;
+ }
+ setName( aName );
}
HYDROGUI_TwoImagesOp::~HYDROGUI_TwoImagesOp()
HYDROGUI_InputPanel* HYDROGUI_TwoImagesOp::createInputPanel() const
{
- return new HYDROGUI_TwoImagesDlg( module(), myTitle );
+ return new HYDROGUI_TwoImagesDlg( module(), getName() );
}
-void HYDROGUI_TwoImagesOp::OnApply()
+void HYDROGUI_TwoImagesOp::onApply()
{
HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
QString aName1, aName2;
Q_OBJECT
public:
- HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const QString& theTitle );
+ enum OperationType { Fuse, Cut };
+
+public:
+ HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType );
virtual ~HYDROGUI_TwoImagesOp();
protected:
virtual HYDROGUI_InputPanel* createInputPanel() const;
protected slots:
- virtual void OnApply();
+ virtual void onApply();
private:
- QString myTitle;
+ int myType;
};
#endif
#ifndef HYDROGUI_UPDATEFLAGS_H
#define HYDROGUI_UPDATEFLAGS_H
+#include <LightApp_UpdateFlags.h>
+
/**
* \enum HYDRO_UpdateFlags
* Enumeration for update flags. First byte is reserved for LightApp_Module.
*/
typedef enum
{
+ UF_All = UF_Forced | UF_Model | UF_Viewer | UF_ObjBrowser | UF_Controls,
UF_GV_Init = 0x00000020, //!< initial update (used with UF_Viewer)
UF_GV_Forced = 0x00000040, //!< to force recomputing all presentations (used with UF_Viewer)
} HYDRO_UpdateFlags;
<source>BROWSE_ICO</source>
<translation>icon_browse.png</translation>
</message>
+ <message>
+ <source>REDO_ICO</source>
+ <translation>icon_redo.png</translation>
+ </message>
+ <message>
+ <source>UNDO_ICO</source>
+ <translation>icon_undo.png</translation>
+ </message>
</context>
</TS>
<source>DSK_IMPORT_IMAGE</source>
<translation>Import image</translation>
</message>
+ <message>
+ <source>DSK_REDO</source>
+ <translation>Redo</translation>
+ </message>
+ <message>
+ <source>DSK_UNDO</source>
+ <translation>Undo</translation>
+ </message>
+ <message>
+ <source>HYDRO_TOOLBAR</source>
+ <translation>HYDRO toolbar</translation>
+ </message>
<message>
<source>MEN_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>MEN_IMPORT_IMAGE</source>
<translation>Import image</translation>
</message>
+ <message>
+ <source>MEN_REDO</source>
+ <translation>Redo</translation>
+ </message>
+ <message>
+ <source>MEN_UNDO</source>
+ <translation>Undo</translation>
+ </message>
<message>
<source>STB_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>STB_IMPORT_IMAGE</source>
<translation>Import image</translation>
</message>
+ <message>
+ <source>STB_REDO</source>
+ <translation>Redo</translation>
+ </message>
+ <message>
+ <source>STB_UNDO</source>
+ <translation>Undo</translation>
+ </message>
+ </context>
+ <context>
+ <name>HYDROGUI_TwoImagesOp</name>
+ <message>
+ <source>CUT</source>
+ <translation>Cut</translation>
+ </message>
+ <message>
+ <source>FUSE</source>
+ <translation>Fuse</translation>
+ </message>
</context>
</TS>