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 "SalomeApp_Application.h"
27 #include "SalomeApp_Study.h"
29 #include "SUIT_Desktop.h"
31 #include "OB_Browser.h"
35 #include <qtabwidget.h>
36 #include <qhgroupbox.h>
38 #include <vtkRenderer.h>
39 #include <vtkPolyData.h>
40 #include <vtkAppendPolyData.h>
41 #include <vtkDataSetMapper.h>
42 #include <vtkGlyph3D.h>
43 #include <vtkPolyDataMapper.h>
44 #include <vtkFloatArray.h>
45 #include <vtkGlyphSource2D.h>
49 bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
50 bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
52 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
53 : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
54 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
55 myPreviewActor(0),myPreviewActorGlyphs(0)
57 setCaption("Cut Lines Definition");
58 setSizeGripEnabled(true);
60 QVBoxLayout* aMainLayout = new QVBoxLayout (this, 7, 6);
61 aMainLayout->setSpacing(5);
66 QTabWidget* aTabPane = new QTabWidget(this);
69 QFrame* aPlanePane = new QFrame(this);
70 QVBoxLayout* aPlaneLayout = new QVBoxLayout(aPlanePane, 5, 6);
72 mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane);
73 mySelPlane->setInsideSpacing( 5 );
74 mySelPlane->setInsideMargin( 5 );
76 QRadioButton* aBxy = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane); // 0
77 QRadioButton* aByz = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane); // 1
78 QRadioButton* aBzx = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane); // 2
79 aBxy->setChecked(false);
80 aByz->setChecked(false);
81 aBzx->setChecked(true);
83 aPlaneLayout->addWidget( mySelPlane );
85 QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
86 aRotBox->setColumnLayout(2, Qt::Horizontal );
88 myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox);
89 myRotXSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
90 myRotXSpn->setValue( 0 );
91 myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox );
92 myRotYSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
93 myRotYSpn->setValue( 0 );
95 aPlaneLayout->addWidget( aRotBox );
97 QHGroupBox* aBaseBox = new QHGroupBox (tr("BASE_PLANE_POS"), aPlanePane);
98 myBasePlanePos = new QLineEdit (aBaseBox);
99 mydvalidator = new QDoubleValidator(this);
100 mydvalidator->setDecimals(32);
101 myBasePlanePos->setValidator(mydvalidator);
103 myCBSetDef = new QCheckBox (tr("SET_DEFAULT"),aBaseBox);
105 aPlaneLayout->addWidget(aBaseBox);
107 QHBox* aPosBox = new QHBox (aPlanePane);
108 aPosBox->setSpacing(5);
109 new QLabel (tr("LBL_POS"), aPosBox);
110 myPosSpn = new QtxDblSpinBox (0, 1, 0.1, aPosBox);
111 myPosSpn->setValue(0.5);
112 aPlaneLayout->addWidget(aPosBox);
114 myPreviewCheck = new QCheckBox (tr("LBL_SHOW_PREVIEW"), aPlanePane);
115 myPreviewCheck->setChecked(false);
116 aPlaneLayout->addWidget(myPreviewCheck);
118 myAllCurvesInvertedCheck = new QCheckBox(tr("LBL_INVERT_CURVES"), aPlanePane);
119 myAllCurvesInvertedCheck->setChecked(false);
120 aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
122 myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
123 myCreateTable->setChecked(MYGenerateTable);
124 aPlaneLayout->addWidget( myCreateTable );
126 QHBox* aCheckPane = new QHBox(aPlanePane);
127 QLabel* aLbl = new QLabel(" ", aCheckPane);
128 aCheckPane->setStretchFactor(aLbl, 0);
129 myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane);
130 aCheckPane->setStretchFactor(aCheckPane, 0);
131 myCurvesCheck->setChecked(MYGenerateCurve);
132 myCurvesCheck->setEnabled(MYGenerateTable);
133 QLabel* aLbl2 = new QLabel(" ", aCheckPane);
134 aCheckPane->setStretchFactor(aLbl2, 1);
135 aPlaneLayout->addWidget( aCheckPane );
137 aPlaneLayout->addStretch();
140 aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
143 QFrame* aLinesPane = new QFrame(this);
144 QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 );
146 mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane);
147 mySelPlane2->setInsideSpacing( 5 );
148 mySelPlane2->setInsideMargin( 5 );
150 QRadioButton* aBxy2 = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane2); // 0
151 QRadioButton* aByz2 = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane2); // 1
152 QRadioButton* aBzx2 = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane2); // 2
153 aBzx2->setEnabled(false);
154 aByz2->setChecked(true);
155 aLinesLayout->addWidget( mySelPlane2 );
157 QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
158 aRotBox2->setColumnLayout(2, Qt::Horizontal );
160 myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2);
161 myRotXSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
162 myRotXSpn2->setValue( 0 );
163 myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 );
164 myRotYSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
165 myRotYSpn2->setValue( 0 );
166 aLinesLayout->addWidget( aRotBox2 );
168 QHBox* aNbBox = new QHBox(aLinesPane);
169 aNbBox->setSpacing(5);
170 new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
171 myNbSpn = new QtxDblSpinBox( 1, 100, 1, aNbBox );
172 myNbSpn->setValue( 10 );
174 aLinesLayout->addWidget( aNbBox );
176 myPosTable = new QTable(aLinesPane, "Positions of cut planes" );
177 myPosTable->setMaximumHeight( 227 );
178 myPosTable->setMinimumWidth( 294 );
179 myPosTable->setNumCols(2);
180 myPosTable->setNumRows(0);
182 QHeader *th = myPosTable->horizontalHeader();
183 th->setLabel( 0, "Position" );
184 th->setLabel( 1, "Set default" );
186 aLinesLayout->addWidget( myPosTable );
188 QHBox* aPosBox2 = new QHBox(aLinesPane);
189 aPosBox2->setSpacing(5);
190 new QLabel( tr( "LBL_POS" ), aPosBox2 );
191 myPosSpn2 = new QtxDblSpinBox( 0, 1, 0.1, aPosBox2 );
192 myPosSpn2->setValue( 0.5 );
193 aLinesLayout->addWidget( aPosBox2 );
194 aLinesLayout->addStretch();
196 aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
198 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
199 myScalarPane->setMargin( 5 );
200 aTabPane->addTab(myScalarPane, "Scalar Bar");
202 aMainLayout->addWidget(aTabPane);
205 QHBox* aBtnBox = new QHBox(this);
206 aBtnBox->setFrameStyle(QFrame::Box | QFrame::Sunken);
207 aBtnBox->setLineWidth( 1 );
208 QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout();
209 aBtnLayout->setAutoAdd( false );
210 aBtnLayout->setSpacing( 5 );
211 aBtnLayout->setMargin( 11 );
213 QPushButton* aOkBtn = new QPushButton (tr("BUT_OK"), aBtnBox);
214 aOkBtn->setAutoDefault( TRUE );
215 aOkBtn->setDefault( true );
216 aBtnLayout->addWidget(aOkBtn);
218 aBtnLayout->addStretch();
220 QPushButton* aCloseBtn = new QPushButton(tr("BUT_CANCEL"), aBtnBox);
221 aBtnLayout->addWidget(aCloseBtn);
223 aMainLayout->addWidget(aBtnBox);
227 // signals and slots connections
228 connect(mySelPlane , SIGNAL(clicked(int)) , this, SLOT(onPlaneSelect(int)));
229 connect(myCBSetDef , SIGNAL(toggled(bool)) , this, SLOT(setBaseDefault()));
230 connect(myPosSpn , SIGNAL(valueChanged(double)) , this, SLOT(setBaseDefault()));
231 connect(mySelPlane2 , SIGNAL(clicked(int)) , this, SLOT(onCutSelect(int)));
232 connect(myNbSpn , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
233 connect(th , SIGNAL(clicked(int)) , this, SLOT(setDefault(int)));
234 connect(myPosSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
235 connect(myPreviewCheck, SIGNAL(toggled(bool)) , this, SLOT(onPreviewCheck(bool)));
236 connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool)));
237 connect(myPosTable , SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)));
238 connect(myRotXSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
239 connect(myRotYSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
240 connect(myRotXSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
241 connect(myRotYSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
242 connect(myBasePlanePos, SIGNAL(textChanged(const QString&)), this, SLOT(onPlanePos(const QString&)));
243 connect(myCreateTable , SIGNAL(toggled(bool)), myCurvesCheck, SLOT(setEnabled(bool)));
245 connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
246 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
247 //connect(myMgr, SIGNAL(closeAllViews()), this, SLOT(reject()));
248 //connect(VisuGUI::application()->desktop(),
249 // SIGNAL(windowActivated(SUIT_ViewWindow*)),
250 // this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
256 VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg()
258 cout<<"### VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg"<<endl;
260 if (myCutLines) //delete myCutLines;
261 myCutLines->Destroy();
262 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
266 //------------------------------------------------------------------------------
267 void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
270 myScalarPane->initFromPrsObject(thePrs);
272 myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
273 myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
274 myPosSpn->setValue(thePrs->GetDisplacement());
275 setOrientation(thePrs->GetOrientationType());
277 myNbSpn->setValue( (int)thePrs->GetNbLines() );
278 myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
279 myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
280 myPosSpn2->setValue(thePrs->GetDisplacement2());
281 setOrientation2(thePrs->GetOrientationType2());
284 myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
285 myCutLines->SameAs(thePrs);
286 myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
287 if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
288 myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
289 myCBSetDef->setChecked(thePrs->IsDefault());
293 if (myPreviewCheck->isChecked()) {
298 //------------------------------------------------------------------------------
299 int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
301 myScalarPane->storeToPrsObject(thePrs);
303 thePrs->SetOrientation(getOrientaion(),
304 myRotXSpn->value()*PI/180.,
305 myRotYSpn->value()*PI/180.);
306 thePrs->SetDisplacement(myPosSpn->value());
307 thePrs->SetNbLines((int)myNbSpn->value());
309 thePrs->SetOrientation2(getOrientaion(false),
310 myRotXSpn2->value()*PI/180.,
311 myRotYSpn2->value()*PI/180.);
312 thePrs->SetDisplacement2(myPosSpn2->value());
314 if (!myCBSetDef->isChecked())
315 thePrs->SetBasePlanePosition(myBasePlanePos->text().toDouble());
316 else thePrs->SetDefault();
318 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
319 if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked())
320 thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
321 else thePrs->SetDefaultPosition(i);
323 if (myAllCurvesInvertedCheck->isChecked())
324 thePrs->SetAllCurvesInverted(true);
328 //------------------------------------------------------------------------------
329 void VisuGUI_CutLinesDlg::createPlanes()
331 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
332 if (aView == NULL) return;
333 if (myCutLines == NULL) return;
334 if (myPreviewActor != 0) return;
336 storeToPrsObject(myCutLines);
337 myCutLines->GetPL()->Update();
338 vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
339 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
340 aPlaneMapper->SetInput(aPolyData->GetOutput());
341 aPlaneMapper->ScalarVisibilityOff();
343 myPreviewActorGlyphs = myPreviewActorGlyphs = SALOME_Actor::New();
344 myPreviewActorGlyphs->PickableOff();
347 myPreviewActor = SALOME_Actor::New();
348 myPreviewActor->PickableOff();
349 myPreviewActor->SetMapper(aPlaneMapper);
350 aPlaneMapper->Delete();
351 aView->AddActor(myPreviewActor);
352 aView->AddActor(myPreviewActorGlyphs);
353 aView->getRenderer()->Render();
357 //------------------------------------------------------------------------------
358 void VisuGUI_CutLinesDlg::deletePlanes()
360 if (myPreviewActor == 0) return;
361 if (SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>()){
362 aView->RemoveActor(myPreviewActor);
363 aView->RemoveActor(myPreviewActorGlyphs);
365 myPreviewActor->Delete();
366 myPreviewActorGlyphs->Delete();
368 myPreviewActorGlyphs = 0;
372 //------------------------------------------------------------------------------
373 void VisuGUI_CutLinesDlg::onPlaneSelect (int theId)
375 for (int i = 0; i < mySelPlane2->count(); i++)
376 mySelPlane2->find(i)->setEnabled(true);
377 QButton* aBtn = mySelPlane2->find(theId);
378 aBtn->setEnabled(false);
381 myRotXLbl->setText( tr("LBL_ROT_X"));
382 myRotYLbl->setText( tr("LBL_ROT_Y"));
383 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
384 onCutSelect(1, false);
387 myRotXLbl->setText( tr("LBL_ROT_Y"));
388 myRotYLbl->setText( tr("LBL_ROT_Z"));
389 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
390 onCutSelect(2, false);
393 myRotXLbl->setText( tr("LBL_ROT_Z"));
394 myRotYLbl->setText( tr("LBL_ROT_X"));
395 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
396 onCutSelect(0, false);
398 setBaseDefault(false);
402 //------------------------------------------------------------------------------
403 void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate)
407 myRotXLbl2->setText( tr("LBL_ROT_X"));
408 myRotYLbl2->setText( tr("LBL_ROT_Y"));
411 myRotXLbl2->setText( tr("LBL_ROT_Y"));
412 myRotYLbl2->setText( tr("LBL_ROT_Z"));
415 myRotXLbl2->setText( tr("LBL_ROT_Z"));
416 myRotYLbl2->setText( tr("LBL_ROT_X"));
418 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
420 if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
421 /*myCutLines->SetOrientation2(getOrientaion(false),
422 myRotXSpn2->value()*PI/180.,
423 myRotYSpn2->value()*PI/180.);
424 myCutLines->SetDisplacement2(myPosSpn2->value());*/
425 //myCutLines->GetPL()->Update();
433 //------------------------------------------------------------------------------
434 void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate)
436 if (!hasInit) return;
438 if (myCBSetDef->isChecked()) {
439 if (!myCutLines->IsDefault()) myCutLines->SetDefault();
440 /*myCutLines->SetOrientation(getOrientaion(),
441 myRotXSpn->value()*PI/180.,
442 myRotYSpn->value()*PI/180.);
443 myCutLines->SetDisplacement(myPosSpn->value());*/
444 /* float aPos = myCutLines->GetBasePlanePosition();
445 myBasePlanePos->setText( QString::number(aPos) );
446 myBasePlanePos->setEnabled(false);*/
447 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
449 if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
450 //myCutLines->SetBasePlanePosition(aPos);
451 // myCutLines->GetPL()->Update();
457 float aPos = myCutLines->GetBasePlanePosition();
458 myBasePlanePos->setText( QString::number(aPos) );
459 myBasePlanePos->setEnabled(false);
461 myBasePlanePos->setEnabled(true);
465 //------------------------------------------------------------------------------
466 void VisuGUI_CutLinesDlg::DrawTable()
468 if (!hasInit) return;
470 int aNbRows = myPosTable->numRows();
471 int aNbPlanes = (int)myNbSpn->value();
473 myCutLines->SetOrientation(getOrientaion(),
474 myRotXSpn->value()*PI/180.,
475 myRotYSpn->value()*PI/180.);
477 myCutLines->SetNbLines(aNbPlanes);
478 myCutLines->SetDisplacement2(myPosSpn2->value());
479 myCutLines->SetOrientation2(getOrientaion(false),
480 myRotXSpn2->value()*PI/180.,
481 myRotYSpn2->value()*PI/180.);
484 for (int i = 0; i < aNbRows; ++i) {
485 QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
486 if (aItem == 0) break;
487 if (!aItem->isChecked())
488 myCutLines->SetLinePosition(i, myPosTable->text(i, 0).toDouble());
491 if (aNbPlanes > aNbRows)
492 myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
493 else if (aNbPlanes < aNbRows)
494 myPosTable->setNumRows(aNbPlanes);
496 int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
497 for (int i = 0; i<aMin; i++) {
498 myPosTable->setText(i, 0, QString::number(myCutLines->GetLinePosition(i)));
499 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutLines->IsDefaultPosition(i));
502 QHeader *vh = myPosTable->verticalHeader();
503 QString str("Plane# %1");
504 for (int i=aMin; i<aNbPlanes; i++) {
505 VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem
506 (myPosTable, QTableItem::OnTyping, QString::number(myCutLines->GetLinePosition(i)));
507 aEditItem->setReplaceable(false);
508 aEditItem->setEnabled(!myCutLines->IsDefaultPosition(i));
509 myPosTable->setItem(i, 0, aEditItem);
511 QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
512 aCheck->setChecked(myCutLines->IsDefaultPosition(i));
513 aCheck->setReplaceable(false);
514 myPosTable->setItem(i, 1, aCheck);
516 vh->setLabel( i, str.arg(i+1) );
519 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
521 if (myPreviewCheck->isChecked()) {
522 // myCutLines->GetPL()->Update();
530 void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
531 if (myPreviewActorGlyphs == 0 ) return;
532 const float *aDirLn = myCutLines->GetCutLinesPL()->GetDirLn();
533 const float *aBasePnt = myCutLines->GetCutLinesPL()->GetBasePnt();
535 float aBoundCenter[3];
537 vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
538 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
539 aPlaneMapper->SetInput(aPolyData->GetOutput());
541 aPlaneMapper->GetBounds(bounds);
543 for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0;
544 for(int i=0; i<3; i++){
545 if (!myAllCurvesInvertedCheck->isChecked())
546 aSecondPnt[i] = aBasePnt[i] + aDirLn[i];
548 aSecondPnt[i] = -aBasePnt[i] - aDirLn[i];
552 max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound;
553 max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound;
554 max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound;
556 vtkPolyData* profile = vtkPolyData::New();
557 vtkPoints* aPoints = vtkPoints::New();
558 vtkGlyph3D* glyphs = vtkGlyph3D::New();
559 vtkFloatArray *aFloatArray = vtkFloatArray::New();
560 vtkGlyphSource2D* source = vtkGlyphSource2D::New();
563 source->SetCenter(aBoundCenter);
564 source->SetGlyphTypeToArrow();
566 aPoints->InsertNextPoint(aBasePnt);
567 profile->SetPoints(aPoints);
569 aFloatArray->SetNumberOfComponents(3);
570 for(int i=0; i<3 ;i++)
571 aFloatArray->InsertNextValue(aSecondPnt[i]);
573 vtkDataSetAttributes* aDataSetAttributes;
574 aDataSetAttributes = profile->GetPointData();
575 aDataSetAttributes->SetVectors(aFloatArray);
577 glyphs->SetScaleFactor(0.25*max_bound);
578 glyphs->SetVectorModeToUseVector();
579 glyphs->SetScaleModeToScaleByVector();
580 glyphs->SetInput(profile);
581 glyphs->SetSource(source->GetOutput());
583 vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New();
584 aGlyphsMapper->ScalarVisibilityOff();
585 aGlyphsMapper->SetInput(glyphs->GetOutput());
587 myPreviewActorGlyphs->SetMapper(aGlyphsMapper);
592 aGlyphsMapper->Delete();
593 aFloatArray->Delete();
595 aPlaneMapper->Delete();
597 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
602 //------------------------------------------------------------------------------
603 void VisuGUI_CutLinesDlg::setDefault (int all)
605 myPosTable->setCurrentCell(-1, 1);
606 myPosTable->clearSelection();
607 if (all == 0) return;
609 for (int i = 0; i < (int)myNbSpn->value(); ++i)
610 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
612 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
613 if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
614 myCutLines->SetDefaultPosition(i);
615 myPosTable->setText( i, 0, QString::number(myCutLines->GetLinePosition(i)));
616 myPosTable->item( i, 0 )->setEnabled(false);
618 myPosTable->item( i, 0 )->setEnabled(true);
622 //------------------------------------------------------------------------------
623 VISU::CutPlanes::Orientation VisuGUI_CutLinesDlg::getOrientaion (bool IsBasePlane)
632 VISU::CutPlanes::Orientation orient;
633 switch (aBG->id(aBG->selected())) {
635 orient = VISU::CutPlanes::XY;
638 orient = VISU::CutPlanes::YZ;
641 orient = VISU::CutPlanes::ZX;
646 //------------------------------------------------------------------------------
647 void VisuGUI_CutLinesDlg::setOrientation (const VISU::CutPlanes::Orientation orient)
650 case VISU::CutPlanes::XY:
651 ((QRadioButton*)mySelPlane->find(0))->setChecked(true);
654 case VISU::CutPlanes::YZ:
655 ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
658 case VISU::CutPlanes::ZX:
659 ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
664 //------------------------------------------------------------------------------
665 void VisuGUI_CutLinesDlg::setOrientation2 (const VISU::CutPlanes::Orientation orient)
668 case VISU::CutPlanes::XY:
669 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
672 case VISU::CutPlanes::YZ:
673 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
676 case VISU::CutPlanes::ZX:
677 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
682 void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
685 QString aTxt = myPosTable->text(theRow, 0);
686 bool isChanged = !aTxt.isEmpty();
687 ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
688 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
690 if (myPreviewCheck->isChecked()) {
692 //myCutLines->SetLinePosition( theRow, aTxt.toDouble());
693 // myCutLines->GetPL()->Update();
699 } else if (theCol == 1){
700 bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
702 //myCutLines->SetDefaultPosition(theRow);
703 // myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
704 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
706 if (myPreviewCheck->isChecked()) {
708 // myCutLines->GetPL()->Update();
714 myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
716 myPosTable->item(theRow, 0)->setEnabled(!isDefault);
720 void VisuGUI_CutLinesDlg::accept()
722 //if ( !VisuGUI::CheckActiveStudyLock() ) {
726 MYGenerateTable = myCreateTable->isChecked();
727 MYGenerateCurve = myCurvesCheck->isChecked();
728 // if (myScalarPane->check()) {
729 /*jfa tmp:((QWidget*)sender())->setDisabled(true);
730 storeToPrsObject(myPrs);
732 if (isGenerateTable()) {
733 visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
734 if (isGenerateCurves()) {
735 SALOMEDSClient_Study* aStudy = study()->studyDS();
736 SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
738 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
739 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
740 for ( ;aIter->More(); aIter->Next()) {
741 SALOMEDSClient_SObject* aTblObj = aIter->Value();
743 SALOMEDSClient_GenericAttribute* anAttr;
744 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
745 visuGUI->CreatePlot(aTblObj);
752 if (GET_VTK_VIEWWINDOW(myMgr)) {
754 visuGUI->CreateActor(myPrs);
759 GET_VTK_VIEWWINDOW(myMgr)->onFitAll();
762 visuGUI->RecreateActor(myPrs);
763 if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
764 if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
765 vf->getRenderer()->ResetCameraClippingRange();
770 SALOMEDSClient_Study* aStudy = study()->studyDS();
771 SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
773 SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
774 SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
775 for ( ;aIter->More(); aIter->Next()) {
776 SALOMEDSClient_SObject* aTblObj = aIter->Value();
778 SALOMEDSClient_GenericAttribute* anAttr;
779 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
780 aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
785 if (isGenerateTable()) {
786 visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str());
787 if (isGenerateCurves()) {
788 SALOMEDSClient_Study* aStudy = study()->studyDS();
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 visuGUI->CreatePlot(aTblObj);
804 VisuGUI::application()->objectBrowser()->updateTree();*/
805 myScalarPane->deletePreview();
811 void VisuGUI_CutLinesDlg::reject()
813 /*jfa tmp:if (myIsCreation) {
814 myPrs->RemoveFromStudy();
815 VisuGUI::application()->objectBrowser()->updateTree();
817 myScalarPane->deletePreview();
822 void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview)
824 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
826 //storeToPrsObject(myCutLines);
827 // myCutLines->GetPL()->Update();
837 /*! Inverting all curves in the table
839 void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert)
841 if (myAllCurvesInvertedCheck->isChecked()){
842 myCutLines->SetAllCurvesInverted(true);
843 myPrs->SetAllCurvesInverted(true);
846 myCutLines->SetAllCurvesInverted(false);
847 myPrs->SetAllCurvesInverted(false);
852 void VisuGUI_CutLinesDlg::onRotation (double theValue)
854 if (myCutLines == NULL) return;
855 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
857 if (myPreviewCheck->isChecked()) {
859 /*myCutLines->SetOrientation(getOrientaion(),
860 myRotXSpn->value()*PI/180.,
861 myRotYSpn->value()*PI/180.);
862 myCutLines->SetOrientation2(getOrientaion(false),
863 myRotXSpn2->value()*PI/180.,
864 myRotYSpn2->value()*PI/180.);*/
865 // myCutLines->GetPL()->Update();
873 void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue)
875 if (myCutLines == NULL) return;
876 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
878 if (myPreviewCheck->isChecked()) {
879 //myCutLines->SetBasePlanePosition(theValue.toDouble());
880 // myCutLines->GetPL()->Update();
888 //jfa tmp:void VisuGUI_CutLinesDlg::onWindowActivated (SUIT_ViewWindow* theWnd)
890 //jfa tmp: if (theWnd != myStudyWnd)