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"
16 #include "VISU_Gen_i.hh"
17 #include "VISU_CutLines_i.hh"
19 #include "VISU_PipeLine.hxx"
20 #include "VISU_PipeLineUtils.hxx"
21 #include "VISU_CutLinesPL.hxx"
23 #include "SVTK_ViewWindow.h"
25 #include "SalomeApp_Application.h"
26 #include "SalomeApp_Study.h"
28 #include "SUIT_Desktop.h"
30 #include "OB_Browser.h"
34 #include <qtabwidget.h>
35 #include <qhgroupbox.h>
37 #include <vtkRenderer.h>
38 #include <vtkPolyData.h>
39 #include <vtkAppendPolyData.h>
40 #include <vtkDataSetMapper.h>
41 #include <vtkGlyph3D.h>
42 #include <vtkPolyDataMapper.h>
43 #include <vtkFloatArray.h>
44 #include <vtkGlyphSource2D.h>
48 bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
49 bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
51 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
52 : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
53 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
54 myPreviewActor(0),myPreviewActorGlyphs(0)
56 setCaption("Cut Lines Definition");
57 setSizeGripEnabled(true);
59 QVBoxLayout* aMainLayout = new QVBoxLayout (this, 7, 6);
60 aMainLayout->setSpacing(5);
65 QTabWidget* aTabPane = new QTabWidget(this);
68 QFrame* aPlanePane = new QFrame(this);
69 QVBoxLayout* aPlaneLayout = new QVBoxLayout(aPlanePane, 5, 6);
71 mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane);
72 mySelPlane->setInsideSpacing( 5 );
73 mySelPlane->setInsideMargin( 5 );
75 QRadioButton* aBxy = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane); // 0
76 QRadioButton* aByz = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane); // 1
77 QRadioButton* aBzx = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane); // 2
78 aBxy->setChecked(false);
79 aByz->setChecked(false);
80 aBzx->setChecked(true);
82 aPlaneLayout->addWidget( mySelPlane );
84 QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
85 aRotBox->setColumnLayout(2, Qt::Horizontal );
87 myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox);
88 myRotXSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
89 myRotXSpn->setValue( 0 );
90 myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox );
91 myRotYSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
92 myRotYSpn->setValue( 0 );
94 aPlaneLayout->addWidget( aRotBox );
96 QHGroupBox* aBaseBox = new QHGroupBox (tr("BASE_PLANE_POS"), aPlanePane);
97 myBasePlanePos = new QLineEdit (aBaseBox);
98 mydvalidator = new QDoubleValidator(this);
99 mydvalidator->setDecimals(32);
100 myBasePlanePos->setValidator(mydvalidator);
102 myCBSetDef = new QCheckBox (tr("SET_DEFAULT"),aBaseBox);
104 aPlaneLayout->addWidget(aBaseBox);
106 QHBox* aPosBox = new QHBox (aPlanePane);
107 aPosBox->setSpacing(5);
108 QLabel* aPosLbl = new QLabel (tr("LBL_POS"), aPosBox);
109 myPosSpn = new QtxDblSpinBox (0, 1, 0.1, aPosBox);
110 myPosSpn->setValue(0.5);
111 aPlaneLayout->addWidget(aPosBox);
113 myPreviewCheck = new QCheckBox (tr("LBL_SHOW_PREVIEW"), aPlanePane);
114 myPreviewCheck->setChecked(false);
115 aPlaneLayout->addWidget(myPreviewCheck);
117 myAllCurvesInvertedCheck = new QCheckBox(tr("LBL_INVERT_CURVES"), aPlanePane);
118 myAllCurvesInvertedCheck->setChecked(false);
119 aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
121 myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
122 myCreateTable->setChecked(MYGenerateTable);
123 aPlaneLayout->addWidget( myCreateTable );
125 QHBox* aCheckPane = new QHBox(aPlanePane);
126 QLabel* aLbl = new QLabel(" ", aCheckPane);
127 aCheckPane->setStretchFactor(aLbl, 0);
128 myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane);
129 aCheckPane->setStretchFactor(aCheckPane, 0);
130 myCurvesCheck->setChecked(MYGenerateCurve);
131 myCurvesCheck->setEnabled(MYGenerateTable);
132 QLabel* aLbl2 = new QLabel(" ", aCheckPane);
133 aCheckPane->setStretchFactor(aLbl2, 1);
134 aPlaneLayout->addWidget( aCheckPane );
136 aPlaneLayout->addStretch();
139 aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
142 QFrame* aLinesPane = new QFrame(this);
143 QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 );
145 mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane);
146 mySelPlane2->setInsideSpacing( 5 );
147 mySelPlane2->setInsideMargin( 5 );
149 QRadioButton* aBxy2 = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane2); // 0
150 QRadioButton* aByz2 = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane2); // 1
151 QRadioButton* aBzx2 = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane2); // 2
152 aBzx2->setEnabled(false);
153 aByz2->setChecked(true);
154 aLinesLayout->addWidget( mySelPlane2 );
156 QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
157 aRotBox2->setColumnLayout(2, Qt::Horizontal );
159 myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2);
160 myRotXSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
161 myRotXSpn2->setValue( 0 );
162 myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 );
163 myRotYSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
164 myRotYSpn2->setValue( 0 );
165 aLinesLayout->addWidget( aRotBox2 );
167 QHBox* aNbBox = new QHBox(aLinesPane);
168 aNbBox->setSpacing(5);
169 QLabel* aNbLbl = new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
170 myNbSpn = new QtxDblSpinBox( 1, 100, 1, aNbBox );
171 myNbSpn->setValue( 10 );
173 aLinesLayout->addWidget( aNbBox );
175 myPosTable = new QTable(aLinesPane, "Positions of cut planes" );
176 myPosTable->setMaximumHeight( 227 );
177 myPosTable->setMinimumWidth( 294 );
178 myPosTable->setNumCols(2);
179 myPosTable->setNumRows(0);
181 QHeader *th = myPosTable->horizontalHeader();
182 th->setLabel( 0, "Position" );
183 th->setLabel( 1, "Set default" );
185 aLinesLayout->addWidget( myPosTable );
187 QHBox* aPosBox2 = new QHBox(aLinesPane);
188 aPosBox2->setSpacing(5);
189 QLabel* aPosLbl2 = new QLabel( tr( "LBL_POS" ), aPosBox2 );
190 myPosSpn2 = new QtxDblSpinBox( 0, 1, 0.1, aPosBox2 );
191 myPosSpn2->setValue( 0.5 );
192 aLinesLayout->addWidget( aPosBox2 );
193 aLinesLayout->addStretch();
195 aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
197 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
198 myScalarPane->setMargin( 5 );
199 aTabPane->addTab(myScalarPane, "Scalar Bar");
201 aMainLayout->addWidget(aTabPane);
204 QHBox* aBtnBox = new QHBox(this);
205 aBtnBox->setFrameStyle(QFrame::Box | QFrame::Sunken);
206 aBtnBox->setLineWidth( 1 );
207 QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout();
208 aBtnLayout->setAutoAdd( false );
209 aBtnLayout->setSpacing( 5 );
210 aBtnLayout->setMargin( 11 );
212 QPushButton* aOkBtn = new QPushButton (tr("BUT_OK"), aBtnBox);
213 aOkBtn->setAutoDefault( TRUE );
214 aOkBtn->setDefault( true );
215 aBtnLayout->addWidget(aOkBtn);
217 aBtnLayout->addStretch();
219 QPushButton* aCloseBtn = new QPushButton(tr("BUT_CANCEL"), aBtnBox);
220 aBtnLayout->addWidget(aCloseBtn);
222 aMainLayout->addWidget(aBtnBox);
226 // signals and slots connections
227 connect(mySelPlane , SIGNAL(clicked(int)) , this, SLOT(onPlaneSelect(int)));
228 connect(myCBSetDef , SIGNAL(toggled(bool)) , this, SLOT(setBaseDefault()));
229 connect(myPosSpn , SIGNAL(valueChanged(double)) , this, SLOT(setBaseDefault()));
230 connect(mySelPlane2 , SIGNAL(clicked(int)) , this, SLOT(onCutSelect(int)));
231 connect(myNbSpn , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
232 connect(th , SIGNAL(clicked(int)) , this, SLOT(setDefault(int)));
233 connect(myPosSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
234 connect(myPreviewCheck, SIGNAL(toggled(bool)) , this, SLOT(onPreviewCheck(bool)));
235 connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool)));
236 connect(myPosTable , SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)));
237 connect(myRotXSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
238 connect(myRotYSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
239 connect(myRotXSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
240 connect(myRotYSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
241 connect(myBasePlanePos, SIGNAL(textChanged(const QString&)), this, SLOT(onPlanePos(const QString&)));
242 connect(myCreateTable , SIGNAL(toggled(bool)), myCurvesCheck, SLOT(setEnabled(bool)));
244 connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
245 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
246 //connect(myMgr, SIGNAL(closeAllViews()), this, SLOT(reject()));
247 //connect(VisuGUI::application()->desktop(),
248 // SIGNAL(windowActivated(SUIT_ViewWindow*)),
249 // this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
255 VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg()
257 cout<<"### VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg"<<endl;
259 if (myCutLines) //delete myCutLines;
260 myCutLines->Destroy();
261 if (SVTK_ViewWindow* vf = VISU::GetViewWindow())
265 //------------------------------------------------------------------------------
266 void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
269 myScalarPane->initFromPrsObject(thePrs);
271 myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
272 myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
273 myPosSpn->setValue(thePrs->GetDisplacement());
274 setOrientation(thePrs->GetOrientationType());
276 myNbSpn->setValue( (int)thePrs->GetNbLines() );
277 myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
278 myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
279 myPosSpn2->setValue(thePrs->GetDisplacement2());
280 setOrientation2(thePrs->GetOrientationType2());
283 myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
284 myCutLines->SameAs(thePrs);
285 myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
286 if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
287 myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
288 myCBSetDef->setChecked(thePrs->IsDefault());
292 if (myPreviewCheck->isChecked()) {
297 //------------------------------------------------------------------------------
298 int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
300 myScalarPane->storeToPrsObject(thePrs);
302 thePrs->SetOrientation(getOrientaion(),
303 myRotXSpn->value()*PI/180.,
304 myRotYSpn->value()*PI/180.);
305 thePrs->SetDisplacement(myPosSpn->value());
306 thePrs->SetNbLines((int)myNbSpn->value());
308 thePrs->SetOrientation2(getOrientaion(false),
309 myRotXSpn2->value()*PI/180.,
310 myRotYSpn2->value()*PI/180.);
311 thePrs->SetDisplacement2(myPosSpn2->value());
313 if (!myCBSetDef->isChecked())
314 thePrs->SetBasePlanePosition(myBasePlanePos->text().toDouble());
315 else thePrs->SetDefault();
317 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
318 if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked())
319 thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
320 else thePrs->SetDefaultPosition(i);
322 if (myAllCurvesInvertedCheck->isChecked())
323 thePrs->SetAllCurvesInverted(true);
327 //------------------------------------------------------------------------------
328 void VisuGUI_CutLinesDlg::createPlanes()
330 SVTK_ViewWindow* aView = VISU::GetViewWindow();
331 if (aView == NULL) return;
332 if (myCutLines == NULL) return;
333 if (myPreviewActor != 0) return;
335 storeToPrsObject(myCutLines);
336 myCutLines->GetPL()->Update();
337 vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
338 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
339 aPlaneMapper->SetInput(aPolyData->GetOutput());
340 aPlaneMapper->ScalarVisibilityOff();
342 myPreviewActorGlyphs = myPreviewActorGlyphs = SALOME_Actor::New();
343 myPreviewActorGlyphs->PickableOff();
346 myPreviewActor = SALOME_Actor::New();
347 myPreviewActor->PickableOff();
348 myPreviewActor->SetMapper(aPlaneMapper);
349 aPlaneMapper->Delete();
350 aView->AddActor(myPreviewActor);
351 aView->AddActor(myPreviewActorGlyphs);
352 aView->getRenderer()->Render();
356 //------------------------------------------------------------------------------
357 void VisuGUI_CutLinesDlg::deletePlanes()
359 if (myPreviewActor == 0) return;
360 if (SVTK_ViewWindow* aView = VISU::GetViewWindow()){
361 aView->RemoveActor(myPreviewActor);
362 aView->RemoveActor(myPreviewActorGlyphs);
364 myPreviewActor->Delete();
365 myPreviewActorGlyphs->Delete();
367 myPreviewActorGlyphs = 0;
371 //------------------------------------------------------------------------------
372 void VisuGUI_CutLinesDlg::onPlaneSelect (int theId)
374 for (int i = 0; i < mySelPlane2->count(); i++)
375 mySelPlane2->find(i)->setEnabled(true);
376 QButton* aBtn = mySelPlane2->find(theId);
377 aBtn->setEnabled(false);
380 myRotXLbl->setText( tr("LBL_ROT_X"));
381 myRotYLbl->setText( tr("LBL_ROT_Y"));
382 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
383 onCutSelect(1, false);
386 myRotXLbl->setText( tr("LBL_ROT_Y"));
387 myRotYLbl->setText( tr("LBL_ROT_Z"));
388 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
389 onCutSelect(2, false);
392 myRotXLbl->setText( tr("LBL_ROT_Z"));
393 myRotYLbl->setText( tr("LBL_ROT_X"));
394 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
395 onCutSelect(0, false);
397 setBaseDefault(false);
401 //------------------------------------------------------------------------------
402 void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate)
406 myRotXLbl2->setText( tr("LBL_ROT_X"));
407 myRotYLbl2->setText( tr("LBL_ROT_Y"));
410 myRotXLbl2->setText( tr("LBL_ROT_Y"));
411 myRotYLbl2->setText( tr("LBL_ROT_Z"));
414 myRotXLbl2->setText( tr("LBL_ROT_Z"));
415 myRotYLbl2->setText( tr("LBL_ROT_X"));
417 SVTK_ViewWindow* aView = VISU::GetViewWindow();
419 if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
420 /*myCutLines->SetOrientation2(getOrientaion(false),
421 myRotXSpn2->value()*PI/180.,
422 myRotYSpn2->value()*PI/180.);
423 myCutLines->SetDisplacement2(myPosSpn2->value());*/
424 //myCutLines->GetPL()->Update();
432 //------------------------------------------------------------------------------
433 void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate)
435 if (!hasInit) return;
437 if (myCBSetDef->isChecked()) {
438 if (!myCutLines->IsDefault()) myCutLines->SetDefault();
439 /*myCutLines->SetOrientation(getOrientaion(),
440 myRotXSpn->value()*PI/180.,
441 myRotYSpn->value()*PI/180.);
442 myCutLines->SetDisplacement(myPosSpn->value());*/
443 /* float aPos = myCutLines->GetBasePlanePosition();
444 myBasePlanePos->setText( QString::number(aPos) );
445 myBasePlanePos->setEnabled(false);*/
446 SVTK_ViewWindow* aView = VISU::GetViewWindow();
448 if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
449 //myCutLines->SetBasePlanePosition(aPos);
450 // myCutLines->GetPL()->Update();
456 float aPos = myCutLines->GetBasePlanePosition();
457 myBasePlanePos->setText( QString::number(aPos) );
458 myBasePlanePos->setEnabled(false);
460 myBasePlanePos->setEnabled(true);
464 //------------------------------------------------------------------------------
465 void VisuGUI_CutLinesDlg::DrawTable()
467 if (!hasInit) return;
469 int aNbRows = myPosTable->numRows();
470 int aNbPlanes = (int)myNbSpn->value();
472 myCutLines->SetOrientation(getOrientaion(),
473 myRotXSpn->value()*PI/180.,
474 myRotYSpn->value()*PI/180.);
476 myCutLines->SetNbLines(aNbPlanes);
477 myCutLines->SetDisplacement2(myPosSpn2->value());
478 myCutLines->SetOrientation2(getOrientaion(false),
479 myRotXSpn2->value()*PI/180.,
480 myRotYSpn2->value()*PI/180.);
483 for (int i = 0; i < aNbRows; ++i) {
484 QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
485 if (aItem == 0) break;
486 if (!aItem->isChecked())
487 myCutLines->SetLinePosition(i, myPosTable->text(i, 0).toDouble());
490 if (aNbPlanes > aNbRows)
491 myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
492 else if (aNbPlanes < aNbRows)
493 myPosTable->setNumRows(aNbPlanes);
495 int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
496 for (int i = 0; i<aMin; i++) {
497 myPosTable->setText(i, 0, QString::number(myCutLines->GetLinePosition(i)));
498 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutLines->IsDefaultPosition(i));
501 QHeader *vh = myPosTable->verticalHeader();
502 QString str("Plane# %1");
503 for (int i=aMin; i<aNbPlanes; i++) {
504 VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem
505 (myPosTable, QTableItem::OnTyping, QString::number(myCutLines->GetLinePosition(i)));
506 aEditItem->setReplaceable(false);
507 aEditItem->setEnabled(!myCutLines->IsDefaultPosition(i));
508 myPosTable->setItem(i, 0, aEditItem);
510 QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
511 aCheck->setChecked(myCutLines->IsDefaultPosition(i));
512 aCheck->setReplaceable(false);
513 myPosTable->setItem(i, 1, aCheck);
515 vh->setLabel( i, str.arg(i+1) );
518 SVTK_ViewWindow* aView = VISU::GetViewWindow();
520 if (myPreviewCheck->isChecked()) {
521 // myCutLines->GetPL()->Update();
529 void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
530 if (myPreviewActorGlyphs == 0 ) return;
531 const float *aDirLn = myCutLines->GetCutLinesPL()->GetDirLn();
532 const float *aBasePnt = myCutLines->GetCutLinesPL()->GetBasePnt();
534 float aBoundCenter[3];
536 vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
537 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
538 aPlaneMapper->SetInput(aPolyData->GetOutput());
540 aPlaneMapper->GetBounds(bounds);
542 for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0;
543 for(int i=0; i<3; i++){
544 if (!myAllCurvesInvertedCheck->isChecked())
545 aSecondPnt[i] = aBasePnt[i] + aDirLn[i];
547 aSecondPnt[i] = -aBasePnt[i] - aDirLn[i];
551 max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound;
552 max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound;
553 max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound;
555 vtkPolyData* profile = vtkPolyData::New();
556 vtkPoints* aPoints = vtkPoints::New();
557 vtkGlyph3D* glyphs = vtkGlyph3D::New();
558 vtkFloatArray *aFloatArray = vtkFloatArray::New();
559 vtkGlyphSource2D* source = vtkGlyphSource2D::New();
562 source->SetCenter(aBoundCenter);
563 source->SetGlyphTypeToArrow();
565 aPoints->InsertNextPoint(aBasePnt);
566 profile->SetPoints(aPoints);
568 aFloatArray->SetNumberOfComponents(3);
569 for(int i=0; i<3 ;i++)
570 aFloatArray->InsertNextValue(aSecondPnt[i]);
572 vtkDataSetAttributes* aDataSetAttributes;
573 aDataSetAttributes = profile->GetPointData();
574 aDataSetAttributes->SetVectors(aFloatArray);
576 glyphs->SetScaleFactor(0.25*max_bound);
577 glyphs->SetVectorModeToUseVector();
578 glyphs->SetScaleModeToScaleByVector();
579 glyphs->SetInput(profile);
580 glyphs->SetSource(source->GetOutput());
582 vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New();
583 aGlyphsMapper->ScalarVisibilityOff();
584 aGlyphsMapper->SetInput(glyphs->GetOutput());
586 myPreviewActorGlyphs->SetMapper(aGlyphsMapper);
591 aGlyphsMapper->Delete();
592 aFloatArray->Delete();
594 aPlaneMapper->Delete();
596 if (SVTK_ViewWindow* vf = VISU::GetViewWindow())
601 //------------------------------------------------------------------------------
602 void VisuGUI_CutLinesDlg::setDefault (int all)
604 myPosTable->setCurrentCell(-1, 1);
605 myPosTable->clearSelection();
606 if (all == 0) return;
608 for (int i = 0; i < (int)myNbSpn->value(); ++i)
609 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
611 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
612 if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
613 myCutLines->SetDefaultPosition(i);
614 myPosTable->setText( i, 0, QString::number(myCutLines->GetLinePosition(i)));
615 myPosTable->item( i, 0 )->setEnabled(false);
617 myPosTable->item( i, 0 )->setEnabled(true);
621 //------------------------------------------------------------------------------
622 VISU::CutPlanes::Orientation VisuGUI_CutLinesDlg::getOrientaion (bool IsBasePlane)
631 VISU::CutPlanes::Orientation orient;
632 switch (aBG->id(aBG->selected())) {
634 orient = VISU::CutPlanes::XY;
637 orient = VISU::CutPlanes::YZ;
640 orient = VISU::CutPlanes::ZX;
645 //------------------------------------------------------------------------------
646 void VisuGUI_CutLinesDlg::setOrientation (const VISU::CutPlanes::Orientation orient)
649 case VISU::CutPlanes::XY:
650 ((QRadioButton*)mySelPlane->find(0))->setChecked(true);
653 case VISU::CutPlanes::YZ:
654 ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
657 case VISU::CutPlanes::ZX:
658 ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
663 //------------------------------------------------------------------------------
664 void VisuGUI_CutLinesDlg::setOrientation2 (const VISU::CutPlanes::Orientation orient)
667 case VISU::CutPlanes::XY:
668 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
671 case VISU::CutPlanes::YZ:
672 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
675 case VISU::CutPlanes::ZX:
676 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
681 void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
684 QString aTxt = myPosTable->text(theRow, 0);
685 bool isChanged = !aTxt.isEmpty();
686 ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
687 SVTK_ViewWindow* aView = VISU::GetViewWindow();
689 if (myPreviewCheck->isChecked()) {
691 //myCutLines->SetLinePosition( theRow, aTxt.toDouble());
692 // myCutLines->GetPL()->Update();
698 } else if (theCol == 1){
699 bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
701 //myCutLines->SetDefaultPosition(theRow);
702 // myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
703 SVTK_ViewWindow* aView = VISU::GetViewWindow();
705 if (myPreviewCheck->isChecked()) {
707 // myCutLines->GetPL()->Update();
713 myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
715 myPosTable->item(theRow, 0)->setEnabled(!isDefault);
719 void VisuGUI_CutLinesDlg::accept()
721 //if ( !VisuGUI::CheckActiveStudyLock() ) {
725 MYGenerateTable = myCreateTable->isChecked();
726 MYGenerateCurve = myCurvesCheck->isChecked();
727 // if (myScalarPane->check()) {
728 /*jfa tmp:((QWidget*)sender())->setDisabled(true);
729 storeToPrsObject(myPrs);
731 if (isGenerateTable()) {
732 visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
733 if (isGenerateCurves()) {
734 SALOMEDSClient_Study* aStudy = study()->studyDS();
735 SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
737 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
738 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
739 for ( ;aIter->More(); aIter->Next()) {
740 SALOMEDSClient_SObject* aTblObj = aIter->Value();
742 SALOMEDSClient_GenericAttribute* anAttr;
743 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
744 visuGUI->CreatePlot(aTblObj);
751 if (GET_VTK_VIEWWINDOW(myMgr)) {
753 visuGUI->CreateActor(myPrs);
758 GET_VTK_VIEWWINDOW(myMgr)->onFitAll();
761 visuGUI->RecreateActor(myPrs);
762 if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
763 if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
764 vf->getRenderer()->ResetCameraClippingRange();
769 SALOMEDSClient_Study* aStudy = study()->studyDS();
770 SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
772 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
773 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
774 for ( ;aIter->More(); aIter->Next()) {
775 SALOMEDSClient_SObject* aTblObj = aIter->Value();
777 SALOMEDSClient_GenericAttribute* anAttr;
778 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
779 aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
784 if (isGenerateTable()) {
785 visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str());
786 if (isGenerateCurves()) {
787 SALOMEDSClient_Study* aStudy = study()->studyDS();
788 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
789 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
790 for ( ;aIter->More(); aIter->Next()) {
791 SALOMEDSClient_SObject* aTblObj = aIter->Value();
793 SALOMEDSClient_GenericAttribute* anAttr;
794 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
795 visuGUI->CreatePlot(aTblObj);
803 VisuGUI::application()->objectBrowser()->updateTree();*/
804 myScalarPane->deletePreview();
810 void VisuGUI_CutLinesDlg::reject()
812 /*jfa tmp:if (myIsCreation) {
813 myPrs->RemoveFromStudy();
814 VisuGUI::application()->objectBrowser()->updateTree();
816 myScalarPane->deletePreview();
821 void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview)
823 if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
825 //storeToPrsObject(myCutLines);
826 // myCutLines->GetPL()->Update();
836 /*! Inverting all curves in the table
838 void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert)
840 if (myAllCurvesInvertedCheck->isChecked()){
841 myCutLines->SetAllCurvesInverted(true);
842 myPrs->SetAllCurvesInverted(true);
845 myCutLines->SetAllCurvesInverted(false);
846 myPrs->SetAllCurvesInverted(false);
851 void VisuGUI_CutLinesDlg::onRotation (double theValue)
853 if (myCutLines == NULL) return;
854 SVTK_ViewWindow* aView = VISU::GetViewWindow();
856 if (myPreviewCheck->isChecked()) {
858 /*myCutLines->SetOrientation(getOrientaion(),
859 myRotXSpn->value()*PI/180.,
860 myRotYSpn->value()*PI/180.);
861 myCutLines->SetOrientation2(getOrientaion(false),
862 myRotXSpn2->value()*PI/180.,
863 myRotYSpn2->value()*PI/180.);*/
864 // myCutLines->GetPL()->Update();
872 void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue)
874 if (myCutLines == NULL) return;
875 SVTK_ViewWindow* aView = VISU::GetViewWindow();
877 if (myPreviewCheck->isChecked()) {
878 //myCutLines->SetBasePlanePosition(theValue.toDouble());
879 // myCutLines->GetPL()->Update();
887 //jfa tmp:void VisuGUI_CutLinesDlg::onWindowActivated (SUIT_ViewWindow* theWnd)
889 //jfa tmp: if (theWnd != myStudyWnd)