// Module : VISU
#include "VisuGUI_StreamLinesDlg.h"
-#include <limits.h>
-#include <qlayout.h>
-#include <qgroupbox.h>
-#include <qcolordialog.h>
+#include "VISU_StreamLines_i.hh"
+#include "VISU_Mesh_i.hh"
+#include "VISU_Gen_i.hh"
+#include "VISU_StreamLinesPL.hxx"
+#include "VISU_Actor.h"
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
+#include "QAD_MessageBox.h"
#include "VisuGUI.h"
#include "SALOME_Selection.h"
+#include "VTKViewer_ViewFrame.h"
+
+#include <limits.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qcolordialog.h>
+using namespace std;
extern VisuGUI *visuGUI;
aSrcLayout->setSpacing( 6 );
aSrcLayout->setMargin( 0 );
- myUseSrcChk = new QCheckBox(tr("Use source presentation"), aSourceBox);
- aSrcLayout->addMultiCellWidget(myUseSrcChk, 0, 0, 0, 1);
+ QLabel* aTypeLbl = new QLabel( tr( "LBL_SOURCE_TYPE" ), aSourceBox);
+ aSrcLayout->addWidget(aTypeLbl, 0, 0);
+
+ myUseSrcCombo = new QComboBox(aSourceBox);
+ const char* aChoise[] = { "None", "Entity", "Family", "Group", "Presentation", 0 };
+ myUseSrcCombo->insertStrList(aChoise);
+ aSrcLayout->addWidget(myUseSrcCombo, 0, 1);
mySrcCombo = new QComboBox(aSourceBox);
- mySrcCombo->setEnabled(myUseSrcChk->isChecked());
+ mySrcCombo->setEnabled((myUseSrcCombo->currentItem() == 0));
+
+ connect(myUseSrcCombo, SIGNAL(activated(int)), this, SLOT(onSourceTypeChange(int)));
// Find All prs obj
QAD_Study* aActiveStudy = VisuGUI::GetActiveStudy();
Handle(SALOME_InteractiveObject) aIO = aSel->firstIObject();
if (aIO->hasEntry()){
SALOMEDS::SObject_var aSObject = VisuGUI::GetStudyDocument()->FindObjectID(aIO->getEntry());
- SALOMEDS::SComponent_var aComp = aSObject->GetFatherComponent();
- SALOMEDS::ChildIterator_var aIter = VisuGUI::GetStudyDocument()->NewChildIterator( aComp );
+ aSObject = aSObject->GetFather();
+ aSObject = aSObject->GetFather();
+ aSObject = aSObject->GetFather();
+ aSObject = aSObject->GetFather();
+ mySelectionObj = aSObject;
+ CORBA::Object_var anObject = VISU::SObjectToObject(mySelectionObj);
+ VISU::Result_var aResult;
+ if (CORBA::is_nil(anObject)) {
+ mySelectionObj = mySelectionObj->GetFather();
+ }
+ SALOMEDS::ChildIterator_var aIter = VisuGUI::GetStudyDocument()->NewChildIterator( mySelectionObj );
for (aIter->InitEx(true); aIter->More(); aIter->Next() ) {
SALOMEDS::SObject_var aChildSObj = aIter->Value();
CORBA::Object_var aChildObject = VISU::SObjectToObject( aChildSObj );
+
if(!CORBA::is_nil( aChildObject ) ) {
VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow( aChildObject );
- if( !CORBA::is_nil( aPrsObj ) ) {
- if (aPrsObj->GetType() != VISU::TSTREAMLINES) {
+ if( !CORBA::is_nil( aPrsObj ) ) { // if this is a Prs object
+ if ((aPrsObj->GetType() != VISU::TSTREAMLINES) &&
+ (aPrsObj->GetType() != VISU::TMESH)) {
SALOMEDS::GenericAttribute_var anAttr;
if ( aChildSObj->FindAttribute(anAttr, "AttributeName") ) {
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- mySrcCombo->insertItem(QString(aName->Value()));
+ myPrsLst += QString(aName->Value());
myPrsList.append(aPrsObj);
+ continue;
+ }
+ }
+ }
+ }
+ // else { // This is not a Prs object
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) {
+ SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(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::TFAMILY) || (aType == VISU::TGROUP) || (aType == VISU::TENTITY)) {
+ SALOMEDS::GenericAttribute_var aNameAttr;
+ if ( aChildSObj->FindAttribute(aNameAttr, "AttributeName") ) {
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(aNameAttr);
+ VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow( aChildObject );
+ switch(aType) {
+ case VISU::TFAMILY:
+ myFamilisLst += QString(aName->Value());
+ myFamilyList.append(aPrsObj);
+ break;
+ case VISU::TGROUP:
+ myGroupsLst += QString(aName->Value());
+ myGroupList.append(aPrsObj);
+ break;
+ case VISU::TENTITY:
+ myEntitiesLst += QString(aName->Value());
+ myEntityList.append(aPrsObj);
+ break;
+ }
}
}
}
}
}
}
-
- connect(myUseSrcChk, SIGNAL(toggled(bool)), mySrcCombo, SLOT(setEnabled(bool)));
+ // connect(myUseSrcChk, SIGNAL(toggled(bool)), mySrcCombo, SLOT(setEnabled(bool)));
aSrcLayout->addMultiCellWidget(mySrcCombo, 1, 1, 0, 1);
QLabel* aPercentLbl = new QLabel( tr( "Used points (0..1)" ), aSourceBox);
myStepLen = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 0.1);
myStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
TopLayout->addWidget(myStepLen, 1, 1);
+ connect(myStepLen, SIGNAL(valueChanged(double)), this, SLOT(StepLengthChanged(double)));
QLabel* aIntegStepLenLbl = new QLabel( tr( "Integration Step" ), this);
TopLayout->addWidget(aIntegStepLenLbl, 2, 0);
myIntegStepLen = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 0.1);
myIntegStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
TopLayout->addWidget(myIntegStepLen, 2, 1);
+ connect(myIntegStepLen, SIGNAL(valueChanged(double)), this, SLOT(IntegrationStepChanged(double)));
QLabel* aPropagationLbl = new QLabel( tr( "Propagation Time" ), this);
TopLayout->addWidget(aPropagationLbl, 3, 0);
myPropTime = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 1);
myPropTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
TopLayout->addWidget(myPropTime, 3, 1);
-
connect(myPropTime, SIGNAL(valueChanged(double)), this, SLOT(PropagationTimeChanged(double)));
QLabel* aDirLbl = new QLabel( tr( "Direction" ), this);
void VisuGUI_StreamLinesDlg::initFromPrsObject(VISU::StreamLines_i* thePrs) {
+ myPropTime->setValue(thePrs->GetPropagationTime());
+
+ myStepLen->setRange(VISU_StreamLinesPL::GetMinStepLength(thePrs->GetIntegrationStep()),
+ VISU_StreamLinesPL::GetMaxStepLength(thePrs->GetPropagationTime()));
myStepLen->setValue(thePrs->GetStepLength());
+
+ myIntegStepLen->setRange(thePrs->GetMinIntegrationStep(),thePrs->GetMaxIntegrationStep());
myIntegStepLen->setValue(thePrs->GetIntegrationStep());
- myPropTime->setValue(thePrs->GetPropagationTime());
+
switch (thePrs->GetDirection()) {
case VISU::StreamLines::FORWARD:
myDirCombo->setCurrentItem(0);
case VISU::StreamLines::BOTH:
myDirCombo->setCurrentItem(2);
}
- myUseScalar->setChecked(thePrs->isColored());
+ myUseScalar->setChecked(thePrs->IsColored());
myPntPercent->setValue(thePrs->GetUsedPoints());
-
- myUseSrcChk->setChecked(false);
+
+ mySrcCombo->setEnabled(false);
QString aSrcEntry = thePrs->GetSourceEntry();
- if (!aSrcEntry.isEmpty()) {
- for (int i = 0; i < myPrsList.count(); i++) {
- VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(myPrsList[i]));
- if (aSrcEntry == aPrs->GetEntry()) {
- myUseSrcChk->setChecked(true);
- mySrcCombo->setCurrentItem(i);
- break;
- }
- }
- }
-
+
SALOMEDS::Color anOldColor = thePrs->GetColor();
QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
setColor(aColor);
enableSetColor();
+
+#define INITPRS(PRSLIST, PRSNUM) \
+ for (int i = 0; i < PRSLIST.count(); i++) { \
+ VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(PRSLIST[i])); \
+ if (aPrs == NULL) continue; \
+ if (aSrcEntry == aPrs->GetEntry()) { \
+ onSourceTypeChange(PRSNUM); \
+ myUseSrcCombo->setCurrentItem(PRSNUM); \
+ mySrcCombo->setEnabled(true); \
+ mySrcCombo->setCurrentItem(i); \
+ return; \
+ } \
+ }
+
+ if (!aSrcEntry.isEmpty()) {
+ INITPRS(myEntityList, 1);
+ INITPRS(myFamilyList, 2);
+ INITPRS(myGroupList, 3);
+ INITPRS(myPrsList, 4);
+ }
+
+#undef INITPRS
- myIntegStepLen->setMaxValue(thePrs->GetMaxIntegrationStep());
- myIntegStepLen->setMinValue(thePrs->GetMinIntegrationStep());
- myStepLen->setMaxValue(myPropTime->value());
- myStepLen->setMinValue(myPropTime->value()/10000.);
}
void VisuGUI_StreamLinesDlg::storeToPrsObject(VISU::StreamLines_i* thePrs) {
- thePrs->SetStepLength(myStepLen->value());
+ //Order of setting of the values are important
thePrs->SetIntegrationStep(myIntegStepLen->value());
thePrs->SetPropagationTime(myPropTime->value());
+ thePrs->SetStepLength(myStepLen->value());
switch (myDirCombo->currentItem()) {
case 0:
thePrs->SetDirection(VISU::StreamLines::FORWARD);
case 2:
thePrs->SetDirection(VISU::StreamLines::BOTH);
}
- thePrs->setColored(myUseScalar->isChecked());
- if(!thePrs->isColored()){
+ thePrs->ShowColored(myUseScalar->isChecked());
+ if(!thePrs->IsColored()){
SALOMEDS::Color aColor;
aColor.R = myColor.red()/255.;
aColor.G = myColor.green()/255.;
aColor.B = myColor.blue()/255.;
thePrs->SetColor(aColor);
}
- if (myUseSrcChk->isChecked() && (myPrsList.count() > 0)) {
- thePrs->SetSource(myPrsList[mySrcCombo->currentItem()]);
- } else
- thePrs->SetSource(VISU::Prs3d::_nil());
thePrs->SetUsedPoints(myPntPercent->value());
+
+ int aSrcSelection = myUseSrcCombo->currentItem();
+ int aSrcItem = (mySrcCombo->count() > 0)? mySrcCombo->currentItem() : -1;
+ if ((aSrcSelection > 0) && (aSrcItem > -1)) {
+ VISU::Prs3d_var aPrs;
+ VISU::VISUType aType;
+ QString aName;
+ switch (aSrcSelection){
+ case 1: // Entity
+ aPrs = myEntityList[aSrcItem];
+ aType = VISU::TENTITY;
+ aName = myEntitiesLst[aSrcItem];
+ break;
+ case 2: // Family
+ aPrs = myFamilyList[aSrcItem];
+ aType = VISU::TFAMILY;
+ aName = myFamilisLst[aSrcItem];
+ break;
+ case 3: // Group
+ aPrs = myGroupList[aSrcItem];
+ aType = VISU::TGROUP;
+ aName = myGroupsLst[aSrcItem];
+ break;
+ case 4: // Presentation
+ aPrs = myPrsList[aSrcItem];
+ break;
+ }
+ if (!CORBA::is_nil( aPrs )) {
+ thePrs->SetSource(aPrs);
+ } else if (aSrcSelection == 4) {
+ thePrs->SetSource(VISU::Prs3d::_nil());
+ } else { // Create Mesh presentation
+ thePrs->SetSource(createMesh(aType, aName));
+ }
+ } else
+ thePrs->SetSource(VISU::Prs3d::_nil());
}
/*!
SelColor->setEnabled(!myUseScalar->isChecked() );
}
+void VisuGUI_StreamLinesDlg::StepLengthChanged(double theValue){
+}
+
+void VisuGUI_StreamLinesDlg::IntegrationStepChanged(double theValue) {
+ PropagationTimeChanged(myPropTime->value());
+}
+
void VisuGUI_StreamLinesDlg::PropagationTimeChanged(double theValue) {
- myStepLen->setMaxValue(theValue);
- myStepLen->setMinValue(theValue/1000000.);
+ myStepLen->setMinValue(VISU_StreamLinesPL::GetMinStepLength(myIntegStepLen->value()));
+ myStepLen->setMaxValue(VISU_StreamLinesPL::GetMaxStepLength(myPropTime->value()));
+}
+
+void VisuGUI_StreamLinesDlg::onSourceTypeChange(int theIndex) {
+ mySrcCombo->clear();
+ if (theIndex == 0) {
+ mySrcCombo->setEnabled(false);
+ return;
+ } else
+ mySrcCombo->setEnabled(true);
+
+ switch(theIndex) {
+ case 1: // Entity
+ mySrcCombo->insertStringList(myEntitiesLst);
+ return;
+ case 2: // Family
+ mySrcCombo->insertStringList(myFamilisLst);
+ return;
+ case 3: // Group
+ mySrcCombo->insertStringList(myGroupsLst);
+ return;
+ case 4: // Presentation
+ mySrcCombo->insertStringList(myPrsLst);
+ return;
+ }
}
+
+VISU::Mesh_var VisuGUI_StreamLinesDlg::createMesh(VISU::VISUType theType, QString theName) {
+ CORBA::Object_var anObject = VISU::SObjectToObject(mySelectionObj);
+ VISU::Result_var aResult;
+ if (!CORBA::is_nil(anObject)) {
+ aResult = VISU::Result::_narrow(anObject);
+ }
+ if(CORBA::is_nil(aResult)) {
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("WRN_NO_AVAILABLE_DATA"),
+ tr ("VISU_BUT_OK"));
+ return VISU::Mesh::_nil();
+ }
+ SALOMEDS::ChildIterator_var aIter = VisuGUI::GetStudyDocument()->NewChildIterator( mySelectionObj );
+ VISU::Storable::TRestoringMap aMap;
+
+ for (aIter->InitEx(true); aIter->More(); aIter->Next() ) {
+ SALOMEDS::SObject_var aChildSObj = aIter->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) {
+ SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+ CORBA::String_var aComm = aComment->Value();
+ QString strIn(aComm.in());
+ aMap.clear();
+ VISU::Storable::StrToMap(strIn,aMap);
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if (isExist) {
+ if (aType != theType) continue;
+
+ SALOMEDS::GenericAttribute_var aNameAttr;
+ if ( aChildSObj->FindAttribute(aNameAttr, "AttributeName") ) {
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(aNameAttr);
+ if (QString(aName->Value()) == theName) break; //use current map
+ }
+ }
+ }
+ }
+ CORBA::Object_var aMesh;
+ QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName");
+ switch (theType) {
+ case VISU::TFAMILY:
+ {
+ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
+ aMesh = VisuGUI::GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.latin1(),anEntity,theName.latin1());
+ }
+ break;
+ case VISU::TGROUP:
+ {
+ aMesh = VisuGUI::GetVisuGen()->GroupMesh(aResult,aMeshName.latin1(), theName.latin1());
+ }
+ break;
+ case VISU::TENTITY:
+ {
+ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
+ aMesh = VisuGUI::GetVisuGen()->MeshOnEntity(aResult,aMeshName.latin1(),anEntity);
+ }
+ break;
+ }
+ VISU::Mesh_i* pPresent = NULL;
+ if(!CORBA::is_nil(aMesh))
+ pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
+ if (pPresent == NULL) {
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_CANT_BUILD_PRESENTATION"),
+ tr ("VISU_BUT_OK") );
+ return VISU::Mesh::_nil();
+ }
+ // Create Actor
+ if(VTKViewer_ViewFrame* vf = visuGUI->GetVtkViewFrame()){
+ try{
+ pPresent->SetPresentationType(VISU::POINT);
+ VISU_Actor *anActor = pPresent->CreateActor();
+ vf->AddActor(anActor);
+ }catch(std::runtime_error& exc){
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
+ tr ("ERR_CANT_CREATE_ACTOR"),
+ tr ("VISU_BUT_OK") );
+ }
+ }
+ return pPresent->_this();
+}