#include "VISU_StreamLines_i.hh"
#include "VISU_Actor.h"
+#include <vtkRenderer.h>
+
+
static double MAXVALUE = 1.0E+300;
#define MAXVAL 1e10
ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
: QDialog(theParent, "ArrangeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myAnimator(theAnimator)
+ myAnimator(theAnimator), myViewFrame(0)
{
myCurrent = 0;
init();
}
+ArrangeDlg::ArrangeDlg(QWidget* theParent, VTKViewer_ViewFrame* theViewFrame)
+ : QDialog(theParent, "ArrangeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+ myAnimator(0), myViewFrame(theViewFrame)
+{
+ myCurrent = 0;
+ init();
+ QStringList aPrsNames;
+ vtkActor* anActor;
+ vtkActorCollection *anActColl = myViewFrame->getRenderer()->GetActors();
+ for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;) {
+ if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
+ if (anVISUActor->GetVisibility() != 0)
+ if (VISU::Prs3d_i* aPrs = anVISUActor->GetParent()->GetPrs3d()) {
+ if (!myPrsMap.contains(aPrs)) {
+ SALOMEDS::SObject_var aSObject = aPrs->GetSObject();
+ if(!aSObject->_is_nil()){
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ string aNam = aName->Value();
+ QString strIn(aNam.c_str());
+ aPrsNames.append(strIn);
+ myPrsMap[aPrs] = myOffsets.count();
+ Offset aOffs;
+ anVISUActor->GetPosition(aOffs.myOffset);
+ myOffsets.append(aOffs);
+ }
+ }
+ }
+ }
+ }
+ myFieldLst->insertStringList(aPrsNames);
+ myFieldLst->setSelected(0, true);
+}
+
+
+
void ArrangeDlg::init()
{
setCaption("Arrange Presentations");
//Distance Input
QHBox* aDistPane = new QHBox(aAutoPane);
aDistPane->setSpacing(5);
- new QLabel("Distance", aDistPane);
- myDistVal = new QAD_SpinBoxDbl(aDistPane, -5, 5, 0.5 );
- myDistVal->setValue(0.5);
+ new QLabel("Relative Distance", aDistPane);
+ myDistVal = new QAD_SpinBoxDbl(aDistPane, -10,10, 0.5 );
+ myDistVal->setValue(1);
myStackWgt->addWidget(aAutoPane, AutoMode);
connect(aBtnGrp, SIGNAL(clicked(int)), myStackWgt, SLOT(raiseWidget(int)) );
+ if (!myAnimator) {
+ mySaveChk = new QCheckBox("Save to presentation", this);
+ mySaveChk->setChecked(false);
+ aMainLayout->addWidget(mySaveChk);
+ }
+
// Common buttons ===========================================================
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setColumnLayout(0, Qt::Vertical );
void ArrangeDlg::accept()
+{
+ if (myAnimator) {
+ acceptAnimation();
+ } else {
+ acceptViewWindow();
+ }
+ QDialog::accept();
+}
+
+void ArrangeDlg::onFieldChange(int theCurrent)
+{
+ if (myCurrent != theCurrent) {
+ Offset& aOffs = myOffsets[myCurrent];
+ aOffs.myOffset[0] = myCoord[0]->value();
+ aOffs.myOffset[1] = myCoord[1]->value();
+ aOffs.myOffset[2] = myCoord[2]->value();
+ }
+ myCurrent = theCurrent;
+ const Offset& aNewOffs = myOffsets[myCurrent];
+ myCoord[0]->setValue(aNewOffs.myOffset[0]);
+ myCoord[1]->setValue(aNewOffs.myOffset[1]);
+ myCoord[2]->setValue(aNewOffs.myOffset[2]);
+}
+
+void ArrangeDlg::acceptAnimation()
{
if (getMode() == ManualMode) {
// Save from GUI
int aAxis = getAxis();
switch (aAxis) {
case XAxis:
- aDist = fabs(aBounds[3] - aBounds[0]);
+ aDist = fabs(aBounds[1] - aBounds[0]);
break;
case YAxis:
- aDist = fabs(aBounds[4] - aBounds[1]);
+ aDist = fabs(aBounds[3] - aBounds[2]);
break;
case ZAxis:
- aDist = fabs(aBounds[5] - aBounds[2]);
+ aDist = fabs(aBounds[5] - aBounds[4]);
}
- aDist += aDist*getDistance();
+ aDist = aDist*getDistance();
for (int i = 0; i < myAnimator->getNbFields(); i++) {
myAnimator->getFieldData(i).myOffset[0] = 0;
myAnimator->getFieldData(i).myOffset[1] = 0;
myAnimator->getFieldData(i).myOffset[2] = 0;
myAnimator->getFieldData(i).myOffset[aAxis] = aDist * i;
}
-
+
QApplication::restoreOverrideCursor();
}
- QDialog::accept();
}
-void ArrangeDlg::onFieldChange(int theCurrent)
+void ArrangeDlg::acceptViewWindow()
{
- if (myCurrent != theCurrent) {
+ if (getMode() == ManualMode) {
+ // Save from GUI
Offset& aOffs = myOffsets[myCurrent];
aOffs.myOffset[0] = myCoord[0]->value();
aOffs.myOffset[1] = myCoord[1]->value();
aOffs.myOffset[2] = myCoord[2]->value();
+
+ QMap<VISU::Prs3d_i*, int>::Iterator it;
+ for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it) {
+ VISU::Prs3d_i* aPrs = it.key();
+ Offset& aOffs = myOffsets[it.data()];
+ if (VISU_Actor* anActor = VisuGUI::GetActor(aPrs, myViewFrame)) anActor->SetPosition(aOffs.myOffset);
+ if (mySaveChk->isChecked())aPrs->SetOffset(aOffs.myOffset);
+ }
+ } else {
+ float aDist = 0;
+ bool aInit = true;
+ int i;
+ QMap<VISU::Prs3d_i*, int>::Iterator it;
+ for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) {
+ VISU::Prs3d_i* aPrs = it.key();
+ if (VISU_Actor* aActor = VisuGUI::GetActor(aPrs, myViewFrame)){
+ int aAxis = getAxis();
+ if (aInit) {
+ float aBounds[6];
+ aActor->GetBounds(aBounds);
+ switch (aAxis) {
+ case XAxis:
+ aDist = fabs(aBounds[1] - aBounds[0]);
+ break;
+ case YAxis:
+ aDist = fabs(aBounds[3] - aBounds[2]);
+ break;
+ case ZAxis:
+ aDist = fabs(aBounds[5] - aBounds[4]);
+ }
+ aDist = aDist*getDistance();
+ aInit = false;
+ }
+ float aOffset[3];
+ aOffset[0] = aOffset[1] = aOffset[2] = 0;
+ aOffset[aAxis] = aDist * i;
+ aActor->SetPosition(aOffset);
+
+ if (mySaveChk->isChecked())aPrs->SetOffset(aOffset);
+ }
+ }
}
- myCurrent = theCurrent;
- const Offset& aNewOffs = myOffsets[myCurrent];
- myCoord[0]->setValue(aNewOffs.myOffset[0]);
- myCoord[1]->setValue(aNewOffs.myOffset[1]);
- myCoord[2]->setValue(aNewOffs.myOffset[2]);
+ myViewFrame->getRenderer()->ResetCameraClippingRange();
+ myViewFrame->Repaint();
}
-
-
//*****************************************************************************************************
//*****************************************************************************************************
//*****************************************************************************************************