#include "VISU_CutLines_i.hh"
#include "VISU_PipeLine.hxx"
+#include "VISU_PipeLineUtils.hxx"
#include "VISU_CutLinesPL.hxx"
#include "SVTK_ViewWindow.h"
#include <vtkPolyData.h>
#include <vtkAppendPolyData.h>
#include <vtkDataSetMapper.h>
+#include <vtkGlyph3D.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkFloatArray.h>
+#include <vtkGlyphSource2D.h>
using namespace std;
bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
-VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule,
- bool theIsCreation, bool theIsModal)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", theIsModal,
+VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
+ : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myPreviewActor(0)
+ myPreviewActor(0),myPreviewActorGlyphs(0)
{
- if (!theIsModal) {
- setWFlags(getWFlags() | WDestructiveClose);
- }
setCaption("Cut Lines Definition");
setSizeGripEnabled(true);
- myIsCreation = theIsCreation;
QVBoxLayout* aMainLayout = new QVBoxLayout (this, 7, 6);
aMainLayout->setSpacing(5);
QRadioButton* aBxy = new QRadioButton( tr( "PARALLEL_XOY" ), mySelPlane); // 0
QRadioButton* aByz = new QRadioButton( tr( "PARALLEL_YOZ" ), mySelPlane); // 1
QRadioButton* aBzx = new QRadioButton( tr( "PARALLEL_ZOX" ), mySelPlane); // 2
+ aBxy->setChecked(false);
+ aByz->setChecked(false);
aBzx->setChecked(true);
aPlaneLayout->addWidget( mySelPlane );
myPreviewCheck->setChecked(false);
aPlaneLayout->addWidget(myPreviewCheck);
+ myAllCurvesInvertedCheck = new QCheckBox(tr("LBL_INVERT_CURVES"), aPlanePane);
+ myAllCurvesInvertedCheck->setChecked(false);
+ aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
+
myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
myCreateTable->setChecked(MYGenerateTable);
aPlaneLayout->addWidget( myCreateTable );
connect(th , SIGNAL(clicked(int)) , this, SLOT(setDefault(int)));
connect(myPosSpn2 , SIGNAL(valueChanged(double)) , this, SLOT(DrawTable()));
connect(myPreviewCheck, SIGNAL(toggled(bool)) , this, SLOT(onPreviewCheck(bool)));
+ connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool)));
connect(myPosTable , SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)));
connect(myRotXSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
connect(myRotYSpn , SIGNAL(valueChanged(double)) , this, SLOT(onRotation(double)));
hasInit = true;
myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
myCutLines->SameAs(thePrs);
+ myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
+ if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
myCBSetDef->setChecked(thePrs->IsDefault());
DrawTable();
thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
else thePrs->SetDefaultPosition(i);
}
+ if (myAllCurvesInvertedCheck->isChecked())
+ thePrs->SetAllCurvesInverted(true);
return 1;
}
vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
aPlaneMapper->SetInput(aPolyData->GetOutput());
aPlaneMapper->ScalarVisibilityOff();
-
+
+ myPreviewActorGlyphs = myPreviewActorGlyphs = SALOME_Actor::New();
+ myPreviewActorGlyphs->PickableOff();
+ updateGlyphs(false);
+
myPreviewActor = SALOME_Actor::New();
myPreviewActor->PickableOff();
myPreviewActor->SetMapper(aPlaneMapper);
aPlaneMapper->Delete();
aView->AddActor(myPreviewActor);
+ aView->AddActor(myPreviewActorGlyphs);
aView->getRenderer()->Render();
aView->onFitAll();
}
void VisuGUI_CutLinesDlg::deletePlanes()
{
if (myPreviewActor == 0) return;
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow())
+ if (SVTK_ViewWindow* aView = VISU::GetViewWindow()){
aView->RemoveActor(myPreviewActor);
+ aView->RemoveActor(myPreviewActorGlyphs);
+ }
myPreviewActor->Delete();
+ myPreviewActorGlyphs->Delete();
myPreviewActor = 0;
+ myPreviewActorGlyphs = 0;
}
myRotXLbl2->setText( tr("LBL_ROT_Z"));
myRotYLbl2->setText( tr("LBL_ROT_X"));
}
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
/*myCutLines->SetOrientation2(getOrientaion(false),
myRotXSpn2->value()*PI/180.,
/* float aPos = myCutLines->GetBasePlanePosition();
myBasePlanePos->setText( QString::number(aPos) );
myBasePlanePos->setEnabled(false);*/
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
//myCutLines->SetBasePlanePosition(aPos);
// myCutLines->GetPL()->Update();
vh->setLabel( i, str.arg(i+1) );
}
// Update preview
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (myPreviewCheck->isChecked()) {
// myCutLines->GetPL()->Update();
deletePlanes();
}
}
+void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
+ if (myPreviewActorGlyphs == 0 ) return;
+ const float *aDirLn = myCutLines->GetCutLinesPL()->GetDirLn();
+ const float *aBasePnt = myCutLines->GetCutLinesPL()->GetBasePnt();
+ float aSecondPnt[3];
+ float aBoundCenter[3];
+
+ vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
+ vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
+ aPlaneMapper->SetInput(aPolyData->GetOutput());
+ float bounds[6];
+ aPlaneMapper->GetBounds(bounds);
+
+ for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0;
+ for(int i=0; i<3; i++){
+ if (!myAllCurvesInvertedCheck->isChecked())
+ aSecondPnt[i] = aBasePnt[i] + aDirLn[i];
+ else
+ aSecondPnt[i] = -aBasePnt[i] - aDirLn[i];
+ }
+
+ float max_bound = 0;
+ max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound;
+ max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound;
+ max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound;
+
+ vtkPolyData* profile = vtkPolyData::New();
+ vtkPoints* aPoints = vtkPoints::New();
+ vtkGlyph3D* glyphs = vtkGlyph3D::New();
+ vtkFloatArray *aFloatArray = vtkFloatArray::New();
+ vtkGlyphSource2D* source = vtkGlyphSource2D::New();
+
+ source->FilledOn();
+ source->SetCenter(aBoundCenter);
+ source->SetGlyphTypeToArrow();
+
+ aPoints->InsertNextPoint(aBasePnt);
+ profile->SetPoints(aPoints);
+
+ aFloatArray->SetNumberOfComponents(3);
+ for(int i=0; i<3 ;i++)
+ aFloatArray->InsertNextValue(aSecondPnt[i]);
+
+ vtkDataSetAttributes* aDataSetAttributes;
+ aDataSetAttributes = profile->GetPointData();
+ aDataSetAttributes->SetVectors(aFloatArray);
+
+ glyphs->SetScaleFactor(0.25*max_bound);
+ glyphs->SetVectorModeToUseVector();
+ glyphs->SetScaleModeToScaleByVector();
+ glyphs->SetInput(profile);
+ glyphs->SetSource(source->GetOutput());
+
+ vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New();
+ aGlyphsMapper->ScalarVisibilityOff();
+ aGlyphsMapper->SetInput(glyphs->GetOutput());
+
+ myPreviewActorGlyphs->SetMapper(aGlyphsMapper);
+
+ profile->Delete();
+ glyphs->Delete();
+ aPoints->Delete();
+ aGlyphsMapper->Delete();
+ aFloatArray->Delete();
+ source->Delete();
+ aPlaneMapper->Delete();
+
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow())
+ if (update)
+ vf->Repaint();
+}
+
//------------------------------------------------------------------------------
void VisuGUI_CutLinesDlg::setDefault (int all)
{
QString aTxt = myPosTable->text(theRow, 0);
bool isChanged = !aTxt.isEmpty();
((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
-
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (myPreviewCheck->isChecked()) {
//Update Preview
//myCutLines->SetLinePosition( theRow, aTxt.toDouble());
//aView->Repaint();
}
}
- } else {
+ } else if (theCol == 1){
bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
if (isDefault) {
//myCutLines->SetDefaultPosition(theRow);
// myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
-
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (myPreviewCheck->isChecked()) {
//Update Preview
// myCutLines->GetPL()->Update();
}
}
+/*! Inverting all curves in the table
+ */
+void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert)
+{
+ if (myAllCurvesInvertedCheck->isChecked()){
+ myCutLines->SetAllCurvesInverted(true);
+ myPrs->SetAllCurvesInverted(true);
+ }
+ else {
+ myCutLines->SetAllCurvesInverted(false);
+ myPrs->SetAllCurvesInverted(false);
+ }
+ updateGlyphs(true);
+}
+
void VisuGUI_CutLinesDlg::onRotation (double theValue)
{
if (myCutLines == NULL) return;
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (myPreviewCheck->isChecked()) {
/*myCutLines->SetOrientation(getOrientaion(),
void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue)
{
if (myCutLines == NULL) return;
- if (SVTK_ViewWindow* aView = VISU::GetViewWindow()) {
+ SVTK_ViewWindow* aView = VISU::GetViewWindow();
+ if (aView) {
if (myPreviewCheck->isChecked()) {
//myCutLines->SetBasePlanePosition(theValue.toDouble());
// myCutLines->GetPL()->Update();