#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
#include "VISU_Result_i.hh"
#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_ScalarMapPL.hxx"
#include "VISU_ScalarMapOnDeformedShapePL.hxx"
#include "SALOME_ListIO.hxx"
-#include "SALOMEDSClient_AttributeComment.hxx"
+#include "SALOMEDSClient_AttributeString.hxx"
#include "SALOMEDSClient_AttributeName.hxx"
#include <qlayout.h>
* Constructor
*/
VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_ScalarMapOnDeformedShapeDlg", false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myIsAnimation(false),
- myVisuGUI(theModule)
+ : VisuGUI_ScalarBarBaseDlg(theModule),
+ myIsAnimation(false),
+ myUpdateScalars(true),
+ myVisuGUI(theModule)
{
- myPrs = NULL;
setCaption(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- QTabWidget* aTabBox = new QTabWidget (this);
+ myTabBox = new QTabWidget (this);
// Scalar Map on Deformed shape pane
QVBox* aBox = new QVBox (this);
ScalFact = new QtxDblSpinBox (0.0, 1.0E+38, 0.1, TopGroup);
ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
- ScalFact->setPrecision(5);
+ ScalFact->setPrecision(38);
ScalFact->setValue(0.1);
TopGroupLayout->addWidget(ScalFact, 0, 1);
TopGroupLayout->addWidget(myTimeStampsCombo,2,1);
//
- aTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB"));
+ myTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB"));
// Scalar bar pane
- myScalarPane = new VisuGUI_ScalarBarPane (this, false);
- myScalarPane->setMargin(5);
+ myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAPONDEFORMEDSHAPE, theModule, this);
- aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(GetScalarPane(), tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(myInputPane, tr("INPUT_TAB"));
// Buttons
QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons");
GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
// Add Tab box and Buttons to the top layout
- TopLayout->addWidget(aTabBox);
+ TopLayout->addWidget(myTabBox);
TopLayout->addWidget(GroupButtons);
// signals and slots connections
connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int)));
}
-void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject
- (VISU::ScalarMapOnDeformedShape_i* thePrs, bool isAnim)
-{
- myIsAnimation = isAnim;
- myPrs = thePrs;
-
- setFactor(myPrs->GetScale());
- myTimeStampsCombo->setDisabled(isAnim);
-
- QString aFieldName(myPrs->GetScalarFieldName().c_str());
- float aIterFloat = GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(),
- myPrs->GetScalarFieldName().c_str(),
- myPrs->GetScalarIteration(),
- myPrs->GetScalarEntity());
- QString aIteration(QString("%1").arg(aIterFloat));
+VisuGUI_ScalarMapOnDeformedShapeDlg::~VisuGUI_ScalarMapOnDeformedShapeDlg()
+{}
- if (myMeshFieldsTimes.size() == 0)
+void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
+ bool theInit )
+{
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+ setFactor(myPrsCopy->GetScale());
+ myTimeStampsCombo->setDisabled(myIsAnimation);
+
+ CORBA::String_var aFieldName(myPrsCopy->GetScalarFieldName());
+ QString aIteration = GetFloatValueOfTimeStamp(myPrsCopy->GetScalarEntity(),
+ aFieldName.in(),
+ myPrsCopy->GetScalarTimeStampNumber());
+ if (myEntity2Fields.size() == 0)
{
// find all fields and time stamps on it
_PTR(Study) aActiveStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI));
Handle(SALOME_InteractiveObject) aIO = selected.First();
if (aIO->hasEntry()) {
_PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry());
-
- _PTR(GenericAttribute) anTmpAttr;
- if (aSObject->FindAttribute(anTmpAttr, "AttributeComment")) {
- _PTR(AttributeComment) aTmpComment (anTmpAttr);
- string aTmpComm = aTmpComment->Value();
- QString aTmpstrIn (aTmpComm.c_str());
- VISU::Storable::TRestoringMap aTmpaMap;
- VISU::Storable::StrToMap(aTmpstrIn,aTmpaMap);
- bool aTmpisExist;
- VISU::VISUType aTmpType =
- (VISU::VISUType)VISU::Storable::FindValue(aTmpaMap,"myType",&aTmpisExist).toInt();
- switch(aTmpType){
- case VISU::TTIMESTAMP:
- {
- aSObject = aSObject->GetFather();
- aSObject = aSObject->GetFather();
- break;
- }
- case VISU::TFIELD:
- {
- _PTR(SObject) newSObject;
- if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject;
- aSObject = aSObject->GetFather();
- break;
- }
- case VISU::TANIMATION:
- {
- _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject);
- for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) {
- _PTR(SObject) aTmpChildSObj = aTmpIter->Value();
- _PTR(SObject) newSObject;
- if(aTmpChildSObj->ReferencedObject(newSObject)){
- aSObject = newSObject;
- aSObject->GetFather();
- break;
- }
- }
+ VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject );
+ switch(aType){
+ case VISU::TTIMESTAMP: {
+ aSObject = aSObject->GetFather();
+ aSObject = aSObject->GetFather();
+ break;
+ }
+ case VISU::TFIELD: {
+ _PTR(SObject) newSObject;
+ if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject;
+ aSObject = aSObject->GetFather();
+ break;
+ }
+ case VISU::TANIMATION: {
+ _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject);
+ for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) {
+ _PTR(SObject) aTmpChildSObj = aTmpIter->Value();
+ _PTR(SObject) newSObject;
+ if(aTmpChildSObj->ReferencedObject(newSObject)){
+ aSObject = newSObject;
+ aSObject->GetFather();
break;
}
}
- }
-
+ break;
+ }}
+
aSObject = aSObject->GetFather();
aSObject = aSObject->GetFather();
for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
_PTR(SObject) aChildSObj = aIter->Value();
- CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj);
-
- _PTR(GenericAttribute) anAttr;
- if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) {
- _PTR(AttributeComment) aComment (anAttr);
- string aComm = aComment->Value();
- QString strIn (aComm.c_str());
- VISU::Storable::TRestoringMap aMap;
- VISU::Storable::StrToMap(strIn,aMap);
- bool isExist;
- VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
- if (isExist) {
- if ((aType == VISU::TTIMESTAMP)) {
- _PTR(GenericAttribute) aNameAttr;
- if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) {
- _PTR(AttributeName) aName (aNameAttr);
- VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
- QString aMeshName = VISU::getValue(aChildSObj, "myMeshName");
- if (QString(myPrs->GetMeshName().c_str()) != aMeshName) continue;
- myCurrMeshName = aMeshName;
- QString aFieldName = VISU::getValue(aChildSObj, "myFieldName");
- QString aTimeIter = VISU::getValue(aChildSObj, "myTimeStampId");
- QString aEntity = VISU::getValue(aChildSObj, "myEntityId");
- VISU::TEntity anEntity;
- switch (aEntity.toInt()) {
- case 0: anEntity = VISU::NODE_ENTITY; break;
- case 1: anEntity = VISU::EDGE_ENTITY; break;
- case 2: anEntity = VISU::FACE_ENTITY; break;
- case 3: anEntity = VISU::CELL_ENTITY; break;
- }
- TFT &aFieldsMap = myMeshFieldsTimes[aMeshName.latin1()];
- TFE aKey (aFieldName.latin1(), anEntity);
- aFieldsMap[aKey][aTimeIter.toInt()] =
- GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(),
- aFieldName.latin1(),
- aTimeIter.toInt(),
- anEntity);
- }
- }
- }
+ VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aChildSObj);
+ if (!aRestoringMap.empty()) {
+ VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aRestoringMap);
+ if (aType == VISU::TTIMESTAMP) {
+ QString aMeshName = aRestoringMap["myMeshName"];
+ CORBA::String_var aName = myPrsCopy->GetMeshName();
+ if (aMeshName != aName.in())
+ continue;
+ QString aFieldName = aRestoringMap["myFieldName"];
+ QString aTimeIter = aRestoringMap["myTimeStampId"];
+ QString aEntity = aRestoringMap["myEntityId"];
+ VISU::Entity anEntity;
+ switch (aEntity.toInt()) {
+ case 0: anEntity = VISU::NODE; break;
+ case 1: anEntity = VISU::EDGE; break;
+ case 2: anEntity = VISU::FACE; break;
+ case 3: anEntity = VISU::CELL; break;
+ }
+ TFieldName2TimeStamps& aFieldName2TimeStamps = myEntity2Fields[anEntity];
+ TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldName2TimeStamps[aFieldName];
+ aTimeStampNumber2Time[aTimeIter.toInt()] =
+ GetFloatValueOfTimeStamp(anEntity,
+ aFieldName.latin1(),
+ aTimeIter.toInt());
+ }
}
}
}
-
AddAllFieldNames();
}
- myFieldsCombo->setCurrentText(aFieldName);
+ myFieldsCombo->setCurrentText(aFieldName.in());
AddAllTimes(myFieldsCombo->currentText());
myTimeStampsCombo->setCurrentText(aIteration);
- SetScalarField();
+ SetScalarField( false );
- myScalarPane->initFromPrsObject(myPrs);
-}
+ VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
-int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject
- (VISU::ScalarMapOnDeformedShape_i* thePrs, bool theUpdateScalars, int theIter)
-{
- thePrs->SetScale(getFactor());
+ if( !theInit )
+ return;
- if (myIsAnimation)
- thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
- getCurrentScalarFieldName().latin1(),
- theIter,
- myPrs->GetScalarEntity());
- else
- thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
- getCurrentScalarFieldName().latin1(),
- myTimeStampsCombo->currentItem() + 1,
- myPrs->GetScalarEntity());
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
+}
- if (theUpdateScalars) SetScalarField();
+int
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ if(!myInputPane->check() || !GetScalarPane()->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
+
+ myPrsCopy->SetScale(getFactor());
- thePrs->ShowColored(true);
+ myPrsCopy->SetScalarField(myPrsCopy->GetScalarEntity(),
+ getCurrentScalarFieldName().latin1(),
+ myTimeStampID[ myTimeStampsCombo->currentItem() ]);
- myScalarPane->storeToPrsObject(thePrs);
+ if(myUpdateScalars)
+ SetScalarField( false );
- myPrs = thePrs;
+ VISU::TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Copy(myPrsCopy, thePrs);
- return 1;
+ return anIsOk;
}
int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldNamePos(){
return myTimeStampsCombo->count();
}
-VISU::TEntity VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarEntity(){
- VISU::TEntity anEntity;
- TFT::const_iterator aIterField = myMeshFieldsTimes[myCurrMeshName].begin();
- for(;aIterField != myMeshFieldsTimes[myCurrMeshName].end();aIterField++){
- if (aIterField->first.first == myFieldsCombo->currentText()){
- anEntity = aIterField->first.second;
- break;
+VISU::Entity
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::getCurrentScalarEntity()
+{
+ VISU::Entity anEntity = VISU::Entity(-1);
+ TEntity2Fields::const_iterator anIter = myEntity2Fields.begin();
+ for(; anIter != myEntity2Fields.end(); anIter++){
+ const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second;
+ TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin();
+ for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){
+ const QString& aFieldName = aFieldIter->first;
+ if (aFieldName == myFieldsCombo->currentText()) {
+ anEntity = anIter->first;
+ break;
+ }
}
}
return anEntity;
}
-void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(){
- SetScalarField(myTimeStampsCombo->currentItem()+1);
+void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField( const bool save_scalar_pane ){
+ SetScalarField( myTimeStampID[ myTimeStampsCombo->currentItem() ], "", save_scalar_pane );
}
-void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(int theIter,QString theFieldName){
+void
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::SetScalarField(int theIter,
+ QString theFieldName,
+ const bool save_scalar_pane )
+{
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ if( save_scalar_pane )
+ GetScalarPane()->storeToPrsObject(myPrsCopy);
QString aFieldName;
else
aFieldName = theFieldName;
- VISU::TEntity anEntity = getCurrentScalarEntity();
-
- myPrs->SetScalarField(myCurrMeshName.latin1(),
- aFieldName.latin1(),
- theIter,
- anEntity);
-
- myScalarPane->storeToPrsObject(myPrs);
+ VISU::Entity anEntity = getCurrentScalarEntity();
- UpdateScalarField();
+ myPrsCopy->SetScalarField(anEntity,
+ aFieldName.latin1(),
+ theIter);
+
+ if( save_scalar_pane )
+ UpdateScalarField();
+
+ QApplication::restoreOverrideCursor();
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::accept()
{
- if (myScalarPane->check()){
- myScalarPane->deletePreview();
- QDialog::accept();
- }
+ VisuGUI_ScalarBarBaseDlg::accept();
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::reject()
{
- myScalarPane->deletePreview();
- QDialog::reject();
+ VisuGUI_ScalarBarBaseDlg::reject();
}
-void VisuGUI_ScalarMapOnDeformedShapeDlg::onHelp()
+QString VisuGUI_ScalarMapOnDeformedShapeDlg::GetContextHelpFilePath()
{
- QString aHelpFileName = "scalar_map_on_deformed_shape_presentation.htm";
- LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
- if (app)
- app->onHelpContextModule(myVisuGUI ? app->moduleName(myVisuGUI->moduleName()) : QString(""), aHelpFileName);
- else {
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
- }
+ return "scalar_map_on_deformed_shape_page.html";
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllFieldNames(){
- TMF::const_iterator aIterMesh = myMeshFieldsTimes.begin();
- for(;aIterMesh != myMeshFieldsTimes.end();aIterMesh++){
- QString aMeshName = aIterMesh->first;
- TFT::const_iterator aIterField = (aIterMesh->second).begin();
- for(;aIterField != (aIterMesh->second).end(); aIterField++){
- QString aFieldName = aIterField->first.first;
+ TEntity2Fields::const_iterator anIter = myEntity2Fields.begin();
+ for(; anIter != myEntity2Fields.end(); anIter++){
+ const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second;
+ TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin();
+ for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){
+ const QString& aFieldName = aFieldIter->first;
myFieldsCombo->insertItem(aFieldName);
}
}
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllTimes(const QString& theFieldName){
- TMF::const_iterator aIterMesh = myMeshFieldsTimes.begin();
- for(;aIterMesh != myMeshFieldsTimes.end();aIterMesh++){
- QString aMeshName = aIterMesh->first;
- TFT::const_iterator aIterField = (aIterMesh->second).begin();
- for(;aIterField != (aIterMesh->second).end(); aIterField++){
- QString aFieldName = aIterField->first.first;
- if(theFieldName != aFieldName) continue;
+ TEntity2Fields::const_iterator anIter = myEntity2Fields.begin();
+ for(; anIter != myEntity2Fields.end(); anIter++){
+ const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second;
+ TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin();
+ for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){
+ const QString& aFieldName = aFieldIter->first;
+ if(theFieldName != aFieldName)
+ continue;
+
+ myTimeStampID.clear();
myTimeStampsCombo->clear();
- TTL::const_iterator aTimeIter = (aIterField->second).begin();
- for(;aTimeIter != (aIterField->second).end(); aTimeIter++)
- myTimeStampsCombo->insertItem(QString("%1").arg(aTimeIter->second));
+
+ const TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldIter->second;
+ TTimeStampNumber2Time::const_iterator aTimeStampIter = aTimeStampNumber2Time.begin();
+ for(; aTimeStampIter != aTimeStampNumber2Time.end(); aTimeStampIter++){
+ int aTimeStampNumber = aTimeStampIter->first;
+ myTimeStampID.push_back(aTimeStampNumber);
+
+ QString aTimeStampTime = aTimeStampIter->second;
+ myTimeStampsCombo->insertItem(aTimeStampTime);
+ }
return;
}
}
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){
- myPrs->SetScale(getFactor());
- vtkFloatingPointType aRange[2];
- myPrs->GetScalarMapOnDeformedShapePL()->Build();
- myPrs->GetScalarMapOnDeformedShapePL()->Update();
- myPrs->GetScalarMapOnDeformedShapePL()->GetSourceRange(aRange);
- double aDoubleRange[2];
- aDoubleRange[0] = double(aRange[0]);
- aDoubleRange[1] = double(aRange[1]);
- myScalarPane->initFromPrsObject(myPrs);
- myScalarPane->setRange(aDoubleRange[0],aDoubleRange[1],myScalarPane->isIRange());
+ GetScalarPane()->initFromPrsObject(myPrsCopy);
}
-float VisuGUI_ScalarMapOnDeformedShapeDlg::GetFloatValueOfTimeStamp(const char* theMeshName,
- const char* theFieldName,
- const int theIter,
- const VISU::TEntity theEntity){
- float ret=1;
- VISU::Result_i* theResult = myPrs->GetResult();
- VISU::PField aField = theResult->GetInput()->GetField(theMeshName,theEntity,theFieldName);
- if(!aField) return ret;
+QString
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::GetFloatValueOfTimeStamp(VISU::Entity theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber)
+{
+ QString aTime("");
+ VISU::TEntity anEntity = VISU::TEntity(theEntity);
+ VISU::Result_i* theResult = myPrsCopy->GetCResult();
+ VISU::Result_i::PInput anInput = theResult->GetInput();
+ VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(),
+ anEntity,
+ theFieldName);
+ if(!aField)
+ return aTime;
+
VISU::TValField& aValField = aField->myValField;
- VISU::TValField::const_iterator aIter = aValField.find(theIter);
+ VISU::TValField::const_iterator aIter = aValField.find(theTimeStampNumber);
if(aIter != aValField.end()){
VISU::PValForTime aValForTime = aIter->second;
- ret = float(aValForTime->myTime.first);
- } else {
- if(MYDEBUG){
- cout << "Where are no aValForTime with iteration:"<<theIter<<endl;
- cout << "\tThe possible interations is aValField.keys():";
- VISU::TValField::const_iterator aTmp = aValField.begin();
- for(;aTmp != aValField.end(); aTmp++)
- cout << aTmp->first << ",";
- cout << endl;
- }
+ aTime = VISU_Convertor::GenerateName(aValForTime->myTime).c_str();
}
- return ret;
+ return aTime;
}