TGROUP, /*!< A group of families */
TFIELD, /*!< Field represents the results of calculations (it can be scalar or vector values), grouped together under one physical concept. */
TTIMESTAMP, /*!<Time stamp represents a subfield: the results of calculations are taken in one definite moment. */
+ TANIMATION, /*!< Represents Animation object. */
TALL
};
\param theCycle If this boolean parameter is True, playback of your animation will be set as cycling.
*/
void setCycling(in boolean theCycle);
+
+
+ SALOMEDS::SObject publishInStudy();
+
+ void saveAnimation();
+
+ void restoreFromStudy(in SALOMEDS::SObject theSObj);
+
+ boolean isSavedInStudy();
};
/*!
+//************************************************************************
void VisuGUI::TimeAnimation() {
- VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
+ // VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
+ VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetActiveStudy());
SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
bool isDefined = false;
else delete aAnimationDlg;
}
+//************************************************************************
+void VisuGUI::ShowAnimation()
+{
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ if ( Sel->IObjectCount() != 1 )
+ return;
+ SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
+ if( aSObj->_is_nil() ) return;
+
+ VISU::Storable::TRestoringMap aMap;
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
+ SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+ string aComm = aComment->Value();
+ QString strIn(aComm.c_str());
+ VISU::Storable::StrToMap(strIn,aMap);
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if (aType != VISU::TANIMATION) return;
+
+ VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetActiveStudy());
+ aAnimationDlg->restoreFromStudy(aSObj);
+ aAnimationDlg->show();
+}
+
+//************************************************************************
void VisuGUI::ImportMedField() {
if (checkLock(GetStudyDocument())) return;
SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
case VISU::TRESULT:
if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
break;
-
+
case VISU::TTABLE:
if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
if(isExist){
switch (aType) {
+ case VISU::TANIMATION:
+ thePopup->insertItem("Show..", visuGUI, SLOT(ShowAnimation()));
+ if ( !aIsLocked ) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
+ break;
+
case VISU::TENTITY:
case VISU::TFAMILY:
case VISU::TGROUP:
void ClippingPlanes();
void Sweep();
void TimeAnimation();
+ void ShowAnimation();
void ImportMedField();
//void ImportMedMesh();
#include "VisuGUI_TimeAnimation.h"
#include "VisuGUI.h"
+#include "QAD_Study.h"
#include <qlayout.h>
#include <qhbox.h>
static QPixmap MYpausePixmap(pauseIco);
-VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy)
+VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(QAD_Study* theStudyFrame)
: QDialog( QAD_Application::getDesktop(), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
{
setCaption("Animation");
setSizeGripEnabled( TRUE );
- myStudy = theStudy;
+ myStudyFrame = theStudyFrame;
+ myStudy = myStudyFrame->getStudyDocument();
isClosing = false;
- myAnimator = new VISU_TimeAnimation(theStudy);
+ myAnimator = new VISU_TimeAnimation(myStudy);
myAnimator->setSpeed(1);
myAnimator->setViewer(VisuGUI::GetVtkViewFrame());
connect( myAnimator, SIGNAL( frameChanged(long, double) ),
aMainLayout->addWidget(myPlayFrame);
+ QHBox* aPublishBox = new QHBox(this);
+ aPublishBox->setSpacing(5);
+
+ myPublishBtn = new QPushButton("Publish to study", aPublishBox);
+ connect(myPublishBtn, SIGNAL(clicked()), this, SLOT(publishToStudy()));
+
+ mySaveBtn = new QPushButton("Save Animation", aPublishBox);
+ mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
+ connect(mySaveBtn, SIGNAL(clicked()), this, SLOT(saveToStudy()));
+
+ aMainLayout->addWidget(aPublishBox);
+
+
QHBox* aBtnBox = new QHBox(this);
QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
aBtnLayout->addStretch();
myGenBtn->setEnabled(true);
}
}
+
+//************************************************************************
+void VisuGUI_TimeAnimationDlg::saveToStudy()
+{
+ myAnimator->saveAnimation();
+ myStudyFrame->updateObjBrowser( true );
+}
+
+//************************************************************************
+void VisuGUI_TimeAnimationDlg::publishToStudy()
+{
+ myAnimator->publishInStudy();
+ myStudyFrame->updateObjBrowser( true );
+ mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
+}
+
+//************************************************************************
+void VisuGUI_TimeAnimationDlg::restoreFromStudy(SALOMEDS::SObject_var theAnimation)
+{
+ myAnimator->restoreFromStudy(theAnimation);
+ mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
+}
class VISU_TimeAnimation;
class VTKViewer_ViewFrame;
+class QAD_Study;
/**
* Auxilliary class for presentations definition
{
Q_OBJECT
public:
- VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy);
+ VisuGUI_TimeAnimationDlg(QAD_Study* theStudyFrame);
~VisuGUI_TimeAnimationDlg();
void addField(SALOMEDS::SObject_var theField);
void clearView();
+ void restoreFromStudy(SALOMEDS::SObject_var theAnimation);
+
protected:
virtual void closeEvent(QCloseEvent* theEvent);
void stopAnimation();
void onExecution(long theNewFrame, double theTime);
void onBrowse();
void onStop();
+ void saveToStudy();
+ void publishToStudy();
private:
QSlider* mySlider;
QFrame* myPlayFrame;
SALOMEDS::Study_var myStudy;
+ QAD_Study* myStudyFrame;
VISU_TimeAnimation* myAnimator;
QCheckBox* mySaveCheck;
QLineEdit* myPathEdit;
bool isClosing;
QCloseEvent* myEvent;
+
+ QPushButton* myPublishBtn;
+ QPushButton* mySaveBtn;
};
#endif //VISUGUI_TIMEANIMATION_H
VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap)
{
myName = VISU::Storable::FindValue(theMap,"myName").latin1();
+ myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat();
+ myOffset[1] = VISU::Storable::FindValue(theMap,"myOffset[1]").toFloat();
+ myOffset[2] = VISU::Storable::FindValue(theMap,"myOffset[2]").toFloat();
return this;
}
void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){
Storable::DataToStream( theStr, "myName", myName.c_str() );
+ Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
+ Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
+ Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
}
void VISU::Prs3d_i::Update() {
myTimeMax = 0;
myLastError = "";
myCycling = false;
+
+ myAnimSObject = SALOMEDS::SObject::_nil();
}
mySpeed = (theSpeed<1)? 1 : theSpeed;
}
+//************************************************************************
+int VISU_TimeAnimation::myNBAnimations = 0;
+QString VISU_TimeAnimation::GenerateName()
+{
+ return VISU::GenerateName("Animation", myNBAnimations++);
+}
+
+//************************************************************************
+SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
+{
+ if (myStudy->GetProperties()->IsLocked())
+ return myAnimSObject;
+
+ if (!myAnimSObject->_is_nil()) {
+ myAnimSObject = SALOMEDS::SObject::_nil();
+ }
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+ SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(myStudy);
+ CORBA::String_var aSComponentEntry = aSComponent->GetID();
+
+ QString aComment;
+ aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g",VISU::TANIMATION,myMinVal,myMaxVal);
+
+ string anEntry = VISU::CreateAttributes(myStudy,aSComponentEntry.in(),"","", GenerateName(),"",aComment,true);
+ myAnimSObject = myStudy->FindObjectID(anEntry.c_str());
+
+ for (int i = 0; i < getNbFields(); i++) {
+ FieldData& aData = myFieldsLst[i];
+ SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(myAnimSObject);
+ aStudyBuilder->Addreference(newObj, aData.myField);
+ if (!aData.myPrs.empty()) {
+ ostringstream strOut;
+ aData.myPrs[0]->ToStream(strOut);
+ string aPrsComment = strOut.str();
+ VISU::CreateAttributes(myStudy, newObj->GetID(),"","", aData.myPrs[0]->GetComment(),"",aPrsComment.c_str(),true);
+ }
+ }
+ aStudyBuilder->CommitCommand();
+ return myAnimSObject;
+}
+
+//************************************************************************
+void VISU_TimeAnimation::saveAnimation()
+{
+ if (myStudy->GetProperties()->IsLocked()) return ;
+ if (myAnimSObject->_is_nil()) return;
+
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+ SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(myStudy);
+ CORBA::String_var aSComponentEntry = aSComponent->GetID();
+
+ QString aComment;
+ aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g",VISU::TANIMATION,myMinVal,myMaxVal);
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ anAttr = aStudyBuilder->FindOrCreateAttribute(myAnimSObject, "AttributeComment");
+ SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
+ aCmnt->SetValue(aComment);
+
+ SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(myAnimSObject);
+ int i;
+ for (i = 0, anIter->Init(); anIter->More(); anIter->Next(), i++) {
+ SALOMEDS::SObject_var aRefObj = anIter->Value();
+ SALOMEDS::ChildIterator_var anPrsIter = myStudy->NewChildIterator(aRefObj);
+ anPrsIter->Init();
+ if (!anPrsIter->More()) continue;
+ FieldData& aData = myFieldsLst[i];
+ if (aData.myPrs.empty()) continue;
+
+ SALOMEDS::SObject_var aPrsObj = anPrsIter->Value();
+ ostringstream strOut;
+ aData.myPrs[0]->ToStream(strOut);
+ string aPrsComment = strOut.str();
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeComment");
+ aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
+ aCmnt->SetValue(aPrsComment.c_str());
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
+ SALOMEDS::AttributeName_var aPrsName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aPrsName->SetValue(aData.myPrs[0]->GetComment());
+ }
+}
+
+//************************************************************************
+void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
+{
+ myAnimSObject = SALOMEDS::SObject::_duplicate(theField);
+
+ VISU::Storable::TRestoringMap aMap;
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!myAnimSObject->FindAttribute(anAttr, "AttributeComment")) return;
+
+ SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+ string aComm = aComment->Value();
+ QString strIn(aComm.c_str());
+ VISU::Storable::StrToMap(strIn,aMap);
+ bool isExist;
+
+ myMinVal = VISU::Storable::FindValue(aMap,"myMinVal",&isExist).toDouble();
+ myMaxVal = VISU::Storable::FindValue(aMap,"myMaxVal",&isExist).toDouble();
+
+ SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(myAnimSObject);
+ for (anIter->Init(); anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var aRefObj = anIter->Value();
+ SALOMEDS::SObject_var aFieldObj;
+ if (!aRefObj->ReferencedObject(aFieldObj) ) continue;
+ addField(aFieldObj);
+ FieldData& aData = getFieldData(getNbFields()-1);
+
+ SALOMEDS::ChildIterator_var anPrsIter = myStudy->NewChildIterator(aRefObj);
+ anPrsIter->Init();
+ if (!anPrsIter->More()) continue;
+ SALOMEDS::SObject_var aPrsObj = anPrsIter->Value();
+ if (!aPrsObj->FindAttribute(anAttr, "AttributeName")) continue;
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ string aStr = aName->Value();
+ QString strName(aStr.c_str());
+
+ if (strName == VISU::ScalarMap_i::myComment.c_str())
+ aData.myPrsType = VISU::TSCALARMAP;
+ else if (strName == VISU::IsoSurfaces_i::myComment.c_str())
+ aData.myPrsType = VISU::TISOSURFACE;
+ else if (strName == VISU::CutPlanes_i::myComment.c_str())
+ aData.myPrsType = VISU::TCUTPLANES;
+ else if (strName == VISU::DeformedShape_i::myComment.c_str())
+ aData.myPrsType = VISU::TDEFORMEDSHAPE;
+ else if (strName == VISU::Vectors_i::myComment.c_str())
+ aData.myPrsType = VISU::TVECTORS;
+ else if (strName == VISU::StreamLines_i::myComment.c_str())
+ aData.myPrsType = VISU::TSTREAMLINES;
+ else
+ continue;
+ generatePresentations(getNbFields()-1);
+
+ if (!aPrsObj->FindAttribute(anAttr, "AttributeComment")) return;
+ SALOMEDS::AttributeComment_var aPrsComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+ string aPrsComm = aPrsComment->Value();
+ QString strPrsIn(aPrsComm.c_str());
+ VISU::Storable::TRestoringMap aPrsMap;
+ VISU::Storable::StrToMap(strPrsIn,aPrsMap);
+
+ aData.myPrs[0]->Restore(aPrsMap);
+ aData.myPrs[0]->GetOffset(aData.myOffset);
+ for (int i = 1; i < aData.myNbFrames; i++) {
+ aData.myPrs[i]->SameAs(aData.myPrs[0]);
+ }
+ }
+
+}
+
+//========================================================================
+//========================================================================
//========================================================================
VISU_TimeAnimation_i::VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D){
myAnim = new VISU_TimeAnimation(theStudy,theView3D);
}
+SALOMEDS::SObject_ptr VISU_TimeAnimation_i::publishInStudy()
+{
+ return myAnim->publishInStudy();
+}
+
+void VISU_TimeAnimation_i::restoreFromStudy(SALOMEDS::SObject_ptr theObj)
+{
+ myAnim->restoreFromStudy(theObj);
+}
+
+CORBA::Boolean VISU_TimeAnimation_i::isSavedInStudy()
+{
+ return myAnim->isSavedInStudy();
+}
+
+void VISU_TimeAnimation_i::saveAnimation()
+{
+ myAnim->saveAnimation();
+}
void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
+ SALOMEDS::SObject_ptr publishInStudy();
+ void restoreFromStudy(SALOMEDS::SObject_ptr theField);
+ void saveAnimation();
+ bool isSavedInStudy() const { return !myAnimSObject->_is_nil(); }
+
public slots:
void setProportionalSlot(bool theProp) { myProportional = theProp; }
void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
protected:
void run();
+ QString GenerateName();
private:
QString myLastError;
double myTimeMin, myTimeMax;
QString myDumpPath;
VTKViewer_ViewFrame* myView;
+
+ SALOMEDS::SObject_var myAnimSObject;
+
+ static int myNBAnimations;
};
virtual void setProportional(CORBA::Boolean theProp);
virtual void setCycling(CORBA::Boolean theCycle);
+
+ virtual SALOMEDS::SObject_ptr publishInStudy();
+ virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
+ virtual CORBA::Boolean isSavedInStudy();
+ virtual void saveAnimation();
+
};