-// VISU OBJECT : interactive object for VISU entities implementation
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// 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
// 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
-//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// VISU OBJECT : interactive object for VISU entities implementation
// File : VISU_DumpPython.cc
// Author : Alexey PETROV
// Module : VISU
-
+//
#include "VISU_Gen_i.hh"
#include "VISU_Result_i.hh"
#include "VISU_PrsObject_i.hh"
#include "VISU_StreamLines_i.hh"
#include "VISU_Plot3D_i.hh"
#include "VISU_Table_i.hh"
+#include "VISU_PointMap3d_i.hh"
#include "VISU_GaussPoints_i.hh"
-#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_DeformedShapeAndScalarMap_i.hh"
#include "VISU_ColoredPrs3dCache_i.hh"
#include "VISU_ColoredPrs3dHolder_i.hh"
#include <strstream>
#include <functional>
-#include <qstring.h>
-#include <qfileinfo.h>
+#include <QString>
+#include <QFileInfo>
//#define COUT
{
CORBA::String_var aString = theSObject->GetName();
- std::string aName = QString(aString.in()).simplifyWhiteSpace().latin1();
+ std::string aName = QString(aString.in()).simplified().toLatin1().data();
//replace_if(aName.begin(),aName.end(),not1(ptr_fun(isxdigit)),'_');
replace_if(aName.begin(),aName.end(),TReplacePredicate(),'_');
//---------------------------------------------------------------------------
+ void SetClippingPlane(Prs3d_i* thePrs, string theName,
+ std::ostream& theStr,
+ std::string thePrefix)
+ {
+ VISU_CutPlaneFunction* aPlane;
+ VISU_Gen_i* aGen = VISU_Gen_i::GetVisuGenImpl();
+ VISU_ClippingPlaneMgr& aMgr = aGen->GetClippingPlaneMgr();
+ int aId;
+ for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) {
+ aPlane = dynamic_cast<VISU_CutPlaneFunction*>(thePrs->GetClippingPlane(i));
+ if (aPlane) {
+ if (!aPlane->isAuto()) {
+ aId = aMgr.GetPlaneId(aPlane);
+ if (aId > -1) {
+ theStr<<thePrefix<<"aVisu.ApplyClippingPlane("<<theName<<", "<<aId<<")"<<endl;
+ }
+ }
+ }
+ }
+ }
+
+
void
Prs3dToPython(VISU::Prs3d_i* theServant,
std::ostream& theStr,
float x, y, z;
theServant->GetOffset(x,y,z);
theStr<<thePrefix<<theName<<".SetOffset("<<x<<", "<<y<<", "<<z<<")"<<endl;
+ SetClippingPlane(theServant, theName, theStr, thePrefix);
}
//---------------------------------------------------------------------------
std::string aParam;
switch(theServant->GetBarOrientation()){
- case ColoredPrs3d::HORIZONTAL:
+ case ColoredPrs3dBase::HORIZONTAL:
aParam = "VISU.ColoredPrs3d.HORIZONTAL";
break;
- case ColoredPrs3d::VERTICAL:
+ case ColoredPrs3dBase::VERTICAL:
aParam = "VISU.ColoredPrs3d.VERTICAL";
break;
}
QString aMainTexture = theServant->GetQMainTexture();
QString anAlphaTexture = theServant->GetQAlphaTexture();
- theStr<<thePrefix<<theName<<".SetTextures('"<<aMainTexture.latin1()<<"', '"<<anAlphaTexture.latin1()<<"')"<<endl;
+ theStr<<thePrefix<<theName<<".SetTextures('"<<aMainTexture.toLatin1().data()<<"', '"<<anAlphaTexture.toLatin1().data()<<"')"<<endl;
theStr<<thePrefix<<theName<<".SetAlphaThreshold("<<theServant->GetAlphaThreshold()<<")"<<endl;
aParam = "VISU.LOGARITHMIC";
break;
}
+ std::string aVisible = theServant->IsBarVisible()? "True" : "False";
theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetBarVisible("<<aVisible<<")"<<endl;
return thePrefix;
}
+ //---------------------------------------------------------------------------
+ std::string
+ MonoColorPrsToPython(SALOMEDS::SObject_ptr theSObject,
+ VISU::MonoColorPrs_i* theServant,
+ std::ostream& theStr,
+ const std::string& theName,
+ TColoredPrs3dFactory& thePrsFactory,
+ std::string thePrefix)
+ {
+ thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+ theStr<<thePrefix<<endl;
+ theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
+ return thePrefix;
+ }
//---------------------------------------------------------------------------
std::string
TColoredPrs3dFactory& thePrsFactory,
std::string thePrefix)
{
- thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+ thePrefix = MonoColorPrsToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
theStr<<thePrefix<<endl;
theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
- theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
- theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
+// theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
+// theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
return thePrefix;
}
TColoredPrs3dFactory& thePrsFactory,
std::string thePrefix)
{
- thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+ thePrefix = MonoColorPrsToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
+ // thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
theStr<<thePrefix<<endl;
std::string aParam;
//---------------------------------------------------------------------------
std::string
- ScalarMapOnDeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
- VISU::ScalarMapOnDeformedShape_i* theServant,
- std::ostream& theStr,
- const std::string& theName,
- TColoredPrs3dFactory& thePrsFactory,
- std::string thePrefix)
+ DeformedShapeAndScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
+ VISU::DeformedShapeAndScalarMap_i* theServant,
+ std::ostream& theStr,
+ const std::string& theName,
+ TColoredPrs3dFactory& thePrsFactory,
+ std::string thePrefix)
{
thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
theStr<<thePrefix<<endl;
theStr<<thePrefix<<endl;
theStr<<thePrefix<<theName<<".SetNbSurfaces("<<theServant->GetNbSurfaces()<<")"<<endl;
+ theStr<<thePrefix<<theName<<".ShowLabels("<<theServant->IsLabeled()<<","<<theServant->GetNbLabels()<<")"<<endl;
return thePrefix;
}
theStr<<thePrefix<<theName<<".SetPlanePosition("<<anId<<", "<<theServant->GetPlanePosition(anId)<<")"<<endl;
}
+ theStr<<thePrefix<<theName<<".UseDeformation("<<GetBoolean(theServant->IsDeformed())<<")"<<endl;
+ if(theServant->IsDeformed()){
+ theStr<< thePrefix << theName << ".SetScale(" << theServant->GetScale()<<")"<<endl;
+ std::string aStringEntity;
+ VISU::Entity anEntity = theServant->GetVectorialFieldEntity();
+ switch(anEntity){
+ case NODE:
+ aStringEntity = "VISU.NODE";
+ break;
+ case EDGE:
+ aStringEntity = "VISU.EDGE";
+ break;
+ case FACE:
+ aStringEntity = "VISU.FACE";
+ break;
+ case CELL:
+ aStringEntity = "VISU.CELL";
+ break;
+ }
+ theStr<< thePrefix << theName << ".SetVectorialField("<<aStringEntity<<", '" << theServant->GetVectorialFieldName() <<"')"<<endl;
+ }
return thePrefix;
}
return thePrefix;
}
-
//---------------------------------------------------------------------------
// declaration
void DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
bool anIsExist;
QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
if(anIsExist){
- if(strcmp(aMethodName.latin1(),"ImportTables") == 0){
+ if(strcmp(aMethodName.toLatin1().data(),"ImportTables") == 0){
return;
}
}
}
}
-
+
//---------------------------------------------------------------------------
void
break;
}
theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetShrink("<<(aServant->IsShrank()? "True" : "False")<<")"<<endl;
theStr<<thePrefix<<endl;
DumpChildrenToPython(theStudy,
}
return;
case VISU::TSCALARMAPONDEFORMEDSHAPE:
- if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(GetServant(anObj).in())){
- TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnDeformedShapeOnField", theArgumentName);
- thePrefix = ScalarMapOnDeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
+ case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+ if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast<DeformedShapeAndScalarMap_i*>(GetServant(anObj).in())){
+ TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeAndScalarMapOnField", theArgumentName);
+ thePrefix = DeformedShapeAndScalarMapToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
theStr<<thePrefix<<"pass"<<endl<<endl;
}
return;
theStr<<thePrefix<<"pass"<<endl<<endl;
}
return;
+ case VISU::TPOINTMAP3D:
+ if (PointMap3d_i* aServant = dynamic_cast<PointMap3d_i*>(GetServant(anObj).in())) {
+ CORBA::Short aTag = theSObject->Tag();
+ theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
+ theStr<<thePrefix<<"if anIsFound:"<<endl;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
+ theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+
+ // Set name (as this object could be renamed by user)
+ theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
+
+ // Set PointMap3D Properties
+
+ theStr<<thePrefix<<aName<<".SetScaleFactor("<<aServant->GetScaleFactor()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetContourPrs("<<aServant->GetIsContourPrs()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetNbOfContours("<<aServant->GetNbOfContours()<<")"<<endl;
+
+ std::string aParam;
+ switch(aServant->GetScaling()){
+ case LINEAR:
+ aParam = "VISU.LINEAR";
+ break;
+ case LOGARITHMIC:
+ aParam = "VISU.LOGARITHMIC";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetScaling("<<aParam<<")"<<endl;
+
+ theStr<<thePrefix<<aName<<".SetNbColors("<<aServant->GetNbColors()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetLabels("<<aServant->GetLabels()<<")"<<endl;
+
+ switch(aServant->GetBarOrientation()){
+ case ColoredPrs3dBase::HORIZONTAL:
+ aParam = "VISU.ColoredPrs3d.HORIZONTAL";
+ break;
+ case ColoredPrs3dBase::VERTICAL:
+ aParam = "VISU.ColoredPrs3d.VERTICAL";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetBarOrientation("<<aParam<<")"<<endl;
+
+ if(aServant->IsRangeFixed())
+ theStr<<thePrefix<<aName<<".SetRange("<<aServant->GetMin()<<", "<<aServant->GetMax()<<")"<<endl;
+ else
+ theStr<<thePrefix<<aName<<".SetSourceRange()"<<endl;
+
+ theStr<<thePrefix<<aName<<".SetPosition("<<aServant->GetPosX()<<", "<<aServant->GetPosY()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetSize("<<aServant->GetWidth()<<", "<<aServant->GetHeight()<<")"<<endl;
+
+ float dx, dy, dz;
+ aServant->GetOffset(dx, dy, dz);
+ theStr<<thePrefix<<aName<<".SetOffset("<<dx<<", "<<dy<<", "<<dz<<")"<<endl;
+
+
+ theStr<<thePrefix<<endl;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
case VISU::TGAUSSPOINTS:
if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(GetServant(anObj).in())){
TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName);
bool anIsExist;
QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
if(anIsExist){
- if(strcmp(aSourceId.latin1(),"CutLines") == 0){
+ if( aSourceId == "CutLines" ){
theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<theArgumentName<<"'):"<<endl;
thePrefix += PREFIX;
theStr<<thePrefix<<"pass"<<endl<<endl;
theStr<<aPrefix<<"pass"<<endl<<endl;
- }else if(strcmp(aSourceId.latin1(),"TableFile") == 0){
+ }else if( aSourceId == "TableFile" ){
CORBA::Short aTag = theSObject->Tag();
theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
theStr<<thePrefix<<"if anIsFound:"<<endl;
thePrefix);
theStr<<thePrefix<<"pass"<<endl<<endl;
- }else if(strcmp(aSourceId.latin1(),"TableAttr") == 0){
+ }else if( aSourceId == "TableAttr" ){
theArgumentName = aName;
DumpTableAttrToPython(theStudy,
theIsPublished,
bool anIsExist;
QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
if (anIsExist) {
- if (strcmp(aTypeName.latin1(),"ImportTables") == 0) {
+ if (aTypeName == "ImportTables") {
QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
if(anIsExist){
std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
- theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.latin1()<<"')"<<endl;
+ theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.toLatin1().data()<<"')"<<endl;
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
thePrefix += PREFIX;
theStr<<thePrefix<<"pass"<<endl<<endl;
return;
}
- } else if (strcmp(aTypeName.latin1(),"VIEW3D") == 0) {
+ } else if (aTypeName == "VIEW3D") {
std::string aName = GetName(theSObject);
theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
return;
} else if (aTypeName == "ENTITY" || aTypeName == "FAMILY" || aTypeName == "GROUP") {
// Set name (as this object could be renamed by user)
- string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
- string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").latin1();
+ string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").toLatin1().data();
+ string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").toLatin1().data();
string anEntityTypeKey = "myEntityId";
if (aTypeName == "ENTITY") anEntityTypeKey = "myId";
int anEntity = VISU::Storable::FindValue(aMap,anEntityTypeKey,"0").toInt();
break;
}
case VISU::TSCALARMAPONDEFORMEDSHAPE:
- if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(aDevice)){
- ScalarMapOnDeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
+ case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+ if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast<DeformedShapeAndScalarMap_i*>(aDevice)){
+ DeformedShapeAndScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
break;
}
case VISU::TVECTORS:
//ANIMATION
theStr<<thePrefix<<endl;
QString animName = aSObject->GetName();
- theStr<<thePrefix<<"#Animation: "<<animName<<endl;
+ theStr<<thePrefix<<"#Animation: "<<animName.toLatin1().data()<<endl;
theStr<<thePrefix<<endl;
theStr<<thePrefix<<"animSO = aBuilder.NewObject(aSComponent)"<<endl;
- theStr<<thePrefix<<"aBuilder.SetName(animSO, '"<<animName<<"')"<< endl;
+ theStr<<thePrefix<<"aBuilder.SetName(animSO, '"<<animName.toLatin1().data()<<"')"<< endl;
theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(animSO, 'AttributeString')"<< endl;
- theStr<<thePrefix<<"strAttr.SetValue('"<<value<<"')"<< endl;
+ theStr<<thePrefix<<"strAttr.SetValue('"<<value.toLatin1().data()<<"')"<< endl;
value = refObj->GetName();
QString path(theStudy->GetObjectPath(father));
//The following code requierd as a field name can contain '/' character
- theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path<<"', '"<<value<<"'))"<<endl;
+ theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path.toLatin1().data()<<"', '"<<value.toLatin1().data()<<"'))"<<endl;
}
value = anObj->GetName();
- if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value<<"')"<< endl;
+ if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value.toLatin1().data()<<"')"<< endl;
//SCALARMAP,...
SALOMEDS::ChildIterator_var aSubIter = theStudy->NewChildIterator(anObj);
theStr<<thePrefix<<"subSO = aBuilder.NewObject(fieldSO)"<<endl;
value = aSubObj->GetName();
- if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(subSO, '"<<value<<"')"<< endl;
+ if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(subSO, '"<<value.toLatin1().data()<<"')"<< endl;
if (aSubObj->FindAttribute(anAttr, "AttributeString")) {
aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(subSO, 'AttributeString')"<< endl;
theStr<<thePrefix<<endl;
}
+
+ void
+ DumpClippingPlanesToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ std::string thePrefix,
+ VISU_ClippingPlaneMgr& thePlaneMgr)
+ {
+
+ if(!theIsPublished) return;
+
+ VISU_CutPlaneFunction* aPlane;
+ double aOrigin[3], aDir[3];
+ for (int i = 0; i < thePlaneMgr.GetClippingPlanesNb(); i++) {
+ aPlane = thePlaneMgr.GetClippingPlane(i);
+ aPlane->GetOrigin(aOrigin);
+ aPlane->GetNormal(aDir);
+
+ theStr<<thePrefix<<"aVisu.CreateClippingPlane("<<
+ aOrigin[0]<<","<<aOrigin[1]<<","<<aOrigin[2]<<","<<
+ aDir[0]<<","<<aDir[1]<<","<<aDir[2]<<","<<
+ aPlane->isAuto()<<",\""<<aPlane->getName()<<"\")"<<endl;
+ }
+ theStr<<endl;
+ }
+
+
//---------------------------------------------------------------------------
Engines::TMPFile*
VISU_Gen_i::
aStr<<endl;
SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
+
+ VISU::DumpClippingPlanesToPython(aStudy,
+ theIsPublished,
+ theIsValidScript,
+ aComponent.in(),
+ aStr,
+ aPrefix,
+ myClippingPlaneMgr);
+
+
VISU::DumpChildrenToPython(aStudy,
theIsPublished,
theIsValidScript,
aStr,
aPrefix);
+
//Output the script that sets up the visul parameters.
if(theIsPublished) {
char* script = aStudy->GetDefaultScript("Post-Pro", aPrefix.c_str());