#include "VISU_IsoSurfaces_i.hh"
#include "VISU_DeformedShape_i.hh"
#include "VISU_CutPlanes_i.hh"
+#include "VISU_Plot3D_i.hh"
#include "VISU_CutLines_i.hh"
#include "VISU_Vectors_i.hh"
#include "VISU_StreamLines_i.hh"
if (!CORBA::is_nil(theView3D)) {
VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
- //QAD_StudyFrame* aStudyFrame = pView->GetStudyFrame();
- //myView = VISU::GetViewFrame(aStudyFrame);
- SUIT_ViewWindow* aVW = pView->myViewWindow;
+ SUIT_ViewWindow* aVW = pView->GetViewWindow();
myView = VISU::GetViewWindow(aVW);
}
//************************************************************************
void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
{
- FieldData aNewData;
- _PTR(SObject) aField = VISU::GetClientSObject(theField, myStudy);
- aNewData.myField = aField;
- aNewData.myNbFrames = 0;
- aNewData.myPrsType = VISU::TSCALARMAP;
- VISU::Storable::TRestoringMap aMap = getMapOfValue(aNewData.myField);
- aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
- myFieldsLst.append(aNewData);
-
- //find Min/Max timestamps
- if ((myTimeMin == 0) && (myTimeMax == 0)) {
- _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aField);
- anIter->Next(); // First is reference on support
- myTimeMin = getTimeValue(anIter->Value());
- for(; anIter->More(); anIter->Next()) {
- myTimeMax = getTimeValue(anIter->Value());
- }
- }
+ SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
+ _PTR(SObject) aField = VISU::GetClientSObject(theFieldDup, myStudy);
+ addField(aField);
}
}
break;
+ case VISU::TPLOT3D: // Plot3d
+ {
+ VISU::Plot3D_i* aPresent = new VISU::Plot3D_i (pResult, false);
+ aPresent->Create(aMeshName.latin1(), anEntity,
+ aFieldName.latin1(), aTimeStampId);
+ aData.myPrs[i] = aPresent;
+ }
+ break;
+
case VISU::TDEFORMEDSHAPE: // Deformed Shape
{
VISU::DeformedShape_i* aPresent = new VISU::DeformedShape_i(pResult, false);
aData.myPrs[i] = aPresent;
}
break;
+ default:
+ MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
+ return;
}
if (aData.myPrs[i]->GetMin() < aMin) aMin = aData.myPrs[i]->GetMin();
if (aData.myPrs[i]->GetMax() > aMax) aMax = aData.myPrs[i]->GetMax();
i++;
}
aData.myNbFrames = i;
- QString aFixRange = VISU::GetResourceMgr()->stringValue("Visu:SBImposeRange");
- if (aFixRange.compare("true") != 0) {
+
+ int rangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0);
+ if ( rangeType != 1 ) {
for (i = 0; i < aData.myNbFrames; i++) {
aData.myPrs[i]->SetRange(aMin, aMax);
aData.myPrs[i]->SetOffset(aData.myOffset);
//************************************************************************
CORBA::Boolean VISU_TimeAnimation::generateFrames() {
if (!myView) {
- MESSAGE("Viewer is nod defined for animation");
+ MESSAGE("Viewer is not defined for animation");
return false;
}
//************************************************************************
void VISU_TimeAnimation::clearView() {
if (!myView) {
- MESSAGE("Viewer is nod defined for animation");
+ MESSAGE("Viewer is not defined for animation");
return;
}
vtkRenderer* aRen = myView->getRenderer();
//************************************************************************
-void VISU_TimeAnimation::run() {
+void VISU_TimeAnimation::run()
+{
if (!myView) {
- MESSAGE("Viewer is nod defined for animation");
+ MESSAGE("Viewer is not defined for animation");
return;
}
- double k=1;
- double aOneVal;
- bool isDumping = !myDumpPath.isEmpty();
- aOneVal = (myFieldsLst[0].myNbFrames > 2) ?
- myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0] : 1;
+ double k = 1;
+ bool isDumping = !myDumpPath.isEmpty();
+ double aOneVal = 1;
+ if (myFieldsLst[0].myNbFrames > 2)
+ aOneVal = myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0];
qApp->lock();
while (myIsActive) {
emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
}
}
myView->Repaint(false);
+
if (isDumping) {
+ // We must unlock mutex for some time before grabbing to allow view updating
+ qApp->unlock();
+ msleep(100);
+ qApp->lock();
+
QPixmap px = QPixmap::grabWindow(myView->winId());
QString aFile(myDumpPath);
QString aName = QString("%1").arg(myFieldsLst[0].myTiming[myFrame]);
aFile += aName;
aFile += ".jpeg";
px.save(aFile, "JPEG");
- }
- if (!isDumping) {
+ } else {
+ k = 1;
if (myProportional) {
switch (myFrame) {
case 0:
- k=1;
break;
case 1:
if (myFieldsLst[0].myNbFrames > 2)
- k = (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal;
- else
- k = 1;
+ k = (myFieldsLst[0].myTiming[myFrame+1] -
+ myFieldsLst[0].myTiming[myFrame]) / aOneVal;
break;
default:
- k = (myFrame < (myFieldsLst[0].myNbFrames-1))?
- (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal : 1;
+ if (myFrame < (myFieldsLst[0].myNbFrames - 1))
+ k = (myFieldsLst[0].myTiming[myFrame+1] -
+ myFieldsLst[0].myTiming[myFrame]) / aOneVal;
}
- } else
- k = 1;
- qApp->unlock();
- msleep((int)(1000.*k/mySpeed));
- qApp->lock();
- } else {
+ }
+ int delay = (int)(1000. * k / mySpeed);
qApp->unlock();
- msleep(100);
+ msleep(delay);
qApp->lock();
}
+
if (!myIsActive) break;
myFrame++;
if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) {
_PTR(AttributeName) aName (anAttr);
QString aNameString (aName->Value().c_str());
- return aNameString.toDouble();
+ int time_len = aNameString.find(',');
+ if (time_len > -1)
+ return aNameString.left(time_len).toDouble();
+ else
+ return aNameString.toDouble();
}
return -1.0;
}
case VISU::TCUTPLANES:
aPrsCmt = VISU::CutPlanes_i::myComment;
break;
+ case VISU::TPLOT3D:
+ aPrsCmt = VISU::Plot3D_i::myComment;
+ break;
case VISU::TDEFORMEDSHAPE:
aPrsCmt = VISU::DeformedShape_i::myComment;
break;
for (int i = 0; i < getNbFields(); i++) {
FieldData& aData = myFieldsLst[i];
+
_PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
aStudyBuilder->Addreference(newObj, aData.myField);
+
if (aData.myPrs.empty()) {
- VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
- GetPresentationComment(aData.myPrsType).c_str(),"","",true);
- } else {
- ostringstream strOut;
- aData.myPrs[0]->ToStream(strOut);
- string aPrsComment = strOut.str();
- VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
- aData.myPrs[0]->GetComment(),"",aPrsComment.c_str(),true);
+ generatePresentations(i);
}
+ ostringstream strOut;
+ aData.myPrs[0]->ToStream(strOut);
+ string aPrsComment = strOut.str();
+ VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
+ aData.myPrs[0]->GetComment(),"",aPrsComment.c_str(),true);
}
aStudyBuilder->CommitCommand();
//************************************************************************
void VISU_TimeAnimation::saveAnimation()
{
- if (myStudy->GetProperties()->IsLocked()) return;
+ if (myStudy->GetProperties()->IsLocked()) return;
if (myAnimEntry.isEmpty()) return;
- _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry);
+ _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.latin1());
if (!aAnimSObject) return;
_PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
_PTR(GenericAttribute) anAttr;
anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeComment");
_PTR(AttributeComment) aCmnt (anAttr);
- aCmnt->SetValue(aComment);
+ aCmnt->SetValue(aComment.latin1());
_PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
- int i;
- for (i = 0, anIter->Init(); anIter->More(); anIter->Next(), i++) {
+ int i = 0, nbf = getNbFields();
+ for (anIter->Init(); anIter->More(); anIter->Next(), i++) {
+ if (i >= nbf) break; // it must not be
FieldData& aData = myFieldsLst[i];
+ // Get presentation name and comment
+ if (aData.myPrs.empty()) {
+ generatePresentations(i);
+ }
+ ostringstream strOut;
+ aData.myPrs[0]->ToStream(strOut);
+ string aPrsComment = strOut.str();
+ string aPrsNameTxt = aData.myPrs[0]->GetComment();
+
+ // Save in study
_PTR(SObject) aRefObj = anIter->Value();
_PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
anPrsIter->Init();
- string aPrsComment, aPrsNameTxt;
- if (aData.myPrs.empty()) {
- aPrsComment = "";
- aPrsNameTxt = GetPresentationComment(aData.myPrsType);
- } else {
- ostringstream strOut;
- aData.myPrs[0]->ToStream(strOut);
- aPrsComment = strOut.str();
-
- aPrsNameTxt = aData.myPrs[0]->GetComment();
- }
-
if (anPrsIter->More()) {
_PTR(SObject) aPrsObj = anPrsIter->Value();
anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeComment");
aData.myPrsType = VISU::TISOSURFACE;
else if (strName == VISU::CutPlanes_i::myComment.c_str())
aData.myPrsType = VISU::TCUTPLANES;
+ else if (strName == VISU::Plot3D_i::myComment.c_str())
+ aData.myPrsType = VISU::TPLOT3D;
else if (strName == VISU::DeformedShape_i::myComment.c_str())
aData.myPrsType = VISU::TDEFORMEDSHAPE;
else if (strName == VISU::Vectors_i::myComment.c_str())
}
aData.myPrs[0]->GetOffset(aData.myOffset);
for (int i = 1; i < aData.myNbFrames; i++) {
- aData.myPrs[i]->SameAs(aData.myPrs[0]);
+ //jfa 03.08.2005:aData.myPrs[i]->SameAs(aData.myPrs[0]);
+ aData.myPrs[i]->SameAsParams(aData.myPrs[0]);//jfa 03.08.2005
}
}
string aStr = aAnimSObject->GetID();