1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : VisuGUI_CutLinesDlg.cxx
11 #include "VisuGUI_CutLinesDlg.h"
14 #include "VisuGUI_Tools.h"
15 #include "VisuGUI_ViewTools.h"
17 #include "VISU_Gen_i.hh"
18 #include "VISU_CutLines_i.hh"
20 #include "VISU_PipeLine.hxx"
21 #include "VISU_PipeLineUtils.hxx"
22 #include "VISU_CutLinesPL.hxx"
24 #include "SVTK_ViewWindow.h"
26 #include "LightApp_Application.h"
27 #include "SalomeApp_Study.h"
29 #include "SUIT_Desktop.h"
30 #include "SUIT_Session.h"
31 #include "SUIT_MessageBox.h"
32 #include "SUIT_ResourceMgr.h"
34 #include "OB_Browser.h"
38 #include <qtabwidget.h>
39 #include <qhgroupbox.h>
41 #include <vtkRenderer.h>
42 #include <vtkPolyData.h>
43 #include <vtkAppendPolyData.h>
44 #include <vtkDataSetMapper.h>
45 #include <vtkGlyph3D.h>
46 #include <vtkPolyDataMapper.h>
47 #include <vtkFloatArray.h>
48 #include <vtkGlyphSource2D.h>
52 bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
53 bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
55 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
56 : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
57 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
58 myPreviewActor(0),myPreviewActorGlyphs(0)
60 setCaption("Cut Lines Definition");
61 setSizeGripEnabled(true);
63 QVBoxLayout* aMainLayout = new QVBoxLayout (this, 7, 6);
64 aMainLayout->setSpacing(5);
69 QTabWidget* aTabPane = new QTabWidget(this);
72 QFrame* aPlanePane = new QFrame(this);
73 QVBoxLayout* aPlaneLayout = new QVBoxLayout(aPlanePane, 5, 6);
75 mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane);
76 mySelPlane->setInsideSpacing( 5 );
77 mySelPlane->setInsideMargin( 5 );
79 QRadioButton* aBxy = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane); // 0
80 QRadioButton* aByz = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane); // 1
81 QRadioButton* aBzx = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane); // 2
82 aBxy->setChecked(false);
83 aByz->setChecked(false);
84 aBzx->setChecked(true);
86 aPlaneLayout->addWidget( mySelPlane );
88 QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
89 aRotBox->setColumnLayout(2, Qt::Horizontal );
91 myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox);
92 myRotXSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
93 myRotXSpn->setValue( 0 );
94 myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox );
95 myRotYSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
96 myRotYSpn->setValue( 0 );
98 aPlaneLayout->addWidget( aRotBox );
100 QHGroupBox* aBaseBox = new QHGroupBox (tr("BASE_PLANE_POS"), aPlanePane);
101 myBasePlanePos = new QLineEdit (aBaseBox);
102 mydvalidator = new QDoubleValidator(this);
103 mydvalidator->setDecimals(32);
104 myBasePlanePos->setValidator(mydvalidator);
106 myCBSetDef = new QCheckBox (tr("SET_DEFAULT"),aBaseBox);
108 aPlaneLayout->addWidget(aBaseBox);
110 QHBox* aPosBox = new QHBox (aPlanePane);
111 aPosBox->setSpacing(5);
112 new QLabel (tr("LBL_POS"), aPosBox);
113 myPosSpn = new QtxDblSpinBox (0, 1, 0.1, aPosBox);
114 myPosSpn->setValue(0.5);
115 aPlaneLayout->addWidget(aPosBox);
117 myPreviewCheck = new QCheckBox (tr("LBL_SHOW_PREVIEW"), aPlanePane);
118 myPreviewCheck->setChecked(false);
119 aPlaneLayout->addWidget(myPreviewCheck);
121 myAllCurvesInvertedCheck = new QCheckBox(tr("LBL_INVERT_CURVES"), aPlanePane);
122 myAllCurvesInvertedCheck->setChecked(false);
123 aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
125 myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
126 myCreateTable->setChecked(MYGenerateTable);
127 aPlaneLayout->addWidget( myCreateTable );
129 QHBox* aCheckPane = new QHBox(aPlanePane);
130 QLabel* aLbl = new QLabel(" ", aCheckPane);
131 aCheckPane->setStretchFactor(aLbl, 0);
132 myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane);
133 aCheckPane->setStretchFactor(aCheckPane, 0);
134 myCurvesCheck->setChecked(MYGenerateCurve);
135 myCurvesCheck->setEnabled(MYGenerateTable);
136 QLabel* aLbl2 = new QLabel(" ", aCheckPane);
137 aCheckPane->setStretchFactor(aLbl2, 1);
138 aPlaneLayout->addWidget( aCheckPane );
140 aPlaneLayout->addStretch();
143 aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
146 QFrame* aLinesPane = new QFrame(this);
147 QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 );
149 mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane);
150 mySelPlane2->setInsideSpacing( 5 );
151 mySelPlane2->setInsideMargin( 5 );
153 QRadioButton* aBxy2 = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane2); // 0
154 QRadioButton* aByz2 = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane2); // 1
155 QRadioButton* aBzx2 = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane2); // 2
156 aBzx2->setEnabled(false);
157 aByz2->setChecked(true);
158 aLinesLayout->addWidget( mySelPlane2 );
160 QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
161 aRotBox2->setColumnLayout(2, Qt::Horizontal );
163 myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2);
164 myRotXSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
165 myRotXSpn2->setValue( 0 );
166 myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 );
167 myRotYSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
168 myRotYSpn2->setValue( 0 );
169 aLinesLayout->addWidget( aRotBox2 );
171 QHBox* aNbBox = new QHBox(aLinesPane);
172 aNbBox->setSpacing(5);
173 new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
174 myNbSpn = new QtxDblSpinBox( 1, 100, 1, aNbBox );
175 myNbSpn->setValue( 10 );
177 aLinesLayout->addWidget( aNbBox );
179 myPosTable = new QTable(aLinesPane, "Positions of cut planes" );
180 myPosTable->setMaximumHeight( 227 );
181 myPosTable->setMinimumWidth( 294 );
182 myPosTable->setNumCols(2);
183 myPosTable->setNumRows(0);
185 QHeader *th = myPosTable->horizontalHeader();
186 th->setLabel( 0, "Position" );
187 th->setLabel( 1, "Set default" );
189 aLinesLayout->addWidget( myPosTable );
191 QHBox* aPosBox2 = new QHBox(aLinesPane);
192 aPosBox2->setSpacing(5);
193 new QLabel( tr( "LBL_POS" ), aPosBox2 );
194 myPosSpn2 = new QtxDblSpinBox( 0, 1, 0.1, aPosBox2 );
195 myPosSpn2->setValue( 0.5 );
196 aLinesLayout->addWidget( aPosBox2 );
197 aLinesLayout->addStretch();
199 aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
201 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
202 myScalarPane->setMargin( 5 );
203 aTabPane->addTab(myScalarPane, "Scalar Bar");
205 aMainLayout->addWidget(aTabPane);
208 QHBox* aBtnBox = new QHBox(this);
209 aBtnBox->setFrameStyle(QFrame::Box | QFrame::Sunken);
210 aBtnBox->setLineWidth( 1 );
211 QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout();
212 aBtnLayout->setAutoAdd( false );
213 aBtnLayout->setSpacing( 5 );
214 aBtnLayout->setMargin( 11 );
216 QPushButton* aOkBtn = new QPushButton (tr("BUT_OK"), aBtnBox);
217 aOkBtn->setAutoDefault( TRUE );
218 aOkBtn->setDefault( true );
219 aBtnLayout->addWidget(aOkBtn);
221 aBtnLayout->addStretch();
223 QPushButton* aCloseBtn = new QPushButton(tr("BUT_CANCEL"), aBtnBox);
224 aBtnLayout->addWidget(aCloseBtn);
226 QPushButton* aHelpBtn = new QPushButton(tr("BUT_HELP"), aBtnBox);
227 aBtnLayout->addWidget(aHelpBtn);
229 aMainLayout->addWidget(aBtnBox);
233 // signals and slots connections
234 connect(mySelPlane , SIGNAL(clicked(int)) , this, SLOT(onPlaneSelect(int)));
235 connect(myCBSetDef , SIGNAL(toggled(bool)) , this, SLOT(setBaseDefault()));
236 connect(myPosSpn , SIGNAL(valueChanged(double)) , this, SLOT(setBaseDefault()));
237 connect(mySelPlane2 , SIGNAL(clicked(int)) , this, SLOT(onCutSelect(int)));
238 connect(myNbSpn , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
239 connect(th , SIGNAL(clicked(int)) , this, SLOT(setDefault(int)));
240 connect(myPosSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
241 connect(myPreviewCheck, SIGNAL(toggled(bool)) , this, SLOT(onPreviewCheck(bool)));
242 connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool)));
243 connect(myPosTable , SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)));
244 connect(myRotXSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
245 connect(myRotYSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
246 connect(myRotXSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
247 connect(myRotYSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
248 connect(myBasePlanePos, SIGNAL(textChanged(const QString&)), this, SLOT(onPlanePos(const QString&)));
249 connect(myCreateTable , SIGNAL(toggled(bool)), myCurvesCheck, SLOT(setEnabled(bool)));
251 connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
252 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
253 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
254 //connect(myMgr, SIGNAL(closeAllViews()), this, SLOT(reject()));
255 //connect(VisuGUI::application()->desktop(),
256 // SIGNAL(windowActivated(SUIT_ViewWindow*)),
257 // this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
263 VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg()
265 cout<<"### VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg"<<endl;
267 if (myCutLines) //delete myCutLines;
268 myCutLines->Destroy();
269 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
273 //------------------------------------------------------------------------------
274 void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
277 myScalarPane->initFromPrsObject(thePrs);
279 myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
280 myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
281 myPosSpn->setValue(thePrs->GetDisplacement());
282 setOrientation(thePrs->GetOrientationType());
284 myNbSpn->setValue( (int)thePrs->GetNbLines() );
285 myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
286 myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
287 myPosSpn2->setValue(thePrs->GetDisplacement2());
288 setOrientation2(thePrs->GetOrientationType2());
291 myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
292 myCutLines->SameAs(thePrs);
293 myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
294 if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
295 myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
296 myCBSetDef->setChecked(thePrs->IsDefault());
300 if (myPreviewCheck->isChecked()) {
305 //------------------------------------------------------------------------------
306 int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
308 myScalarPane->storeToPrsObject(thePrs);
310 thePrs->SetOrientation(getOrientaion(),
311 myRotXSpn->value()*PI/180.,
312 myRotYSpn->value()*PI/180.);
313 thePrs->SetDisplacement(myPosSpn->value());
314 thePrs->SetNbLines((int)myNbSpn->value());
316 thePrs->SetOrientation2(getOrientaion(false),
317 myRotXSpn2->value()*PI/180.,
318 myRotYSpn2->value()*PI/180.);
319 thePrs->SetDisplacement2(myPosSpn2->value());
321 if (!myCBSetDef->isChecked())
322 thePrs->SetBasePlanePosition(myBasePlanePos->text().toDouble());
323 else thePrs->SetDefault();
325 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
326 if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked())
327 thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
328 else thePrs->SetDefaultPosition(i);
330 if (myAllCurvesInvertedCheck->isChecked())
331 thePrs->SetAllCurvesInverted(true);
335 //------------------------------------------------------------------------------
336 void VisuGUI_CutLinesDlg::createPlanes()
338 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
339 if (aView == NULL) return;
340 if (myCutLines == NULL) return;
341 if (myPreviewActor != 0) return;
343 storeToPrsObject(myCutLines);
344 myCutLines->GetPL()->Update();
345 vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
346 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
347 aPlaneMapper->SetInput(aPolyData->GetOutput());
348 aPlaneMapper->ScalarVisibilityOff();
350 myPreviewActorGlyphs = SALOME_Actor::New();
351 myPreviewActorGlyphs->PickableOff();
354 myPreviewActor = SALOME_Actor::New();
355 myPreviewActor->PickableOff();
356 myPreviewActor->SetMapper(aPlaneMapper);
357 aPlaneMapper->Delete();
358 aView->AddActor(myPreviewActor);
359 aView->AddActor(myPreviewActorGlyphs);
360 aView->getRenderer()->Render();
364 //------------------------------------------------------------------------------
365 void VisuGUI_CutLinesDlg::deletePlanes()
367 if (myPreviewActor == 0) return;
368 SVTK_ViewWindow* aView;
369 vtkRenderer* aRend = myPreviewActor->GetRenderer();
370 vtkRenderer* aRendGlyphs = myPreviewActorGlyphs->GetRenderer();
372 myPreviewActor->RemoveFromRender(aRend);
374 myPreviewActorGlyphs->RemoveFromRender(aRendGlyphs);
376 // Bug IPAL11962: preview is still in the viewer, if viewer not active.
377 // if (aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>()){
378 // aView->RemoveActor(myPreviewActor);
379 // aView->RemoveActor(myPreviewActorGlyphs);
382 myPreviewActor->Delete();
383 myPreviewActorGlyphs->Delete();
385 myPreviewActorGlyphs = 0;
389 //------------------------------------------------------------------------------
390 void VisuGUI_CutLinesDlg::onPlaneSelect (int theId)
392 for (int i = 0; i < mySelPlane2->count(); i++)
393 mySelPlane2->find(i)->setEnabled(true);
394 QButton* aBtn = mySelPlane2->find(theId);
395 aBtn->setEnabled(false);
398 myRotXLbl->setText( tr("LBL_ROT_X"));
399 myRotYLbl->setText( tr("LBL_ROT_Y"));
400 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
401 onCutSelect(1, false);
404 myRotXLbl->setText( tr("LBL_ROT_Y"));
405 myRotYLbl->setText( tr("LBL_ROT_Z"));
406 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
407 onCutSelect(2, false);
410 myRotXLbl->setText( tr("LBL_ROT_Z"));
411 myRotYLbl->setText( tr("LBL_ROT_X"));
412 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
413 onCutSelect(0, false);
415 setBaseDefault(false);
419 //------------------------------------------------------------------------------
420 void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate)
424 myRotXLbl2->setText( tr("LBL_ROT_X"));
425 myRotYLbl2->setText( tr("LBL_ROT_Y"));
428 myRotXLbl2->setText( tr("LBL_ROT_Y"));
429 myRotYLbl2->setText( tr("LBL_ROT_Z"));
432 myRotXLbl2->setText( tr("LBL_ROT_Z"));
433 myRotYLbl2->setText( tr("LBL_ROT_X"));
435 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
437 if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
438 /*myCutLines->SetOrientation2(getOrientaion(false),
439 myRotXSpn2->value()*PI/180.,
440 myRotYSpn2->value()*PI/180.);
441 myCutLines->SetDisplacement2(myPosSpn2->value());*/
442 //myCutLines->GetPL()->Update();
450 //------------------------------------------------------------------------------
451 void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate)
453 if (!hasInit) return;
455 if (myCBSetDef->isChecked()) {
456 if (!myCutLines->IsDefault()) myCutLines->SetDefault();
457 /*myCutLines->SetOrientation(getOrientaion(),
458 myRotXSpn->value()*PI/180.,
459 myRotYSpn->value()*PI/180.);
460 myCutLines->SetDisplacement(myPosSpn->value());*/
461 /* float aPos = myCutLines->GetBasePlanePosition();
462 myBasePlanePos->setText( QString::number(aPos) );
463 myBasePlanePos->setEnabled(false);*/
464 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
466 if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
467 //myCutLines->SetBasePlanePosition(aPos);
468 // myCutLines->GetPL()->Update();
474 vtkFloatingPointType aPos = myCutLines->GetBasePlanePosition();
475 myBasePlanePos->setText( QString::number(aPos) );
476 myBasePlanePos->setEnabled(false);
478 myBasePlanePos->setEnabled(true);
482 //------------------------------------------------------------------------------
483 void VisuGUI_CutLinesDlg::DrawTable()
485 if (!hasInit) return;
487 int aNbRows = myPosTable->numRows();
488 int aNbPlanes = (int)myNbSpn->value();
490 myCutLines->SetOrientation(getOrientaion(),
491 myRotXSpn->value()*PI/180.,
492 myRotYSpn->value()*PI/180.);
494 myCutLines->SetNbLines(aNbPlanes);
495 myCutLines->SetDisplacement2(myPosSpn2->value());
496 myCutLines->SetOrientation2(getOrientaion(false),
497 myRotXSpn2->value()*PI/180.,
498 myRotYSpn2->value()*PI/180.);
501 for (int i = 0; i < aNbRows; ++i) {
502 QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
503 if (aItem == 0) break;
504 if (!aItem->isChecked())
505 myCutLines->SetLinePosition(i, myPosTable->text(i, 0).toDouble());
508 if (aNbPlanes > aNbRows)
509 myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
510 else if (aNbPlanes < aNbRows)
511 myPosTable->setNumRows(aNbPlanes);
513 int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
514 for (int i = 0; i<aMin; i++) {
515 myPosTable->setText(i, 0, QString::number(myCutLines->GetLinePosition(i)));
516 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutLines->IsDefaultPosition(i));
519 QHeader *vh = myPosTable->verticalHeader();
520 QString str("Plane# %1");
521 for (int i=aMin; i<aNbPlanes; i++) {
522 VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem
523 (myPosTable, QTableItem::OnTyping, QString::number(myCutLines->GetLinePosition(i)));
524 aEditItem->setReplaceable(false);
525 aEditItem->setEnabled(!myCutLines->IsDefaultPosition(i));
526 myPosTable->setItem(i, 0, aEditItem);
528 QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
529 aCheck->setChecked(myCutLines->IsDefaultPosition(i));
530 aCheck->setReplaceable(false);
531 myPosTable->setItem(i, 1, aCheck);
533 vh->setLabel( i, str.arg(i+1) );
536 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
538 if (myPreviewCheck->isChecked()) {
539 // myCutLines->GetPL()->Update();
547 void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
548 if (myPreviewActorGlyphs == 0 ) return;
549 const vtkFloatingPointType *aDirLn = myCutLines->GetCutLinesPL()->GetRealDirLn();
550 const vtkFloatingPointType *aBasePnt = myCutLines->GetCutLinesPL()->GetBasePnt();
551 vtkFloatingPointType aSecondPnt[3];
552 vtkFloatingPointType aBoundCenter[3];
554 vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
555 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
556 aPlaneMapper->SetInput(aPolyData->GetOutput());
557 vtkFloatingPointType bounds[6];
558 aPlaneMapper->GetBounds(bounds);
560 for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0;
561 for(int i=0; i<3; i++){
562 if (!myAllCurvesInvertedCheck->isChecked())
563 aSecondPnt[i] = aBasePnt[i] + aDirLn[i];
565 aSecondPnt[i] = -aBasePnt[i] - aDirLn[i];
568 vtkFloatingPointType max_bound = 0;
569 max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound;
570 max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound;
571 max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound;
573 vtkPolyData* profile = vtkPolyData::New();
574 vtkPoints* aPoints = vtkPoints::New();
575 vtkGlyph3D* glyphs = vtkGlyph3D::New();
576 vtkFloatArray *aFloatArray = vtkFloatArray::New();
577 vtkGlyphSource2D* source = vtkGlyphSource2D::New();
580 source->SetGlyphTypeToArrow();
582 aPoints->InsertNextPoint(aBoundCenter);
583 profile->SetPoints(aPoints);
585 aFloatArray->SetNumberOfComponents(3);
586 for(int i=0; i<3 ;i++)
587 aFloatArray->InsertNextValue(aSecondPnt[i]);
589 vtkDataSetAttributes* aDataSetAttributes;
590 aDataSetAttributes = profile->GetPointData();
591 aDataSetAttributes->SetVectors(aFloatArray);
593 glyphs->SetScaleFactor(0.25*max_bound);
594 glyphs->SetVectorModeToUseVector();
595 glyphs->SetScaleModeToScaleByVector();
596 glyphs->SetInput(profile);
597 glyphs->SetSource(source->GetOutput());
599 vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New();
600 aGlyphsMapper->ScalarVisibilityOff();
601 aGlyphsMapper->SetInput(glyphs->GetOutput());
603 myPreviewActorGlyphs->SetMapper(aGlyphsMapper);
608 aGlyphsMapper->Delete();
609 aFloatArray->Delete();
611 aPlaneMapper->Delete();
613 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
618 //------------------------------------------------------------------------------
619 void VisuGUI_CutLinesDlg::setDefault (int all)
621 myPosTable->setCurrentCell(-1, 1);
622 myPosTable->clearSelection();
623 if (all == 0) return;
625 for (int i = 0; i < (int)myNbSpn->value(); ++i)
626 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
628 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
629 if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
630 myCutLines->SetDefaultPosition(i);
631 myPosTable->setText( i, 0, QString::number(myCutLines->GetLinePosition(i)));
632 myPosTable->item( i, 0 )->setEnabled(false);
634 myPosTable->item( i, 0 )->setEnabled(true);
638 //------------------------------------------------------------------------------
639 VISU::CutPlanes::Orientation VisuGUI_CutLinesDlg::getOrientaion (bool IsBasePlane)
648 VISU::CutPlanes::Orientation orient;
649 switch (aBG->id(aBG->selected())) {
651 orient = VISU::CutPlanes::XY;
654 orient = VISU::CutPlanes::YZ;
657 orient = VISU::CutPlanes::ZX;
662 //------------------------------------------------------------------------------
663 void VisuGUI_CutLinesDlg::setOrientation (const VISU::CutPlanes::Orientation orient)
666 case VISU::CutPlanes::XY:
667 ((QRadioButton*)mySelPlane->find(0))->setChecked(true);
670 case VISU::CutPlanes::YZ:
671 ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
674 case VISU::CutPlanes::ZX:
675 ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
680 //------------------------------------------------------------------------------
681 void VisuGUI_CutLinesDlg::setOrientation2 (const VISU::CutPlanes::Orientation orient)
684 case VISU::CutPlanes::XY:
685 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
688 case VISU::CutPlanes::YZ:
689 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
692 case VISU::CutPlanes::ZX:
693 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
698 void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
701 QString aTxt = myPosTable->text(theRow, 0);
702 bool isChanged = !aTxt.isEmpty();
703 ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
704 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
706 if (myPreviewCheck->isChecked()) {
708 //myCutLines->SetLinePosition( theRow, aTxt.toDouble());
709 // myCutLines->GetPL()->Update();
715 } else if (theCol == 1){
716 bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
718 //myCutLines->SetDefaultPosition(theRow);
719 // myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
720 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
722 if (myPreviewCheck->isChecked()) {
724 // myCutLines->GetPL()->Update();
730 myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
732 myPosTable->item(theRow, 0)->setEnabled(!isDefault);
736 void VisuGUI_CutLinesDlg::accept()
738 //if ( !VisuGUI::CheckActiveStudyLock() ) {
742 MYGenerateTable = myCreateTable->isChecked();
743 MYGenerateCurve = myCurvesCheck->isChecked();
744 // if (myScalarPane->check()) {
745 /*jfa tmp:((QWidget*)sender())->setDisabled(true);
746 storeToPrsObject(myPrs);
748 if (isGenerateTable()) {
749 visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
750 if (isGenerateCurves()) {
751 SALOMEDSClient_Study* aStudy = study()->studyDS();
752 SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
754 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
755 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
756 for ( ;aIter->More(); aIter->Next()) {
757 SALOMEDSClient_SObject* aTblObj = aIter->Value();
759 SALOMEDSClient_GenericAttribute* anAttr;
760 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
761 visuGUI->CreatePlot(aTblObj);
768 if (GET_VTK_VIEWWINDOW(myMgr)) {
770 visuGUI->CreateActor(myPrs);
775 GET_VTK_VIEWWINDOW(myMgr)->onFitAll();
778 visuGUI->RecreateActor(myPrs);
779 if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
780 if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
781 vf->getRenderer()->ResetCameraClippingRange();
786 SALOMEDSClient_Study* aStudy = study()->studyDS();
787 SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
789 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
790 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
791 for ( ;aIter->More(); aIter->Next()) {
792 SALOMEDSClient_SObject* aTblObj = aIter->Value();
794 SALOMEDSClient_GenericAttribute* anAttr;
795 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
796 aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
801 if (isGenerateTable()) {
802 visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str());
803 if (isGenerateCurves()) {
804 SALOMEDSClient_Study* aStudy = study()->studyDS();
805 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
806 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
807 for ( ;aIter->More(); aIter->Next()) {
808 SALOMEDSClient_SObject* aTblObj = aIter->Value();
810 SALOMEDSClient_GenericAttribute* anAttr;
811 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
812 visuGUI->CreatePlot(aTblObj);
820 VisuGUI::application()->objectBrowser()->updateTree();*/
821 myScalarPane->deletePreview();
827 void VisuGUI_CutLinesDlg::reject()
829 /*jfa tmp:if (myIsCreation) {
830 myPrs->RemoveFromStudy();
831 VisuGUI::application()->objectBrowser()->updateTree();
833 myScalarPane->deletePreview();
838 void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview)
840 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
842 //storeToPrsObject(myCutLines);
843 // myCutLines->GetPL()->Update();
853 /*! Inverting all curves in the table
855 void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert)
857 if (myAllCurvesInvertedCheck->isChecked()){
858 myCutLines->SetAllCurvesInverted(true);
859 myPrs->SetAllCurvesInverted(true);
862 myCutLines->SetAllCurvesInverted(false);
863 myPrs->SetAllCurvesInverted(false);
868 void VisuGUI_CutLinesDlg::onRotation (double theValue)
870 if (myCutLines == NULL) return;
871 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
873 if (myPreviewCheck->isChecked()) {
875 /*myCutLines->SetOrientation(getOrientaion(),
876 myRotXSpn->value()*PI/180.,
877 myRotYSpn->value()*PI/180.);
878 myCutLines->SetOrientation2(getOrientaion(false),
879 myRotXSpn2->value()*PI/180.,
880 myRotYSpn2->value()*PI/180.);*/
881 // myCutLines->GetPL()->Update();
889 void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue)
891 if (myCutLines == NULL) return;
892 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
894 if (myPreviewCheck->isChecked()) {
895 //myCutLines->SetBasePlanePosition(theValue.toDouble());
896 // myCutLines->GetPL()->Update();
904 void VisuGUI_CutLinesDlg::onHelp()
906 QString aHelpFileName = "/files/cut_lines_presentation.htm";
907 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
909 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
910 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
913 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
914 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
915 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
916 QObject::tr("BUT_OK"));
920 //jfa tmp:void VisuGUI_CutLinesDlg::onWindowActivated (SUIT_ViewWindow* theWnd)
922 //jfa tmp: if (theWnd != myStudyWnd)