HYDROData.h
HYDROData_Application.h
HYDROData_Document.h
+ HYDROData_Image.h
HYDROData_Iterator.h
HYDROData_Object.h
- HYDROData_Image.h
HYDROData_Polyline.h
+ HYDROData_VisualState.h
)
set(PROJECT_SOURCES
HYDROData_Application.cxx
HYDROData_Document.cxx
+ HYDROData_Image.cxx
HYDROData_Iterator.cxx
HYDROData_Object.cxx
- HYDROData_Image.cxx
HYDROData_Polyline.cxx
+ HYDROData_VisualState.cxx
)
add_definitions(
#include <TDataStd_UAttribute.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
-// tag of the child of my label that contains information about the operator
-static const int TAG_OPERATOR = 1;
-
-// tag of the child of my label that contains information transformation points
-static const int TAG_TRSF_POINTS = 2;
-
static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
const QPointF& thePointCOut)
{
Handle(TDataStd_RealArray) anArray;
- if (!myLab.FindChild(TAG_TRSF_POINTS).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
- anArray = TDataStd_RealArray::Set(myLab.FindChild(TAG_TRSF_POINTS), 1, 12);
+ if (!myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+ anArray = TDataStd_RealArray::Set(myLab.FindChild(DataTag_TrsfPoints), 1, 12);
}
anArray->SetValue(1, thePointAIn.x());
anArray->SetValue(2, thePointAIn.y());
QPointF& thePointCOut)
{
Handle(TDataStd_RealArray) anArray;
- if (myLab.FindChild(TAG_TRSF_POINTS).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+ if (myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
thePointAIn = QPointF( anArray->Value(1), anArray->Value(2) ).toPoint();
thePointBIn = QPointF( anArray->Value(3), anArray->Value(4) ).toPoint();
thePointCIn = QPointF( anArray->Value(5), anArray->Value(6) ).toPoint();
void HYDROData_Image::SetOperatorName(const QString theOpName)
{
- TDataStd_Name::Set(myLab.FindChild(TAG_OPERATOR),
+ TDataStd_Name::Set(myLab.FindChild(DataTag_Operator),
TCollection_ExtendedString(theOpName.toLatin1().constData()));
}
QString HYDROData_Image::OperatorName()
{
Handle(TDataStd_Name) aName;
- if (myLab.FindChild(TAG_OPERATOR).
+ if (myLab.FindChild(DataTag_Operator).
FindAttribute(TDataStd_Name::GetID(), aName)) {
TCollection_AsciiString aStr(aName->Get());
return QString(aStr.ToCString());
void HYDROData_Image::SetArgs(const QByteArray& theArgs)
{
- SaveByteArray(TAG_OPERATOR, theArgs.constData(), theArgs.length());
+ SaveByteArray(DataTag_Operator, theArgs.constData(), theArgs.length());
}
QByteArray HYDROData_Image::Args()
{
int aLen = 0;
- const char* aData = ByteArray(TAG_OPERATOR, aLen);
+ const char* aData = ByteArray(DataTag_Operator, aLen);
if (!aLen)
return QByteArray();
return QByteArray(aData, aLen);
*/
class HYDROData_Image : public HYDROData_Object
{
+protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_Operator, ///< name of the operator that must be executed for image update
+ DataTag_TrsfPoints ///< image transformation points (3 input + 3 output)
+ };
+
public:
DEFINE_STANDARD_RTTI(HYDROData_Image);
#include <HYDROData_Image.h>
#include <HYDROData_Polyline.h>
+#include <HYDROData_VisualState.h>
#include <TDataStd_Name.hxx>
#include <NCollection_DataMap.hxx>
case KIND_POLYLINE:
aResult = new HYDROData_Polyline();
break;
+ case KIND_VISUAL_STATE:
+ aResult = new HYDROData_VisualState();
+ break;
}
if (!aResult.IsNull())
aResult->SetLabel(theLabel);
#include <TDataStd_Name.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_UAttribute.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_BooleanArray.hxx>
+#include <TDataStd_RealArray.hxx>
#include <TDF_CopyLabel.hxx>
-static const Standard_GUID GUID_VISIBILITY("d6a715c5-9c86-4adc-8a6c-13188f3ad94b");
-
IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,MMgt_TShared)
TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
}
-bool HYDROData_Object::GetVisibility() const
+bool HYDROData_Object::IsVisible( const int theViewId ) const
{
- return myLab.IsAttribute(GUID_VISIBILITY);
+ ViewId2VisualStateMap aMap;
+ GetViewId2VisualStateMap( aMap );
+ if( aMap.find( theViewId ) != aMap.end() )
+ {
+ const VisualState& aVisualState = aMap[ theViewId ];
+ return aVisualState.Visibility;
+ }
+ return false;
}
-void HYDROData_Object::SetVisibility(bool theState)
+void HYDROData_Object::SetVisible( const int theViewId,
+ const bool theVal )
{
- if (theState) {
- TDataStd_UAttribute::Set(myLab, GUID_VISIBILITY);
- } else {
- myLab.ForgetAttribute(GUID_VISIBILITY);
- }
+ if( theViewId == 0 )
+ return;
+
+ ViewId2VisualStateMap aMap;
+ GetViewId2VisualStateMap( aMap );
+
+ VisualState& aVisualState = aMap[ theViewId ];
+ aVisualState.Visibility = theVal;
+
+ SetViewId2VisualStateMap( aMap );
}
bool HYDROData_Object::IsRemoved() const
return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
return NULL;
}
+
+void HYDROData_Object::GetViewId2VisualStateMap( ViewId2VisualStateMap& theMap ) const
+{
+ theMap.clear();
+
+ TDF_Label aViewIdLab = myLab.FindChild( DataTag_ViewId );
+ TDF_Label aVisibilityLab = myLab.FindChild( DataTag_Visibility );
+ TDF_Label aTransparencyLab = myLab.FindChild( DataTag_Transparency );
+ TDF_Label aZValueLab = myLab.FindChild( DataTag_ZValue );
+
+ Handle(TDataStd_IntegerArray) aViewIdArray;
+ Handle(TDataStd_BooleanArray) aVisibilityArray;
+ Handle(TDataStd_RealArray) aTransparencyArray;
+ Handle(TDataStd_RealArray) aZValueArray;
+
+ if( !aViewIdLab.FindAttribute( TDataStd_IntegerArray::GetID(), aViewIdArray ) ||
+ !aVisibilityLab.FindAttribute( TDataStd_BooleanArray::GetID(), aVisibilityArray ) ||
+ !aTransparencyLab.FindAttribute( TDataStd_RealArray::GetID(), aTransparencyArray ) ||
+ !aZValueLab.FindAttribute( TDataStd_RealArray::GetID(), aZValueArray ) )
+ return;
+
+ int aSize = qMin( qMin( aViewIdArray->Length(), aVisibilityArray->Length() ),
+ qMin( aTransparencyArray->Length(), aZValueArray->Length() ) );
+ for( int anIndex = 0; anIndex < aSize; anIndex++ )
+ {
+ int aViewId = aViewIdArray->Value( anIndex );
+ VisualState aVisualState;
+ aVisualState.Visibility = aVisibilityArray->Value( anIndex );
+ aVisualState.Transparency = aTransparencyArray->Value( anIndex );
+ aVisualState.ZValue = aZValueArray->Value( anIndex );
+ theMap[ aViewId ] = aVisualState;
+ }
+}
+
+void HYDROData_Object::SetViewId2VisualStateMap( const ViewId2VisualStateMap& theMap )
+{
+ TDF_Label aViewIdLab = myLab.FindChild( DataTag_ViewId );
+ TDF_Label aVisibilityLab = myLab.FindChild( DataTag_Visibility );
+ TDF_Label aTransparencyLab = myLab.FindChild( DataTag_Transparency );
+ TDF_Label aZValueLab = myLab.FindChild( DataTag_ZValue );
+
+ aViewIdLab.ForgetAllAttributes();
+ aVisibilityLab.ForgetAllAttributes();
+ aTransparencyLab.ForgetAllAttributes();
+ aZValueLab.ForgetAllAttributes();
+
+ int aSize = theMap.size();
+
+ Handle(TDataStd_IntegerArray) aViewIdArray =
+ TDataStd_IntegerArray::Set( aViewIdLab, 0, aSize-1 );
+ Handle(TDataStd_BooleanArray) aVisibilityArray =
+ TDataStd_BooleanArray::Set( aVisibilityLab, 0, aSize-1 );
+ Handle(TDataStd_RealArray) aTransparencyArray =
+ TDataStd_RealArray::Set( aTransparencyLab, 0, aSize-1 );
+ Handle(TDataStd_RealArray) aZValueArray =
+ TDataStd_RealArray::Set( aZValueLab, 0, aSize-1 );
+
+ int anIndex = 0;
+ ViewId2VisualStateMapIterator anIter( theMap );
+ while( anIter.hasNext() )
+ {
+ int aViewId = anIter.next().key();
+ const VisualState& aVisualState = anIter.value();
+ aViewIdArray->SetValue( anIndex, aViewId );
+ aVisibilityArray->SetValue( anIndex, aVisualState.Visibility );
+ aTransparencyArray->SetValue( anIndex, aVisualState.Transparency );
+ aZValueArray->SetValue( anIndex, aVisualState.ZValue );
+ anIndex++;
+ }
+}
#include <NCollection_Sequence.hxx>
#include <TDF_Label.hxx>
+#include <QMap>
#include <QString>
///! Kind of an object in a document
const ObjectKind KIND_UNKNOWN = 0;
const ObjectKind KIND_IMAGE = 1;
const ObjectKind KIND_POLYLINE = 2;
+const ObjectKind KIND_VISUAL_STATE = 3;
DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
*/
class HYDROData_Object : public MMgt_TShared
{
+protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = 0, ///< first tag, to reserve
+ DataTag_ViewId, ///< visual state, array of view ids
+ DataTag_Visibility, ///< visual state, array of visibility states
+ DataTag_Transparency, ///< visual state, array of transparency values
+ DataTag_ZValue ///< visual state, array of z-values
+ };
+
+public:
+ /**
+ * Visual state data.
+ */
+ struct VisualState
+ {
+ bool Visibility;
+ double Transparency;
+ double ZValue;
+ VisualState() : Visibility( false ), Transparency( 1.0 ), ZValue( 0.0 ) {}
+ };
+ typedef QMap < int, VisualState > ViewId2VisualStateMap;
+ typedef QMapIterator< int, VisualState > ViewId2VisualStateMapIterator;
+
public:
DEFINE_STANDARD_RTTI(HYDROData_Object);
HYDRODATA_EXPORT void SetName(const QString& theName);
/**
- * Returns the object visibility state.
+ * Returns the object visibility state for the view with specified id.
+ * \param theViewId view id
* \returns visibility state
*/
- HYDRODATA_EXPORT bool GetVisibility() const;
+ HYDRODATA_EXPORT bool IsVisible( const int theViewId ) const;
/**
- * Sets the object visibility state.
- * \param theState visibility state
+ * Sets the object visibility state for the view with specified id.
+ * \param theViewId view id
+ * \param theVal visibility state
*/
- HYDRODATA_EXPORT void SetVisibility(bool theState);
+ HYDRODATA_EXPORT void SetVisible( const int theViewId,
+ const bool theVal );
/**
* Checks is object exists in the data structure.
*/
const char* ByteArray(const int theTag, int& theLen);
+ /**
+ * Returns the map containing the visual states for the specified views.
+ * \param theMap map of visual states
+ */
+ void GetViewId2VisualStateMap( ViewId2VisualStateMap& theMap ) const;
+
+ /**
+ * Sets the map containing the visual states for the specified views.
+ * \param theMap map of visual states
+ */
+ void SetViewId2VisualStateMap( const ViewId2VisualStateMap& theMap );
+
protected:
/// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
TDF_Label myLab; ///< label of this object
// tage of the child of my label that contains information about the operator
static const Standard_GUID GUID_MUST_BE_UPDATED("6647e1f7-1971-4c5a-86c7-11ff0291452d");
-#define TAG_POINTS 1
-#define TAG_SECTIONS_NAME 2
-#define TAG_SECTIONS_CLOSED 3
-#define TAG_SECTIONS_SIZE 4
-#define TAG_SECTIONS_TYPE 5
-
IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline, HYDROData_Object)
int aPointsCnt = 0;
- TDF_Label aNameLab = myLab.FindChild(TAG_SECTIONS_NAME);
+ TDF_Label aNameLab = myLab.FindChild(DataTag_SectionsName);
Handle(TDataStd_ExtStringArray) aSectsNameArray;
aSectsNameArray = TDataStd_ExtStringArray::Set(aNameLab, 0, aSectionsSize-1, false );
- TDF_Label aSizeLab = myLab.FindChild(TAG_SECTIONS_SIZE);
+ TDF_Label aSizeLab = myLab.FindChild(DataTag_SectionsSize);
Handle(TDataStd_IntegerArray) aSizeArray;
aSizeArray = TDataStd_IntegerArray::Set(aSizeLab, 0, aSectionsSize-1, false );
- TDF_Label aClosedLab = myLab.FindChild(TAG_SECTIONS_CLOSED);
+ TDF_Label aClosedLab = myLab.FindChild(DataTag_SectionsClosed);
Handle(TDataStd_BooleanArray) aClosedArray;
aClosedArray = TDataStd_BooleanArray::Set(aClosedLab, 0, aSectionsSize-1 );
- TDF_Label aTypeLab = myLab.FindChild(TAG_SECTIONS_TYPE);
+ TDF_Label aTypeLab = myLab.FindChild(DataTag_SectionsType);
Handle(TDataStd_ByteArray) aTypeArray;
aTypeArray = TDataStd_ByteArray::Set(aTypeLab, 0, aSectionsSize-1, false );
int aSectCnt;
QList<PolylineSection> aRes;
//Get sections size array handle
- TDF_Label aLab = myLab.FindChild( TAG_SECTIONS_SIZE );
+ TDF_Label aLab = myLab.FindChild( DataTag_SectionsSize );
Handle(TDataStd_IntegerArray) aSizeArray;
if (!aLab.FindAttribute(TDataStd_IntegerArray::GetID(), aSizeArray))
return aRes; // return empty if no array
if( aSectCnt == 0 )
return aRes;
//Get section type array handle
- aLab = myLab.FindChild( TAG_SECTIONS_TYPE );
+ aLab = myLab.FindChild( DataTag_SectionsType );
Handle(TDataStd_ByteArray) aTypeArray;
if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aTypeArray))
return aRes;
if( aLen != aSectCnt )
return aRes;
//Get section closed array handle
- aLab = myLab.FindChild( TAG_SECTIONS_CLOSED );
+ aLab = myLab.FindChild( DataTag_SectionsClosed );
Handle(TDataStd_BooleanArray) aClosedArray;
if (!aLab.FindAttribute(TDataStd_BooleanArray::GetID(), aClosedArray))
return aRes;
if( aLen != aSectCnt )
return aRes;
//Get sections names
- TDF_Label aNameLab = myLab.FindChild(TAG_SECTIONS_NAME);
+ TDF_Label aNameLab = myLab.FindChild(DataTag_SectionsName);
Handle(TDataStd_ExtStringArray) aSectNamesArray;
if(!aNameLab.FindAttribute(TDataStd_ExtStringArray::GetID(), aSectNamesArray))
return aRes;
void HYDROData_Polyline::removeAll()
{
//Remove only section data
- TDF_Label aLab = myLab.FindChild( TAG_SECTIONS_SIZE );
+ TDF_Label aLab = myLab.FindChild( DataTag_SectionsSize );
aLab.ForgetAllAttributes();
- aLab = myLab.FindChild( TAG_SECTIONS_TYPE );
+ aLab = myLab.FindChild( DataTag_SectionsType );
aLab.ForgetAllAttributes();
- aLab = myLab.FindChild( TAG_SECTIONS_CLOSED );
+ aLab = myLab.FindChild( DataTag_SectionsClosed );
aLab.ForgetAllAttributes();
myLab.ForgetAttribute(TDataStd_RealArray::GetID());
*/
class HYDROData_Polyline : public HYDROData_Object
{
+protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_SectionsName,
+ DataTag_SectionsClosed,
+ DataTag_SectionsSize,
+ DataTag_SectionsType
+ };
+
public:
DEFINE_STANDARD_RTTI(HYDROData_Polyline);
--- /dev/null
+#include <HYDROData_VisualState.h>
+
+#include <TDataStd_AsciiString.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Object)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_VisualState, HYDROData_Object)
+
+HYDROData_VisualState::HYDROData_VisualState()
+{
+}
+
+HYDROData_VisualState::~HYDROData_VisualState()
+{
+}
+
+void HYDROData_VisualState::SetState( const QString& theState )
+{
+ TCollection_AsciiString aString;
+ Handle(TDataStd_AsciiString) aState;
+ if( !myLab.FindAttribute( TDataStd_AsciiString::GetID(), aState ) )
+ aState = TDataStd_AsciiString::Set( myLab, aString );
+ aString.AssignCat( theState.toLatin1().constData() );
+ aState->Set( aString );
+}
+
+QString HYDROData_VisualState::GetState() const
+{
+ Handle(TDataStd_AsciiString) aState;
+ if( !myLab.FindAttribute( TDataStd_AsciiString::GetID(), aState ) )
+ return QString();
+ return QString( aState->Get().ToCString() );
+}
--- /dev/null
+#ifndef HYDROData_VisualState_HeaderFile
+#define HYDROData_VisualState_HeaderFile
+
+#include <HYDROData_Object.h>
+
+#include <QString>
+
+DEFINE_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Object)
+
+/**\class HYDROData_VisualState
+ * \brief Class that stores/retreives information about the visual state.
+ *
+ * Keeps the visual state as encoded text string.
+ */
+class HYDROData_VisualState : public HYDROData_Object
+{
+protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_State ///< encoded visual state
+ };
+
+public:
+ DEFINE_STANDARD_RTTI(HYDROData_VisualState);
+
+ /**
+ * Returns the kind of this object. Must be redefined in all objects of known type.
+ */
+ HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_VISUAL_STATE; }
+
+ /**
+ * Stores the encoded visual state
+ * \param theState new state
+ */
+ HYDRODATA_EXPORT void SetState( const QString& theState );
+
+ /**
+ * Returns the encoded visual state
+ */
+ HYDRODATA_EXPORT QString GetState() const;
+
+protected:
+
+ friend class HYDROData_Iterator;
+
+ /**
+ * Creates new object in the internal data structure. Use higher level objects
+ * to create objects with real content.
+ */
+ HYDROData_VisualState();
+
+ /**
+ * Destructs properties of the object and object itself, removes it from the document.
+ */
+ ~HYDROData_VisualState();
+
+};
+
+#endif
HYDROGUI_TwoImagesDlg.h
HYDROGUI_TwoImagesOp.h
HYDROGUI_UpdateFlags.h
+ HYDROGUI_VisualStateOp.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_Tool.cxx
HYDROGUI_TwoImagesDlg.cxx
HYDROGUI_TwoImagesOp.cxx
+ HYDROGUI_VisualStateOp.cxx
)
add_definitions(
#include <HYDROData_Image.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_Polyline.h>
+#include <HYDROData_VisualState.h>
#include <CAM_Application.h>
#include <CAM_DataObject.h>
LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, "POLYLINES" );
- HYDROData_Iterator aPolyIterator( aDocument, KIND_POLYLINE );
- for( ; aPolyIterator.More(); aPolyIterator.Next() )
+ anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
+ for( ; anIterator.More(); anIterator.Next() )
{
Handle(HYDROData_Polyline) aPolylineObj =
- Handle(HYDROData_Polyline)::DownCast( aPolyIterator.Current() );
+ Handle(HYDROData_Polyline)::DownCast( anIterator.Current() );
if( !aPolylineObj.IsNull() )
createObject( aPolylineRootObj, aPolylineObj );
}
+ LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, "VISUAL_STATES" );
+
+ anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_VisualState) aVisualStateObj =
+ Handle(HYDROData_VisualState)::DownCast( anIterator.Current() );
+ if( !aVisualStateObj.IsNull() )
+ createObject( aVisualStateRootObj, aVisualStateObj );
+ }
+
if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
{
anObjectBrowser->setAutoOpenLevel( 3 );
const bool theIsForced )
{
HYDROData_SequenceOfObjects aSeq;
- HYDROGUI_Tool::GetPrsSubObjects( myModule, theViewerId, aSeq );
+ HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
Update( aSeq, theViewerId, theIsForced );
}
if( aPrs )
{
- bool anIsVisible = anObj->GetVisibility();
+ bool anIsVisible = anObj->IsVisible( (int)aViewer );
aPrs->setVisible( anIsVisible );
}
}
}
}
+ if( !myPreviewPrs )
+ return false;
+
QImage anImage = myPreviewPrs->getImage();
+ closePreview();
+
HYDROGUI_ImportImageDlg::TransformationDataMap aMap;
bool anIsOk = aPanel->getTransformationDataMap( aMap );
- if( !anIsOk || !myPreviewPrs )
+ if( !anIsOk )
return false;
QPoint aPointA1 = aMap[ HYDROGUI_PrsImage::PointA ].first;
anImageObj->SetTrsfPoints( aPointA1, aPointB1, aPointC1,
aPointA2, aPointB2, aPointC2 );
- anImageObj->SetVisibility( true );
+ anImageObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
return true;
{
HYDROGUI_DataModel* aModel = getDataModel();
+ int aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( this );
+
bool anIsSelection = false;
bool anIsVisibleInSelection = false;
bool anIsHiddenInSelection = false;
bool anIsImage = false;
bool anIsPolyline = false;
+ bool anIsVisualState = false;
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
anIsSelection = true;
- bool aVisibility = anObject->GetVisibility();
+ bool aVisibility = anObject->IsVisible( aViewId );
anIsVisibleInSelection |= aVisibility;
anIsHiddenInSelection |= !aVisibility;
if( anObject->GetKind() == KIND_IMAGE )
anIsImage = true;
-
- if( anObject->GetKind() == KIND_POLYLINE )
+ else if( anObject->GetKind() == KIND_POLYLINE )
anIsPolyline = true;
+ else if( anObject->GetKind() == KIND_VISUAL_STATE )
+ anIsVisualState = true;
}
}
- if( aSeq.Length() == 1 )
+ if( aSeq.IsEmpty() )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsSelection && aSeq.Length() == 1 )
{
if( anIsImage )
{
theMenu->addAction( action( EditPolylineId ) );
theMenu->addSeparator();
}
+ else if( anIsVisualState )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addAction( action( LoadVisualStateId ) );
+ theMenu->addSeparator();
+ }
}
if( anIsSelection )
theMenu->addSeparator();
}
- if( anIsSelection )
+ if( anIsSelection && ( anIsImage || anIsPolyline ) )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
theMenu->addAction( action( HideId ) );
theMenu->addSeparator();
}
+
theMenu->addAction( action( ShowAllId ) );
theMenu->addAction( action( HideAllId ) );
theMenu->addSeparator();
#include "HYDROGUI_ShowHideOp.h"
#include "HYDROGUI_TwoImagesOp.h"
#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_VisualStateOp.h"
#include <CAM_Application.h>
void HYDROGUI_Module::createActions()
{
+ createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
+ createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
+
createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
createAction( EditImageId, "EDIT_IMAGE" );
createAction( ObserveImageId, "OBSERVE_IMAGE" );
void HYDROGUI_Module::createMenus()
{
+ int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
+ int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
+ createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
+ createMenu( separator(), aFileMenu, -1, aCustomPos );
+
int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
createMenu( UndoId, anEditMenu );
createMenu( RedoId, anEditMenu );
HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
switch( theId )
{
+ case SaveVisualStateId:
+ case LoadVisualStateId:
+ anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
+ break;
case ImportImageId:
case EditImageId:
anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId );
enum OperationId
{
FirstId = 0,
+ SaveVisualStateId,
+ LoadVisualStateId,
UndoId,
RedoId,
ImportImageId,
aPolylineObj->setPolylineData(aPolylineData);
theUpdateFlags = UF_Model;
- aPolylineObj->SetVisibility( true );
+ aPolylineObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
return true;
}
{
HYDROGUI_Operation::startOperation();
+ int aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+
// for all objects
if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId )
{
{
Handle(HYDROData_Object) anObject = anIterator.Current();
if( !anObject.IsNull() )
- anObject->SetVisibility( aVisibility );
+ anObject->SetVisible( aViewId, aVisibility );
}
}
{
Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
if( !anObject.IsNull() )
- anObject->SetVisibility( aVisibility ? true : false );
+ anObject->SetVisible( aViewId, aVisibility );
}
}
#include <HYDROData_Document.h>
#include <HYDROData_Iterator.h>
+#include <GraphicsView_Viewer.h>
+
#include <LightApp_Application.h>
#include <LightApp_DataOwner.h>
#include <LightApp_SelectionMgr.h>
}
void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
- const int theViewerId, // currently unused
HYDROData_SequenceOfObjects& theSeq )
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
if( aDocument.IsNull() )
return;
- HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
+ HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Object) anObject = anIterator.Current();
+ if( !anObject.IsNull() )
+ theSeq.Append( anObject );
+ }
+
+ anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
for( ; anIterator.More(); anIterator.Next() )
{
Handle(HYDROData_Object) anObject = anIterator.Current();
}
return aName;
}
+
+int HYDROGUI_Tool::GetActiveGraphicsViewId( HYDROGUI_Module* theModule )
+{
+ int aViewId = 0;
+ SUIT_ViewManager* aViewMgr = theModule->getApp()->activeViewManager();
+ if( !aViewMgr || aViewMgr->getType() != GraphicsView_Viewer::Type() )
+ return aViewId;
+
+ if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
+ aViewId = (int)aViewer;
+ return aViewId;
+}
+
+QList<int> HYDROGUI_Tool::GetGraphicsViewIdList( HYDROGUI_Module* theModule )
+{
+ QList<int> aList;
+ ViewManagerList aViewMgrs;
+ theModule->getApp()->viewManagers( GraphicsView_Viewer::Type(), aViewMgrs );
+ QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
+ while( anIter.hasNext() )
+ {
+ if( SUIT_ViewManager* aViewMgr = anIter.next() )
+ {
+ if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
+ aList.append( (int)aViewer );
+ }
+ }
+ return aList;
+}
/**
* \brief Get sub-objects to build presentations.
* \param theModule module
- * \param theViewerId viewer id
* \param theSeq sequence of sub-objects
*/
static void GetPrsSubObjects( HYDROGUI_Module* theModule,
- const int theViewerId,
HYDROData_SequenceOfObjects& theSeq );
/**
*/
static QString GenerateObjectName( HYDROGUI_Module* theModule,
const QString& thePrefix );
+
+ /**
+ * \brief Get id of the active GraphicsView view.
+ * \param theModule module
+ * \return view id
+ */
+ static int GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
+
+ /**
+ * \brief Get list of ids of existing GraphicsView views.
+ * \param theModule module
+ * \return list of view ids
+ */
+ static QList<int> GetGraphicsViewIdList( HYDROGUI_Module* theModule );
};
#endif
aResult->AppendReference( anImage2 );
aFactory->UpdateImage( doc(), aResult );
- anImage1->SetVisibility( false );
- anImage2->SetVisibility( false );
- aResult->SetVisibility( true );
+ int aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+ anImage1->SetVisible( aViewId, false );
+ anImage2->SetVisible( aViewId, false );
+ aResult->SetVisible( aViewId, true );
theUpdateFlags = UF_Model | UF_Viewer;
return true;
--- /dev/null
+// Copyright (C) 2007-2013 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.
+//
+// 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 "HYDROGUI_VisualStateOp.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_VisualState.h>
+
+#include <GraphicsView_Viewer.h>
+
+#include <LightApp_Application.h>
+
+#include <QtxWorkstack.h>
+
+#include <STD_TabDesktop.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
+
+#include <QApplication.h>
+
+HYDROGUI_VisualStateOp::HYDROGUI_VisualStateOp( HYDROGUI_Module* theModule,
+ const bool theIsLoad )
+: HYDROGUI_Operation( theModule ),
+ myIsLoad( theIsLoad )
+{
+ setName( theIsLoad ? tr( "LOAD_VISUAL_STATE" ) : tr( "SAVE_VISUAL_STATE" ) );
+}
+
+HYDROGUI_VisualStateOp::~HYDROGUI_VisualStateOp()
+{
+}
+
+void HYDROGUI_VisualStateOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ bool aResult = false;
+ if( myIsLoad )
+ aResult = loadVisualState();
+ else
+ aResult = saveVisualState();
+
+ if( aResult )
+ commit();
+ else
+ abort(); // do not commit the document command
+}
+
+bool HYDROGUI_VisualStateOp::saveVisualState()
+{
+ LightApp_Application* anApp = module()->getApp();
+
+ Handle(HYDROData_VisualState) aVisualState =
+ Handle(HYDROData_VisualState)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( aVisualState.IsNull() )
+ {
+ // Create new visual state
+ aVisualState = Handle(HYDROData_VisualState)::DownCast( doc()->CreateObject( KIND_VISUAL_STATE ) );
+ if( aVisualState.IsNull() )
+ return false;
+
+ QString aName = HYDROGUI_Tool::GenerateObjectName( module(), "VisualState" );
+ aVisualState->SetName( aName );
+ }
+
+ // Store parameters.
+ PropertyMap aPropertyMap;
+
+ // A. Setting unique names for view windows in order to save this view inside
+ // workstack's structure (see below). On restore the views with the same names will
+ // be placed to the same place inside the workstack's splitters.
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers( aViewManagerList );
+ nameViewWindows( aViewManagerList );
+
+ // B. Store active window.
+ if( SUIT_ViewWindow* aViewWindow = anApp->desktop()->activeWindow() )
+ setVisualProperty( aPropertyMap, "AP_ACTIVE_VIEW", aViewWindow->objectName() );
+
+ // C. Store view properties.
+ int aViewerId = 0;
+ QListIterator<SUIT_ViewManager*> anIter( aViewManagerList );
+ while( anIter.hasNext() )
+ {
+ if( SUIT_ViewManager* aViewManager = anIter.next() )
+ {
+ int aViewId = (int)aViewManager->getViewModel();
+ if( SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView() )
+ {
+ QString aType = aViewManager->getType();
+ QString aViewerEntry = QString( "%1_%2" ).arg( aType ).arg( ++aViewerId );
+ setVisualProperty( aPropertyMap, "AP_VIEWERS_LIST", aViewerEntry, true );
+
+ setVisualProperty( aPropertyMap, aViewerEntry, aViewWindow->windowTitle(), true );
+ setVisualProperty( aPropertyMap, aViewerEntry, aViewWindow->getVisualParameters(), true );
+
+ // C1. Store parameters of presentations.
+ HYDROData_SequenceOfObjects aSeq;
+ if( aType == GraphicsView_Viewer::Type() )
+ HYDROGUI_Tool::GetPrsSubObjects( module(), aSeq );
+
+ for( int anObjIndex = 1, aLength = aSeq.Length(); anObjIndex <= aLength; anObjIndex++ )
+ {
+ Handle(HYDROData_Object) anObject = aSeq.Value( anObjIndex );
+ if( !anObject.IsNull() )
+ {
+ // Format: "Name|Visibility[|CoordX|CoordY]"
+ QString aParameters = anObject->GetName();
+
+ int aVisibility = (int)anObject->IsVisible( aViewId );
+ aParameters.append( QString( "|%1" ).arg( aVisibility ) );
+
+ setVisualProperty( aPropertyMap, aViewerEntry, aParameters, true );
+ }
+ }
+ }
+ }
+ }
+
+ // D. Store split areas.
+ if( anApp->desktop()->inherits( "STD_TabDesktop" ) )
+ {
+ QtxWorkstack* aWorkstack = ( (STD_TabDesktop*)anApp->desktop() )->workstack();
+ QByteArray aWorkstackState = aWorkstack->saveState( 0 );
+ QString aWorkstackInfo = aWorkstackState.toHex();
+ setVisualProperty( aPropertyMap, "AP_WORKSTACK_INFO", aWorkstackInfo );
+ }
+
+ // E. Store module preferences.
+ //ouv: currently, nothing to do
+
+ QString aState = encodePropertyMap( aPropertyMap );
+ //printf( "--- SetState -----------\n" );
+ //printf( "%s\n", qPrintable( aState ) );
+ //printf( "------------------------\n" );
+ aVisualState->SetState( aState );
+
+ module()->update( UF_Model );
+
+ return true;
+}
+
+bool HYDROGUI_VisualStateOp::loadVisualState()
+{
+ LightApp_Application* anApp = module()->getApp();
+
+ Handle(HYDROData_VisualState) aVisualState =
+ Handle(HYDROData_VisualState)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( aVisualState.IsNull() )
+ return false;
+
+ QString aState = aVisualState->GetState();
+ //printf( "--- GetState -----------\n" );
+ //printf( "%s\n", qPrintable( aState ) );
+ //printf( "------------------------\n" );
+ PropertyMap aPropertyMap = decodePropertyMap( aState );
+
+ // Restore parameters.
+
+ // Preparation. Remove the existing viewers.
+ anApp->clearViewManagers();
+
+ // E. Restore module preferences
+ //ouv: currently, nothing to do
+
+ // C. Restore view properties (step 1).
+ QMap<SUIT_ViewWindow*, QString> aViewParameters;
+ int aNbViewers = nbVisualProperties( aPropertyMap, "AP_VIEWERS_LIST" );
+ for( int anIndex = 0; anIndex < aNbViewers; anIndex++ )
+ {
+ QString aViewerEntry = getVisualProperty( aPropertyMap, "AP_VIEWERS_LIST", anIndex );
+ QString aType = aViewerEntry.section( '_', 0, -2 );
+ QString aViewerId = aViewerEntry.section( '_', -1 ); // unused
+ if( SUIT_ViewManager* aViewManager = anApp->createViewManager( aType ) )
+ {
+ int aViewId = (int)aViewManager->getViewModel();
+ if( SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView() )
+ {
+ // Wait until the window is really shown. This step fixes MANY bugs.
+ //while( !aViewManager->isVisible() )
+ // qApp->processEvents();
+
+ int aNbViewerProps = nbVisualProperties( aPropertyMap, aViewerEntry );
+
+ aViewWindow->setWindowTitle( getVisualProperty( aPropertyMap, aViewerEntry, 0 ) );
+
+ // Parameters of view windows are restoring after the workstack (see below).
+ aViewParameters[ aViewWindow ] = getVisualProperty( aPropertyMap, aViewerEntry, 1 );
+
+ // C1. Restore parameters of presentations.
+ QMap< QString, QStringList > anObject2ParametersMap;
+ for( int aPropIndex1 = 2; aPropIndex1 < aNbViewerProps; aPropIndex1++ )
+ {
+ QString aProperty = getVisualProperty( aPropertyMap, aViewerEntry, aPropIndex1 );
+ QStringList aParameters = aProperty.split( "|" );
+ if( aParameters.count() > 1 )
+ {
+ QString aName = aParameters.front();
+ aParameters.pop_front();
+ anObject2ParametersMap[ aName ] = aParameters;
+ }
+ }
+
+ HYDROData_SequenceOfObjects aSeq;
+ if( aType == GraphicsView_Viewer::Type() )
+ HYDROGUI_Tool::GetPrsSubObjects( module(), aSeq );
+
+ for( int anObjIndex = 1, aLength = aSeq.Length(); anObjIndex <= aLength; anObjIndex++ )
+ {
+ Handle(HYDROData_Object) anObject = aSeq.Value( anObjIndex );
+ if( !anObject.IsNull() )
+ {
+ QString aName = anObject->GetName();
+ if( anObject2ParametersMap.find( aName ) != anObject2ParametersMap.end() )
+ {
+ QStringList aParameters = anObject2ParametersMap[ aName ];
+ int aParamCount = aParameters.count();
+ QVector<bool> anIsOk( aParamCount, false );
+
+ int aParamIndex = -1;
+ if( aParamCount - aParamIndex - 1 >= 1 )
+ {
+ bool anIsVisible = aParameters[ aParamIndex ].toInt( &anIsOk[ ++aParamIndex ] );
+ if( anIsOk[ 0 ] )
+ anObject->SetVisible( aViewId, anIsVisible );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // A. Setting unique names for view windows in order to restore positions of view windows inside
+ // workstack's structure (see below). During save the same naming algorithm was used,
+ // so the same views will get the same names.
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers( aViewManagerList );
+ nameViewWindows( aViewManagerList );
+
+ qApp->processEvents();
+
+ // D. Restore split areas.
+ QtxWorkstack* aWorkstack = 0;
+ if( anApp->desktop()->inherits( "STD_TabDesktop" ) )
+ {
+ if( aWorkstack = ((STD_TabDesktop*)anApp->desktop())->workstack() )
+ {
+ QString aWorkstackInfo = getVisualProperty( aPropertyMap, "AP_WORKSTACK_INFO" );
+ QByteArray aWorkstackState = QByteArray::fromHex( aWorkstackInfo.toLatin1() );
+ aWorkstack->restoreState( aWorkstackState, 0 );
+ }
+ }
+
+ qApp->processEvents();
+
+ // C. Restore view properties (step 2).
+ // B. Restore active window. (currently doesn't work)
+ QString anActiveViewName = getVisualProperty( aPropertyMap, "AP_ACTIVE_VIEW" );
+ QMap<SUIT_ViewWindow*, QString>::Iterator aMapIter;
+ for( aMapIter = aViewParameters.begin(); aMapIter != aViewParameters.end(); ++aMapIter )
+ {
+ if( SUIT_ViewWindow* aViewWindow = aMapIter.key() )
+ {
+ aViewWindow->setVisualParameters( aMapIter.value() );
+ if( anActiveViewName == aViewWindow->objectName() )
+ if( aWorkstack )
+ aWorkstack->setActiveWindow( aViewWindow );
+ }
+ }
+
+ module()->update( UF_Viewer );
+
+ return true;
+}
+
+void HYDROGUI_VisualStateOp::nameViewWindows( const ViewManagerList& theList )
+{
+ QMap<QString, int> aViewersCounter;
+ for( ViewManagerList::const_iterator anIter = theList.begin(); anIter != theList.end(); ++anIter )
+ {
+ SUIT_ViewManager* aViewManager = *anIter;
+ if( !aViewManager )
+ continue;
+
+ int aViewCount = aViewManager->getViewsCount();
+ QString aType = aViewManager->getType();
+ if( !aViewCount )
+ continue;
+
+ if( !aViewersCounter.contains( aType ) )
+ aViewersCounter.insert( aType, 0 );
+
+ int& aViewerId = aViewersCounter[ aType ];
+
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for( int i = 0; i < aViewCount; i++ )
+ {
+ QString aName = QString( "%1_%2_%3" ).arg( aType ).arg( aViewerId ).arg( i );
+ aViews[i]->setObjectName( aName );
+ }
+ aViewerId++;
+ }
+}
+
+QString HYDROGUI_VisualStateOp::encodePropertyMap( const PropertyMap& thePropertyMap )
+{
+ QStringList aPropertyDataStringList;
+ PropertyMapIterator anIter( thePropertyMap );
+ while( anIter.hasNext() )
+ {
+ QString aPropertyName = anIter.next().key();
+ QStringList aPropertyData = anIter.value();
+
+ if( !aPropertyData.isEmpty() )
+ {
+ aPropertyData.prepend( aPropertyName );
+ QString aPropertyDataString = aPropertyData.join( "||" );
+ aPropertyDataStringList.append( aPropertyDataString );
+ }
+ }
+
+ QString aResult = aPropertyDataStringList.join( "|||" );
+ return aResult;
+}
+
+HYDROGUI_VisualStateOp::PropertyMap
+HYDROGUI_VisualStateOp::decodePropertyMap( const QString& theString )
+{
+ PropertyMap aPropertyMap;
+ QStringList aPropertyDataStringList = theString.split( "|||" );
+ QStringListIterator anIter( aPropertyDataStringList );
+ while( anIter.hasNext() )
+ {
+ QString aPropertyDataString = anIter.next();
+ QStringList aPropertyData = aPropertyDataString.split( "||" );
+ if( aPropertyData.count() >= 2 )
+ {
+ QString aPropertyName = aPropertyData.front();
+ aPropertyData.pop_front();
+ aPropertyMap[ aPropertyName ] = aPropertyData;
+ }
+ }
+ return aPropertyMap;
+}
+
+void HYDROGUI_VisualStateOp::setVisualProperty( PropertyMap& thePropertyMap,
+ const QString& thePropertyName,
+ const QString& thePropertyData,
+ const bool theIsAppend )
+{
+ QStringList& aPropertyDataList = thePropertyMap[ thePropertyName ];
+ if( !theIsAppend )
+ aPropertyDataList.clear();
+ aPropertyDataList.append( thePropertyData );
+}
+
+QString HYDROGUI_VisualStateOp::getVisualProperty( const PropertyMap& thePropertyMap,
+ const QString& thePropertyName,
+ int theIndex )
+{
+ PropertyMap::const_iterator anIter = thePropertyMap.find( thePropertyName );
+ if( anIter != thePropertyMap.end() )
+ {
+ const QStringList aPropertyData = anIter.value();
+ if( theIndex >= 0 && theIndex < aPropertyData.count() )
+ return aPropertyData[ theIndex ];
+ }
+ return QString();
+}
+
+int HYDROGUI_VisualStateOp::nbVisualProperties( const PropertyMap& thePropertyMap,
+ const QString& thePropertyName )
+{
+ PropertyMap::const_iterator anIter = thePropertyMap.find( thePropertyName );
+ if( anIter != thePropertyMap.end() )
+ {
+ const QStringList aPropertyData = anIter.value();
+ return aPropertyData.count();
+ }
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2007-2013 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.
+//
+// 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 HYDROGUI_VISUALSTATEOP_H
+#define HYDROGUI_VISUALSTATEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <STD_Application.h>
+
+class HYDROGUI_VisualStateOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_VisualStateOp( HYDROGUI_Module* theModule, const bool theIsLoad );
+ virtual ~HYDROGUI_VisualStateOp();
+
+protected:
+ virtual void startOperation();
+
+protected:
+ bool saveVisualState();
+ bool loadVisualState();
+
+private:
+ static void nameViewWindows( const ViewManagerList& lst );
+
+ typedef QMap < QString, QStringList > PropertyMap;
+ typedef QMapIterator< QString, QStringList > PropertyMapIterator;
+ static QString encodePropertyMap( const PropertyMap& thePropertyMap );
+ static PropertyMap decodePropertyMap( const QString& theString );
+
+ static void setVisualProperty( PropertyMap& thePropertyMap,
+ const QString& thePropertyName,
+ const QString& thePropertyData,
+ const bool theIsAppend = false );
+
+ static QString getVisualProperty( const PropertyMap& thePropertyMap,
+ const QString& thePropertyName,
+ int theIndex = 0 );
+
+ static int nbVisualProperties( const PropertyMap& thePropertyMap,
+ const QString& thePropertyName );
+
+private:
+ bool myIsLoad;
+};
+
+#endif
<source>DSK_IMPORT_IMAGE</source>
<translation>Import image</translation>
</message>
+ <message>
+ <source>DSK_LOAD_VISUAL_STATE</source>
+ <translation>Load visual state</translation>
+ </message>
<message>
<source>DSK_OBSERVE_IMAGE</source>
<translation>Observe image</translation>
<source>DSK_REDO</source>
<translation>Redo</translation>
</message>
+ <message>
+ <source>DSK_SAVE_VISUAL_STATE</source>
+ <translation>Save visual state</translation>
+ </message>
<message>
<source>DSK_SHOW</source>
<translation>Show</translation>
<source>MEN_IMPORT_IMAGE</source>
<translation>Import image</translation>
</message>
+ <message>
+ <source>MEN_LOAD_VISUAL_STATE</source>
+ <translation>Load visual state</translation>
+ </message>
<message>
<source>MEN_OBSERVE_IMAGE</source>
<translation>Observe image</translation>
<source>MEN_REDO</source>
<translation>Redo</translation>
</message>
+ <message>
+ <source>MEN_SAVE_VISUAL_STATE</source>
+ <translation>Save visual state</translation>
+ </message>
<message>
<source>MEN_SHOW</source>
<translation>Show</translation>
<source>STB_IMPORT_IMAGE</source>
<translation>Import image</translation>
</message>
+ <message>
+ <source>STB_LOAD_VISUAL_STATE</source>
+ <translation>Load visual state</translation>
+ </message>
<message>
<source>STB_OBSERVE_IMAGE</source>
<translation>Observe image</translation>
<source>STB_REDO</source>
<translation>Redo</translation>
</message>
+ <message>
+ <source>STB_SAVE_VISUAL_STATE</source>
+ <translation>Save visual state</translation>
+ </message>
<message>
<source>STB_SHOW</source>
<translation>Show</translation>
<translation>Observe image</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_PolylineDlg</name>
+ <message>
+ <source>CURVE_NAME_TLT</source>
+ <translation>Name</translation>
+ </message>
+ </context>
<context>
<name>HYDROGUI_TwoImagesDlg</name>
<message>
</message>
</context>
<context>
- <name>HYDROGUI_PolylineDlg</name>
+ <name>HYDROGUI_VisualStateOp</name>
<message>
- <source>CURVE_NAME_TLT</source>
- <translation>Name</translation>
+ <source>LOAD_VISUAL_STATE</source>
+ <translation>Load visual state</translation>
+ </message>
+ <message>
+ <source>SAVE_VISUAL_STATE</source>
+ <translation>Save visual state</translation>
</message>
</context>
</TS>