DoHook();
ColoredPrs3d_i* anOrigin = const_cast<ColoredPrs3d_i*>(aPrs3d);
-
- myField = anOrigin->GetField();
- myMeshName = myField->myMeshName;
- myEntity = VISU::TEntity(anOrigin->GetEntity());//myField->myEntity;
- myIteration = anOrigin->GetIteration();
- myFieldName = anOrigin->GetFieldName();
-
+ if(myMeshName == ""){
+ myField = anOrigin->GetField();
+ myMeshName = myField->myMeshName;
+ myEntity = VISU::TEntity(anOrigin->GetEntity());//myField->myEntity;
+ myIteration = anOrigin->GetIteration();
+ myFieldName = anOrigin->GetFieldName();
+ }
Build(-1);
TSuperClass::SameAs(theOrigin);
void
VISU::ColoredPrs3d_i
-::SameAsParams(const ColoredPrs3d_i* theOrigin)
+::SameAsParams(const ColoredPrs3d_i* theOrigin,
+ const std::string& theMeshName, const std::string& theFieldName,
+ VISU::Entity theEntity, int theIteration,
+ char* theTitle, bool theIsFixedRange)
{
- int anIteration = GetIteration();
- SameAs(theOrigin);
- myIteration = anIteration;
+ myMeshName = theMeshName;
+ myFieldName = theFieldName;
+ myEntity = (VISU::TEntity)theEntity;
+ myIteration = theIteration;
+ myIsFixedRange = theIsFixedRange;
+ //int anIteration = GetIteration();
+ SameAs(theOrigin);
+ //myIteration = anIteration;
+
+ myTitle = theTitle;
+
Build(-1);
Update();
}
* Is used in VISU_TimeAnimation class implementation.
*/
void
- SameAsParams(const ColoredPrs3d_i* theOrigin);
+ SameAsParams(const ColoredPrs3d_i* theOrigin,
+ const std::string& theMeshName, const std::string& theFieldName,
+ VISU::Entity theEntity, int theIteration,
+ char* theTitle, bool theIsFixedRange);
virtual const VISU::PField&
GetField() const;
ScalarMap_i* anOrigin = const_cast<ScalarMap_i*>(aPrs3d);
SetRange(anOrigin->GetMin(), anOrigin->GetMax());
- myIsFixedRange = anOrigin->IsRangeFixed();
+ //myIsFixedRange = anOrigin->IsRangeFixed();
SetScaling(anOrigin->GetScaling());
}
aData.myPrs[0]->GetOffset(aData.myOffset);
for (int i = 1; i < aData.myNbFrames; i++) {
+ bool anIsFixedRange = false;
+ if (aData.myPrsType != VISU::TGAUSSPOINTS) {
+ if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
+ anIsFixedRange = aPrs->IsRangeFixed();
+ }
//jfa 03.08.2005:aData.myPrs[i]->SameAs(aData.myPrs[0]);
- aData.myPrs[i]->SameAsParams(aData.myPrs[0]);//jfa 03.08.2005
+ aData.myPrs[i]->SameAsParams(aData.myPrs[0],
+ aData.myPrs[i]->GetMeshName(),aData.myPrs[i]->GetFieldName(),
+ aData.myPrs[i]->GetEntity(), aData.myPrs[i]->GetIteration(),
+ aData.myPrs[i]->GetTitle(), anIsFixedRange);//jfa 03.08.2005
}
}
string aStr = aAnimSObject->GetID();
void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
throw (SALOME::SALOME_Exception)
{
- FieldData& aData = myFieldsLst[theFieldNum];
-
- if ( aData.myPrs.empty() )
- throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!"));
-
VISU::ColoredPrs3d_i* aPrs_i = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(thePrs).in());
if ( !aPrs_i )
throw SALOME_Exception(LOCALIZED("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i"));
-
- if ( aPrs_i->GetResult() != aData.myPrs[0]->GetResult() )
- throw SALOME_Exception(LOCALIZED("Error : the MED file is not the same!"));
-
- if ( aPrs_i->GetMeshName() != aData.myPrs[0]->GetMeshName() )
- throw SALOME_Exception(LOCALIZED("Error : the mesh name is not the same!"));
-
- if ( aPrs_i->GetFieldName() != aData.myPrs[0]->GetFieldName() )
- throw SALOME_Exception(LOCALIZED("Error : the field name is not the same!"));
-
- if ( aPrs_i->GetEntity() != aData.myPrs[0]->GetEntity() )
- throw SALOME_Exception(LOCALIZED("Error : the entity is not the same!"));
+ printf("aPrs_i->GetMeshName() = %s; aPrs_i->GetFieldName() = %s\n",aPrs_i->GetMeshName().c_str(),aPrs_i->GetFieldName().c_str());
- for (int i = 0; i < aData.myNbFrames; i++) {
- aData.myPrs[i]->SameAsParams(aPrs_i);
+ if ( myAnimationMode == 0 ) { // parallel animation mode
+ FieldData& aData = myFieldsLst[theFieldNum];
+
+ if ( aData.myPrs.empty() )
+ throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!"));
+
+ if ( aPrs_i->GetResult() != aData.myPrs[0]->GetResult() )
+ throw SALOME_Exception(LOCALIZED("Error : the MED file is not the same!"));
+
+ for (int i = 0; i < aData.myNbFrames; i++) {
+ bool anIsFixedRange = false;
+ if (aData.myPrsType != VISU::TGAUSSPOINTS) {
+ if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
+ anIsFixedRange = aPrs->IsRangeFixed();
+ }
+ aData.myPrs[i]->SameAsParams(aPrs_i,
+ aData.myPrs[i]->GetMeshName(),aData.myPrs[i]->GetFieldName(),
+ aData.myPrs[i]->GetEntity(), aData.myPrs[i]->GetIteration(),
+ aData.myPrs[i]->GetTitle(), anIsFixedRange);
+ }
+ }
+ else if ( myAnimationMode == 1 ) { // successive animation mode
+ for (int f = 0; f < getNbFields(); f++) {
+ FieldData& aData = myFieldsLst[f];
+
+ if ( aData.myPrs.empty() )
+ throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!"));
+
+ for (int i = 0; i < aData.myNbFrames; i++) {
+ printf("aData.myPrs[%d]->GetMeshName() = %s; aData.myPrs[%d]->GetFieldName() = %s\n",
+ i,aData.myPrs[i]->GetMeshName().c_str(),i,aData.myPrs[i]->GetFieldName().c_str());
+ aData.myPrs[i]->SameAsParams(aPrs_i,
+ aData.myPrs[i]->GetMeshName(),aData.myPrs[i]->GetFieldName(),
+ aData.myPrs[i]->GetEntity(), aData.myPrs[i]->GetIteration(),
+ aData.myPrs[i]->GetTitle(), true);
+ }
+ }
}
-
}
//========================================================================
EXPORT_PYSCRIPTS = libVISU_Swig.py batchmode_visu.py batchmode_visu_table.py batchmode_visu_view3d.py \
visu_med.py visu_view3d.py visu.py visu_gui.py visu_prs_example.py \
visu_table.py visu_big_table.py visu_view.py visu_delete.py \
- visu_swig_test.py visu_split_views.py visu_succcessive_animation.py \
+ visu_swig_test.py visu_split_views.py \
+ visu_succcessive_animation.py visu_apply_properties.py visu_apply_properties_successive.py \
VISU_Example_01.py VISU_Example_02.py VISU_Example_03.py VISU_Example_04.py \
VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py
EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# 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 : visu_apply_properties.py
+# Module : VISU
+
+import os
+import time
+import math
+import VISU
+import SALOMEDS
+from visu_gui import *
+
+aDelay = 0
+
+myViewManager = myVisu.GetViewManager();
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The viewer for Animation")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+medFile = "TimeStamps.med"
+myFieldName = "temperature"
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+anAnim = myVisu.CreateAnimation(myView);
+
+aSObj = myStudy.FindObjectIOR(myResult.GetID())
+aSObj = aSObj.FindSubObject(1)[1]
+aSObj = aSObj.FindSubObject(3)[1]
+aSObj = aSObj.FindSubObject(1)[1]
+print "addField 1 : ", anAnim.addField(aSObj)
+
+print "Generate presentations for ", anAnim.getNbFields(), " fields"
+for i in range(0,anAnim.getNbFields()):
+ anAnim.setPresentationType(i,VISU.TPLOT3D)
+ anAnim.generatePresentations(i)
+
+print "Generate frames"
+anAnim.generateFrames()
+
+print "Start Animation"
+anAnim.setSpeed(22)
+anAnim.startAnimation()
+myView.FitAll()
+
+while 1:
+ time.sleep(1+aDelay)
+ if not anAnim.isRunning():
+ anAnim.stopAnimation()
+ break
+
+anAnim.publishInStudy()
+anAnim.saveAnimation()
+
+for i in range(0,anAnim.getNbFields()):
+ aPrs = anAnim.getPresentation(i,0)
+ aPlot3D = aPrs._narrow(VISU.Plot3D)
+
+ if aPlot3D:
+ aNbLabels = aPlot3D.GetLabels()
+ aPlot3D.SetLabels(aNbLabels+3)
+
+ aWidth = aPlot3D.GetWidth()
+ aHeight = aPlot3D.GetHeight()
+ aPlot3D.SetSize(aWidth+0.07,aHeight+0.07)
+
+ print "Apply properties for all time stamps of ", i, " field."
+ try:
+ anAnim.ApplyProperties(i,aPlot3D)
+ except SALOME.SALOME_Exception, inst:
+ msg = "SALOME.SALOME_Exception caught, see details:"
+ msg+="\n******* text:\t" + inst.details.text
+ msg+="\n******* type:\t" + str(inst.details.type)
+ msg+="\n******* where:\t" + inst.details.sourceFile + ":" + \
+ str(inst.details.lineNumber)
+ print msg
+ raise RuntimeError, "There are some errors were occured... For more info see ERRORs above..."
+
+print "Generate frames"
+anAnim.generateFrames()
+
+print "Start Animation"
+anAnim.startAnimation()
+myView.FitAll()
+
+while 1:
+ time.sleep(1+aDelay)
+ if not anAnim.isRunning():
+ anAnim.stopAnimation()
+ break
+
+anAnim.publishInStudy()
+anAnim.saveAnimation()
+
+anAnim.clearFields()
+print "The number of fields in animation after clearFields method is", anAnim.getNbFields()
+
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# 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 : visu_apply_properties_consecutive.py
+# Module : VISU
+
+import os
+import time
+import math
+import VISU
+import SALOMEDS
+from visu_gui import *
+
+aDelay = 0
+
+myViewManager = myVisu.GetViewManager();
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The viewer for Animation")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+medFile = "TimeStamps.med"
+myFieldName = "temperature"
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+anAnim = myVisu.CreateAnimation(myView);
+anAnim.setAnimationMode(VISU.Animation.SUCCCESSIVE)
+
+aSObj = myStudy.FindObjectIOR(myResult.GetID())
+aSObj = aSObj.FindSubObject(1)[1]
+aSObj = aSObj.FindSubObject(3)[1]
+aSObj = aSObj.FindSubObject(1)[1]
+print "addField 1 : ", anAnim.addField(aSObj)
+
+medFile1 = "TimeStamps_import22.med"
+myFieldName1 = "pression"
+
+medFile1 = os.getenv('DATA_DIR') + '/MedFiles/' + medFile1
+myResult1 = myVisu.ImportFile(medFile1)
+
+aSObj1 = myStudy.FindObjectIOR(myResult1.GetID())
+aSObj1 = aSObj1.FindSubObject(1)[1]
+aSObj1 = aSObj1.FindSubObject(3)[1]
+aSObj1 = aSObj1.FindSubObject(3)[1]
+print "addField 2 : ", anAnim.addField(aSObj1)
+
+print "Generate presentations for ", anAnim.getNbFields(), " fields"
+for i in range(0,anAnim.getNbFields()):
+ anAnim.setPresentationType(i,VISU.TPLOT3D)
+ anAnim.generatePresentations(i)
+
+print "Generate frames"
+anAnim.generateFrames()
+
+print "Start Animation"
+anAnim.setSpeed(22)
+anAnim.startAnimation()
+myView.FitAll()
+
+while 1:
+ time.sleep(1+aDelay)
+ if not anAnim.isRunning():
+ anAnim.stopAnimation()
+ break
+
+anAnim.publishInStudy()
+anAnim.saveAnimation()
+
+if anAnim.getAnimationMode() == VISU.Animation.SUCCCESSIVE:
+ print "End of succcessive animation for 2 fields with presentation type VISU.Animation.SUCCCESSIVE"
+
+#for i in range(0,anAnim.getNbFields()):
+aPrs = anAnim.getPresentation(0,0)
+aPlot3D = aPrs._narrow(VISU.Plot3D)
+
+if aPlot3D:
+ aNbLabels = aPlot3D.GetLabels()
+ aPlot3D.SetLabels(aNbLabels+3)
+
+ aWidth = aPlot3D.GetWidth()
+ aHeight = aPlot3D.GetHeight()
+ aPlot3D.SetSize(aWidth+0.07,aHeight+0.07)
+
+ print "Apply properties for all time stamps of all fields."
+ try:
+ anAnim.ApplyProperties(0,aPlot3D)
+ except SALOME.SALOME_Exception, inst:
+ msg = "SALOME.SALOME_Exception caught, see details:"
+ msg+="\n******* text:\t" + inst.details.text
+ msg+="\n******* type:\t" + str(inst.details.type)
+ msg+="\n******* where:\t" + inst.details.sourceFile + ":" + \
+ str(inst.details.lineNumber)
+ print msg
+ raise RuntimeError, "There are some errors were occured... For more info see ERRORs above..."
+
+print "Generate frames"
+anAnim.generateFrames()
+
+print "Start Animation"
+anAnim.startAnimation()
+myView.FitAll()
+
+while 1:
+ time.sleep(1+aDelay)
+ if not anAnim.isRunning():
+ anAnim.stopAnimation()
+ break
+
+anAnim.publishInStudy()
+anAnim.saveAnimation()
+
+anAnim.clearFields()
+print "The number of fields in animation after clearFields method is", anAnim.getNbFields()
+