1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VisuGUI_CutLinesDlg.cxx
24 #include "VisuGUI_CutLinesDlg.h"
26 #include "VISU_ColoredPrs3dFactory.hh"
29 #include "VisuGUI_Tools.h"
30 #include "VisuGUI_ViewTools.h"
31 #include "VisuGUI_InputPane.h"
33 #include "VISU_Gen_i.hh"
34 #include "VISU_CutLines_i.hh"
35 #include "VISU_ColoredPrs3dFactory.hh"
37 #include "VISU_PipeLine.hxx"
38 #include "VISU_PipeLineUtils.hxx"
39 #include "VISU_CutLinesPL.hxx"
41 #include "SVTK_ViewWindow.h"
43 #include "LightApp_Application.h"
44 #include "SalomeApp_Study.h"
46 #include "SUIT_Desktop.h"
47 #include "SUIT_Session.h"
48 #include "SUIT_MessageBox.h"
49 #include "SUIT_ResourceMgr.h"
51 #include "OB_Browser.h"
55 #include <qtabwidget.h>
56 #include <qhgroupbox.h>
57 #include <qlineedit.h>
59 #include <qpushbutton.h>
61 #include <vtkRenderer.h>
62 #include <vtkPolyData.h>
63 #include <vtkAppendPolyData.h>
64 #include <vtkDataSetMapper.h>
65 #include <vtkGlyph3D.h>
66 #include <vtkPolyDataMapper.h>
67 #include <vtkFloatArray.h>
68 #include <vtkGlyphSource2D.h>
72 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
73 : VisuGUI_ScalarBarBaseDlg(theModule),
75 myPreviewActorGlyphs(0)
77 setCaption("Cut Lines Definition");
78 setSizeGripEnabled(true);
80 QVBoxLayout* aMainLayout = new QVBoxLayout (this, 7, 6);
81 aMainLayout->setSpacing(5);
83 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
87 myTabBox = new QTabWidget(this);
90 QFrame* aPlanePane = new QFrame(this);
91 QVBoxLayout* aPlaneLayout = new QVBoxLayout(aPlanePane, 5, 6);
93 mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane);
94 mySelPlane->setInsideSpacing( 5 );
95 mySelPlane->setInsideMargin( 5 );
97 QRadioButton* aBxy = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane); // 0
98 QRadioButton* aByz = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane); // 1
99 QRadioButton* aBzx = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane); // 2
100 aBxy->setChecked(false);
101 aByz->setChecked(false);
102 aBzx->setChecked(true);
104 aPlaneLayout->addWidget( mySelPlane );
106 QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
107 aRotBox->setColumnLayout(2, Qt::Horizontal );
109 myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox);
110 myRotXSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
111 myRotXSpn->setValue( 0 );
112 myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox );
113 myRotYSpn = new QtxDblSpinBox( -45, 45, 5, aRotBox );
114 myRotYSpn->setValue( 0 );
116 aPlaneLayout->addWidget( aRotBox );
118 QHGroupBox* aBaseBox = new QHGroupBox (tr("BASE_PLANE_POS"), aPlanePane);
119 myBasePlanePos = new QLineEdit (aBaseBox);
120 mydvalidator = new QDoubleValidator(this);
121 mydvalidator->setDecimals(32);
122 myBasePlanePos->setValidator(mydvalidator);
124 myCBSetDef = new QCheckBox (tr("SET_DEFAULT"),aBaseBox);
126 aPlaneLayout->addWidget(aBaseBox);
128 QHBox* aPosBox = new QHBox (aPlanePane);
129 aPosBox->setSpacing(5);
130 new QLabel (tr("LBL_POS"), aPosBox);
131 myPosSpn = new QtxDblSpinBox (0, 1, 0.1, aPosBox);
132 myPosSpn->setValue(0.5);
133 aPlaneLayout->addWidget(aPosBox);
135 myPreviewCheck = new QCheckBox (tr("LBL_SHOW_PREVIEW"), aPlanePane);
136 myPreviewCheck->setChecked( aResourceMgr->booleanValue("VISU", "show_preview", false) );
137 aPlaneLayout->addWidget(myPreviewCheck);
139 myAllCurvesInvertedCheck = new QCheckBox(tr("LBL_INVERT_CURVES"), aPlanePane);
140 myAllCurvesInvertedCheck->setChecked(false);
141 aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
143 myUseAbsoluteLengthCheck = new QCheckBox(tr("LBL_ABSOLUTE_LENGTH"), aPlanePane);
144 myUseAbsoluteLengthCheck->setChecked(false);
145 aPlaneLayout->addWidget(myUseAbsoluteLengthCheck);
147 myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
148 myCreateTable->setChecked( aResourceMgr->booleanValue("VISU", "generate_data_table", true) );
149 aPlaneLayout->addWidget( myCreateTable );
151 QHBox* aCheckPane = new QHBox(aPlanePane);
152 QLabel* aLbl = new QLabel(" ", aCheckPane);
153 aCheckPane->setStretchFactor(aLbl, 0);
154 myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane);
155 aCheckPane->setStretchFactor(aCheckPane, 0);
156 myCurvesCheck->setChecked( aResourceMgr->booleanValue("VISU", "generate_curves", true) );
157 myCurvesCheck->setEnabled( aResourceMgr->booleanValue("VISU", "generate_data_table", true) );
158 QLabel* aLbl2 = new QLabel(" ", aCheckPane);
159 aCheckPane->setStretchFactor(aLbl2, 1);
160 aPlaneLayout->addWidget( aCheckPane );
162 aPlaneLayout->addStretch();
165 myTabBox->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
168 QFrame* aLinesPane = new QFrame(this);
169 QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 );
171 mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane);
172 mySelPlane2->setInsideSpacing( 5 );
173 mySelPlane2->setInsideMargin( 5 );
175 QRadioButton* aBxy2 = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane2); // 0
176 QRadioButton* aByz2 = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane2); // 1
177 QRadioButton* aBzx2 = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane2); // 2
178 aBzx2->setEnabled(false);
179 aByz2->setChecked(true);
180 aLinesLayout->addWidget( mySelPlane2 );
182 QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
183 aRotBox2->setColumnLayout(2, Qt::Horizontal );
185 myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2);
186 myRotXSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
187 myRotXSpn2->setValue( 0 );
188 myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 );
189 myRotYSpn2 = new QtxDblSpinBox( -45, 45, 5, aRotBox2 );
190 myRotYSpn2->setValue( 0 );
191 aLinesLayout->addWidget( aRotBox2 );
193 QHBox* aNbBox = new QHBox(aLinesPane);
194 aNbBox->setSpacing(5);
195 new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
196 myNbSpn = new QtxDblSpinBox( 1, 100, 1, aNbBox );
197 myNbSpn->setValue( 10 );
199 aLinesLayout->addWidget( aNbBox );
201 myPosTable = new QTable(aLinesPane, "Positions of cut planes" );
202 myPosTable->setMaximumHeight( 227 );
203 myPosTable->setMinimumWidth( 294 );
204 myPosTable->setNumCols(2);
205 myPosTable->setNumRows(0);
207 QHeader *th = myPosTable->horizontalHeader();
208 th->setLabel( 0, "Position" );
209 th->setLabel( 1, "Set default" );
211 aLinesLayout->addWidget( myPosTable );
213 QHBox* aPosBox2 = new QHBox(aLinesPane);
214 aPosBox2->setSpacing(5);
215 new QLabel( tr( "LBL_POS" ), aPosBox2 );
216 myPosSpn2 = new QtxDblSpinBox( 0, 1, 0.1, aPosBox2 );
217 myPosSpn2->setValue( 0.5 );
218 aLinesLayout->addWidget( aPosBox2 );
219 aLinesLayout->addStretch();
221 myTabBox->addTab( aLinesPane, tr("LBL_LINES_CUT") );
223 myInputPane = new VisuGUI_InputPane(VISU::TCUTLINES, theModule, this);
224 myTabBox->addTab(GetScalarPane(), "Scalar Bar");
225 myTabBox->addTab(myInputPane, "Input");
227 aMainLayout->addWidget(myTabBox);
230 QHBox* aBtnBox = new QHBox(this);
231 aBtnBox->setFrameStyle(QFrame::Box | QFrame::Sunken);
232 aBtnBox->setLineWidth( 1 );
233 QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout();
234 aBtnLayout->setAutoAdd( false );
235 aBtnLayout->setSpacing( 5 );
236 aBtnLayout->setMargin( 11 );
238 QPushButton* aOkBtn = new QPushButton (tr("BUT_OK"), aBtnBox);
239 aOkBtn->setAutoDefault( TRUE );
240 aOkBtn->setDefault( true );
241 aBtnLayout->addWidget(aOkBtn);
243 aBtnLayout->addStretch();
245 QPushButton* aCloseBtn = new QPushButton(tr("BUT_CANCEL"), aBtnBox);
246 aBtnLayout->addWidget(aCloseBtn);
248 QPushButton* aHelpBtn = new QPushButton(tr("BUT_HELP"), aBtnBox);
249 aBtnLayout->addWidget(aHelpBtn);
251 aMainLayout->addWidget(aBtnBox);
253 // signals and slots connections
254 connect(mySelPlane , SIGNAL(clicked(int)) , this, SLOT(onPlaneSelect(int)));
255 connect(myCBSetDef , SIGNAL(toggled(bool)) , this, SLOT(setBaseDefault()));
256 connect(myPosSpn , SIGNAL(valueChanged(double)) , this, SLOT(setBaseDefault()));
257 connect(mySelPlane2 , SIGNAL(clicked(int)) , this, SLOT(onCutSelect(int)));
258 connect(myNbSpn , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
259 connect(th , SIGNAL(clicked(int)) , this, SLOT(setDefault(int)));
260 connect(myPosSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
261 connect(myPreviewCheck, SIGNAL(toggled(bool)) , this, SLOT(onPreviewCheck(bool)));
262 connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool)));
263 connect(myPosTable , SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)));
264 connect(myRotXSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
265 connect(myRotYSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
266 connect(myRotXSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
267 connect(myRotYSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
268 connect(myBasePlanePos, SIGNAL(textChanged(const QString&)), this, SLOT(onPlanePos(const QString&)));
269 connect(myCreateTable , SIGNAL(toggled(bool)), myCurvesCheck, SLOT(setEnabled(bool)));
271 connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
272 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
273 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
279 VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg()
282 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
286 //------------------------------------------------------------------------------
287 void VisuGUI_CutLinesDlg::initFromPrsObject ( VISU::ColoredPrs3d_i* thePrs,
291 myPrsCopy = VISU::TSameAsFactory<VISU::TCUTLINES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
293 VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
295 myRotXSpn->setValue(myPrsCopy->GetRotateX()*180./PI);
296 myRotYSpn->setValue(myPrsCopy->GetRotateY()*180./PI);
297 myPosSpn->setValue(myPrsCopy->GetDisplacement());
298 setOrientation(myPrsCopy->GetOrientationType());
300 myNbSpn->setValue( (int)myPrsCopy->GetNbLines() );
301 myRotXSpn2->setValue(myPrsCopy->GetRotateX2()*180./PI);
302 myRotYSpn2->setValue(myPrsCopy->GetRotateY2()*180./PI);
303 myPosSpn2->setValue(myPrsCopy->GetDisplacement2());
304 setOrientation2(myPrsCopy->GetOrientationType2());
307 myCutLines = VISU::TSameAsFactory<VISU::TCUTLINES>().Create(myPrsCopy, VISU::ColoredPrs3d_i::EDoNotPublish);
308 myCutLines->CopyCurvesInverted(myPrsCopy->GetCurvesInverted());
309 myAllCurvesInvertedCheck->setChecked( myCutLines->IsAllCurvesInverted() );
310 myUseAbsoluteLengthCheck->setChecked( myCutLines->IsUseAbsoluteLength() );
311 myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
312 myCBSetDef->setChecked(myPrsCopy->IsDefault());
316 if (myPreviewCheck->isChecked()) {
323 myInputPane->initFromPrsObject( myPrsCopy );
324 myTabBox->setCurrentPage( 0 );
327 //------------------------------------------------------------------------------
328 int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
330 if(!myInputPane->check() || !GetScalarPane()->check())
333 int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
334 anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
336 myPrsCopy->SetOrientation(getOrientaion(),
337 myRotXSpn->value()*PI/180.,
338 myRotYSpn->value()*PI/180.);
339 myPrsCopy->SetDisplacement(myPosSpn->value());
340 myPrsCopy->SetNbLines((int)myNbSpn->value());
342 myPrsCopy->SetOrientation2(getOrientaion(false),
343 myRotXSpn2->value()*PI/180.,
344 myRotYSpn2->value()*PI/180.);
345 myPrsCopy->SetDisplacement2(myPosSpn2->value());
347 if (!myCBSetDef->isChecked())
348 myPrsCopy->SetBasePlanePosition(myBasePlanePos->text().toDouble());
349 else myPrsCopy->SetDefault();
351 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
352 if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked())
353 myPrsCopy->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
355 myPrsCopy->SetDefaultPosition(i);
358 myPrsCopy->SetAllCurvesInverted( myAllCurvesInvertedCheck->isChecked() );
359 myPrsCopy->SetUseAbsoluteLength( myUseAbsoluteLengthCheck->isChecked() );
361 VISU::TSameAsFactory<VISU::TCUTLINES>().Copy(myPrsCopy, thePrs);
366 //------------------------------------------------------------------------------
367 void VisuGUI_CutLinesDlg::createPlanes()
369 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
370 if (aView == NULL) return;
371 if (!myCutLines) return;
372 if (myPreviewActor != 0) return;
374 storeToPrsObject(myCutLines);
375 myCutLines->GetPipeLine()->Update();
376 vtkAppendPolyData* aPolyData = myCutLines->GetSpecificPL()->GetAppendPolyData();
377 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
378 aPlaneMapper->SetInput(aPolyData->GetOutput());
379 aPlaneMapper->ScalarVisibilityOff();
381 myPreviewActorGlyphs = SALOME_Actor::New();
382 myPreviewActorGlyphs->PickableOff();
385 myPreviewActor = SALOME_Actor::New();
386 myPreviewActor->PickableOff();
387 myPreviewActor->SetMapper(aPlaneMapper);
388 aPlaneMapper->Delete();
389 aView->AddActor(myPreviewActor);
390 aView->AddActor(myPreviewActorGlyphs);
391 aView->getRenderer()->Render();
395 //------------------------------------------------------------------------------
396 void VisuGUI_CutLinesDlg::deletePlanes()
398 if (myPreviewActor == 0) return;
399 vtkRenderer* aRend = myPreviewActor->GetRenderer();
400 vtkRenderer* aRendGlyphs = myPreviewActorGlyphs->GetRenderer();
402 vtkRenderWindow* aWnd1 = aRend->GetRenderWindow();
403 vtkRenderWindow* aWnd2 = aRendGlyphs->GetRenderWindow();
405 myPreviewActor->RemoveFromRender(aRend);
406 if(aRendGlyphs && aWnd2)
407 myPreviewActorGlyphs->RemoveFromRender(aRendGlyphs);
409 myPreviewActor->Delete();
410 myPreviewActorGlyphs->Delete();
412 myPreviewActorGlyphs = 0;
416 //------------------------------------------------------------------------------
417 void VisuGUI_CutLinesDlg::onPlaneSelect (int theId)
419 for (int i = 0; i < mySelPlane2->count(); i++)
420 mySelPlane2->find(i)->setEnabled(true);
421 QButton* aBtn = mySelPlane2->find(theId);
422 aBtn->setEnabled(false);
425 myRotXLbl->setText( tr("LBL_ROT_X"));
426 myRotYLbl->setText( tr("LBL_ROT_Y"));
427 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
428 onCutSelect(1, false);
431 myRotXLbl->setText( tr("LBL_ROT_Y"));
432 myRotYLbl->setText( tr("LBL_ROT_Z"));
433 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
434 onCutSelect(2, false);
437 myRotXLbl->setText( tr("LBL_ROT_Z"));
438 myRotYLbl->setText( tr("LBL_ROT_X"));
439 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
440 onCutSelect(0, false);
442 setBaseDefault(false);
446 //------------------------------------------------------------------------------
447 void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate)
451 myRotXLbl2->setText( tr("LBL_ROT_X"));
452 myRotYLbl2->setText( tr("LBL_ROT_Y"));
455 myRotXLbl2->setText( tr("LBL_ROT_Y"));
456 myRotYLbl2->setText( tr("LBL_ROT_Z"));
459 myRotXLbl2->setText( tr("LBL_ROT_Z"));
460 myRotYLbl2->setText( tr("LBL_ROT_X"));
462 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
464 if (theUpdate && myPreviewCheck->isChecked() && myCutLines) {
471 //------------------------------------------------------------------------------
472 void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate)
474 if (!hasInit) return;
476 if (myCBSetDef->isChecked()) {
477 if (!myCutLines->IsDefault()) myCutLines->SetDefault();
478 myCutLines->SetDisplacement(myPosSpn->value());
479 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
481 if (theUpdate && myPreviewCheck->isChecked() && myCutLines) {
486 vtkFloatingPointType aPos = myCutLines->GetBasePlanePosition();
487 myBasePlanePos->setText( QString::number(aPos) );
488 myBasePlanePos->setEnabled(false);
490 myBasePlanePos->setEnabled(true);
494 //------------------------------------------------------------------------------
495 void VisuGUI_CutLinesDlg::DrawTable()
497 if (!hasInit) return;
499 int aNbRows = myPosTable->numRows();
500 int aNbPlanes = (int)myNbSpn->value();
502 myCutLines->SetOrientation(getOrientaion(),
503 myRotXSpn->value()*PI/180.,
504 myRotYSpn->value()*PI/180.);
506 myCutLines->SetNbLines(aNbPlanes);
507 myCutLines->SetDisplacement2(myPosSpn2->value());
508 myCutLines->SetOrientation2(getOrientaion(false),
509 myRotXSpn2->value()*PI/180.,
510 myRotYSpn2->value()*PI/180.);
513 for (int i = 0; i < aNbRows; ++i) {
514 QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
515 if (aItem == 0) break;
516 if (!aItem->isChecked())
517 myCutLines->SetLinePosition(i, myPosTable->text(i, 0).toDouble());
520 if (aNbPlanes > aNbRows)
521 myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
522 else if (aNbPlanes < aNbRows)
523 myPosTable->setNumRows(aNbPlanes);
525 int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
526 for (int i = 0; i<aMin; i++) {
527 myPosTable->setText(i, 0, QString::number(myCutLines->GetLinePosition(i)));
528 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutLines->IsDefaultPosition(i));
531 QHeader *vh = myPosTable->verticalHeader();
532 QString str("Plane# %1");
533 for (int i=aMin; i<aNbPlanes; i++) {
534 VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem
535 (myPosTable, QTableItem::OnTyping, QString::number(myCutLines->GetLinePosition(i)));
536 aEditItem->setReplaceable(false);
537 aEditItem->setEnabled(!myCutLines->IsDefaultPosition(i));
538 myPosTable->setItem(i, 0, aEditItem);
540 QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
541 aCheck->setChecked(myCutLines->IsDefaultPosition(i));
542 aCheck->setReplaceable(false);
543 myPosTable->setItem(i, 1, aCheck);
545 vh->setLabel( i, str.arg(i+1) );
548 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
550 if (myPreviewCheck->isChecked()) {
557 void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
558 if (myPreviewActorGlyphs == 0 ) return;
559 const vtkFloatingPointType *aDirLn = myCutLines->GetSpecificPL()->GetRealDirLn();
560 vtkFloatingPointType aSecondPnt[3];
561 vtkFloatingPointType aBoundCenter[3];
563 vtkAppendPolyData* aPolyData = myCutLines->GetSpecificPL()->GetAppendPolyData();
564 vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
565 aPlaneMapper->SetInput(aPolyData->GetOutput());
566 vtkFloatingPointType bounds[6];
567 aPlaneMapper->GetBounds(bounds);
569 for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0;
570 for(int i=0; i<3; i++){
571 if (!myAllCurvesInvertedCheck->isChecked())
572 aSecondPnt[i] = aDirLn[i];
574 aSecondPnt[i] = - aDirLn[i];
577 vtkFloatingPointType max_bound = 0;
578 max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound;
579 max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound;
580 max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound;
582 vtkPolyData* profile = vtkPolyData::New();
583 vtkPoints* aPoints = vtkPoints::New();
584 vtkGlyph3D* glyphs = vtkGlyph3D::New();
585 vtkFloatArray *aFloatArray = vtkFloatArray::New();
586 vtkGlyphSource2D* source = vtkGlyphSource2D::New();
589 source->SetGlyphTypeToArrow();
591 aPoints->InsertNextPoint(aBoundCenter);
592 profile->SetPoints(aPoints);
594 aFloatArray->SetNumberOfComponents(3);
595 for(int i=0; i<3 ;i++)
596 aFloatArray->InsertNextValue(aSecondPnt[i]);
598 vtkDataSetAttributes* aDataSetAttributes;
599 aDataSetAttributes = profile->GetPointData();
600 aDataSetAttributes->SetVectors(aFloatArray);
602 glyphs->SetScaleFactor(0.25*max_bound);
603 glyphs->SetVectorModeToUseVector();
604 glyphs->SetScaleModeToScaleByVector();
605 glyphs->SetInput(profile);
606 glyphs->SetSource(source->GetOutput());
608 vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New();
609 aGlyphsMapper->ScalarVisibilityOff();
610 aGlyphsMapper->SetInput(glyphs->GetOutput());
612 myPreviewActorGlyphs->SetMapper(aGlyphsMapper);
617 aGlyphsMapper->Delete();
618 aFloatArray->Delete();
620 aPlaneMapper->Delete();
622 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
627 //------------------------------------------------------------------------------
628 void VisuGUI_CutLinesDlg::setDefault (int all)
630 myPosTable->setCurrentCell(-1, 1);
631 myPosTable->clearSelection();
632 if (all == 0) return;
634 for (int i = 0; i < (int)myNbSpn->value(); ++i)
635 ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
637 for (int i = 0; i < (int)myNbSpn->value(); ++i) {
638 if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
639 myCutLines->SetDefaultPosition(i);
640 myPosTable->setText( i, 0, QString::number(myCutLines->GetLinePosition(i)));
641 myPosTable->item( i, 0 )->setEnabled(false);
643 myPosTable->item( i, 0 )->setEnabled(true);
647 //------------------------------------------------------------------------------
648 VISU::CutPlanes::Orientation VisuGUI_CutLinesDlg::getOrientaion (bool IsBasePlane)
657 VISU::CutPlanes::Orientation orient;
658 switch (aBG->id(aBG->selected())) {
660 orient = VISU::CutPlanes::XY;
663 orient = VISU::CutPlanes::YZ;
666 orient = VISU::CutPlanes::ZX;
671 //------------------------------------------------------------------------------
672 void VisuGUI_CutLinesDlg::setOrientation (const VISU::CutPlanes::Orientation orient)
675 case VISU::CutPlanes::XY:
676 ((QRadioButton*)mySelPlane->find(0))->setChecked(true);
679 case VISU::CutPlanes::YZ:
680 ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
683 case VISU::CutPlanes::ZX:
684 ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
689 //------------------------------------------------------------------------------
690 void VisuGUI_CutLinesDlg::setOrientation2 (const VISU::CutPlanes::Orientation orient)
693 case VISU::CutPlanes::XY:
694 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
697 case VISU::CutPlanes::YZ:
698 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
701 case VISU::CutPlanes::ZX:
702 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
707 void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
710 QString aTxt = myPosTable->text(theRow, 0);
711 bool isChanged = !aTxt.isEmpty();
712 ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
713 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
715 if (myPreviewCheck->isChecked()) {
720 } else if (theCol == 1){
721 bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
723 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
725 if (myPreviewCheck->isChecked()) {
730 myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
732 myPosTable->item(theRow, 0)->setEnabled(!isDefault);
736 void VisuGUI_CutLinesDlg::accept()
738 VisuGUI_ScalarBarBaseDlg::accept();
741 void VisuGUI_CutLinesDlg::reject()
743 VisuGUI_ScalarBarBaseDlg::reject();
746 void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview)
748 if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
758 /*! Inverting all curves in the table
760 void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert)
762 bool anIsAllCurvesInverted = myAllCurvesInvertedCheck->isChecked();
764 myCutLines->SetAllCurvesInverted( anIsAllCurvesInverted );
765 myPrsCopy->SetAllCurvesInverted( anIsAllCurvesInverted );
770 void VisuGUI_CutLinesDlg::onRotation (double theValue)
772 if (!myCutLines) return;
773 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
775 if (myPreviewCheck->isChecked()) {
782 void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue)
784 if (!myCutLines) return;
785 SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
787 if (myPreviewCheck->isChecked()) {
794 QString VisuGUI_CutLinesDlg::GetContextHelpFilePath()
796 return "cut_lines_page.html";