-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
myModule( theModule ),
myPanel( 0 ),
myIsPrintErrorMessage( true ),
+ myIsTransactionOpened( false ),
myPreviewManager( 0 ),
myPreviewZLayer( -1 )
{
*/
void HYDROGUI_Operation::setPreviewManager( OCCViewer_ViewManager* theManager )
{
- if ( !theManager && myPreviewManager )
- module()->getOCCDisplayer()->RemoveZLayer( myPreviewManager, getPreviewZLayer() );
+ //No good: preview Z layer could be used by usual presentations
+ //if ( !theManager && myPreviewManager )
+ // module()->getOCCDisplayer()->RemoveZLayer( myPreviewManager, getPreviewZLayer() );
myPreviewManager = theManager;
if ( myPreviewManager )
- setPreviewZLayer( module()->getOCCDisplayer()->AddTopZLayer( myPreviewManager ) );
+ setPreviewZLayer( module()->getOCCDisplayer()->AddPreviewZLayer( myPreviewManager ) );
}
void HYDROGUI_Operation::startOperation()
// pop the operation from the cached map of active operations
QStack<HYDROGUI_Operation*>& anOperations = myModule->getActiveOperations();
- if ( anOperations.top() == this )
- {
- anOperations.pop();
- }
- else {
- // find in the stack the current operation and remove it from the stack
- QVectorIterator<HYDROGUI_Operation*> aVIt( anOperations );
- aVIt.toBack();
- aVIt.previous(); // skip the top show/hide operation
- while ( aVIt.hasPrevious() )
+ if ( !anOperations.empty() ) {
+ if ( anOperations.top() == this )
+ anOperations.pop();
+ else
{
- HYDROGUI_Operation* anOp = aVIt.previous();
- if ( anOp == this )
- anOperations.remove( anOperations.lastIndexOf( anOp ) );
+ // find in the stack the current operation and remove it from the stack
+ QVectorIterator<HYDROGUI_Operation*> aVIt( anOperations );
+ aVIt.toBack();
+ aVIt.previous(); // skip the top show/hide operation
+ while ( aVIt.hasPrevious() )
+ {
+ HYDROGUI_Operation* anOp = aVIt.previous();
+ if ( anOp == this )
+ anOperations.remove( anOperations.lastIndexOf( anOp ) );
+ }
}
}
// release the preview manager with removing the added preview Z layer
}
bool HYDROGUI_Operation::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
return false;
}
void HYDROGUI_Operation::startDocOperation()
{
- // Open transaction in the model document
+ // Open transaction in the model document only if it not
+ // already opened by other operation (intended for nested operations)
if ( !doc()->IsOperation() )
+ {
doc()->StartOperation();
+ myIsTransactionOpened = true;
+ }
}
void HYDROGUI_Operation::abortDocOperation()
{
- // Abort transaction in the model document
- if ( doc()->IsOperation() )
+ // Abort transaction in the model document only if it was
+ // opened by this operation (intended for nested operations)
+ if ( myIsTransactionOpened && doc()->IsOperation() )
+ {
doc()->AbortOperation();
+ myIsTransactionOpened = false;
+ }
}
void HYDROGUI_Operation::commitDocOperation()
{
- // Commit transaction in the model document
- if ( doc()->IsOperation() )
+ // Commit transaction in the model document only if it was
+ // opened by this operation (intended for nested operations)
+ if ( myIsTransactionOpened && doc()->IsOperation() )
+ {
doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
+ myIsTransactionOpened = false;
+ }
}
Handle_HYDROData_Document HYDROGUI_Operation::doc() const
QString anErrorMsg;
bool aResult = false;
-
+ QStringList aBrowseObjectsEntries;
+
try
{
- aResult = processApply( anUpdateFlags, anErrorMsg );
+ aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
}
catch ( Standard_Failure )
{
module()->update( anUpdateFlags );
commitDocOperation();
commit();
+ browseObjects( aBrowseObjectsEntries );
}
else
{
return QString();
}
-
+void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries )
+{
+ bool isApplyAndClose = true;
+ bool isOptimizedBrowse = true;
+ module()->getApp()->browseObjects( theBrowseObjectsEntries, isApplyAndClose, isOptimizedBrowse );
+}