--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VisuGUI_TransparencyDlg.cxx
+// Author : Nicolas REJNERI
+// Module : VISU
+// $Header$
+
+#include "VisuGUI_TransparencyDlg.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_Tools.h"
+#include "VISU_Actor.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_OverrideCursor.h"
+
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOME_InteractiveObject.hxx"
+
+#include "LightApp_Study.h"
+#include "LightApp_SelectionMgr.h"
+
+#include "SVTK_ViewWindow.h"
+
+// QT Includes
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qslider.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+
+using namespace std;
+
+//=================================================================================
+// class : VisuGUI_TransparencyDlg()
+// purpose :
+//
+//=================================================================================
+VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule,
+ const char* name,
+ bool modal,
+ WFlags fl)
+ : QDialog( VISU::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+ mySelectionMgr( VISU::GetSelectionMgr( theModule ) ),
+ myViewWindow( VISU::GetViewWindow( theModule ) )
+{
+ if (!name)
+ setName("VisuGUI_TransparencyDlg");
+ setCaption(tr("TRANSPARENCY_TITLE" ));
+ setSizeGripEnabled(TRUE);
+ QGridLayout* VisuGUI_TransparencyDlgLayout = new QGridLayout(this);
+ VisuGUI_TransparencyDlgLayout->setSpacing(6);
+ VisuGUI_TransparencyDlgLayout->setMargin(11);
+
+ /*************************************************************************/
+ QGroupBox* GroupC1 = new QGroupBox(this, "GroupC1");
+ GroupC1->setColumnLayout(0, Qt::Vertical);
+ GroupC1->layout()->setSpacing(0);
+ GroupC1->layout()->setMargin(0);
+ QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout());
+ GroupC1Layout->setAlignment(Qt::AlignTop);
+ GroupC1Layout->setSpacing(6);
+ GroupC1Layout->setMargin(11);
+
+ TextLabelTransparent = new QLabel(GroupC1, "TextLabelTransparent");
+ TextLabelTransparent->setText(tr("TRANSPARENCY_TRANSPARENT" ));
+ TextLabelTransparent->setAlignment(AlignLeft);
+ GroupC1Layout->addWidget(TextLabelTransparent, 0, 0);
+
+ ValueLab = new QLabel(GroupC1, "ValueLab");
+ ValueLab->setAlignment(AlignCenter);
+ ValueLab->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+ QFont fnt = ValueLab->font(); fnt.setBold(true); ValueLab->setFont(fnt);
+ GroupC1Layout->addWidget(ValueLab, 0, 1);
+
+ TextLabelOpaque = new QLabel(GroupC1, "TextLabelOpaque");
+ TextLabelOpaque->setText(tr("TRANSPARENCY_OPAQUE" ));
+ TextLabelOpaque->setAlignment(AlignRight);
+ GroupC1Layout->addWidget(TextLabelOpaque, 0, 2);
+
+ Slider1 = new QSlider(0, 10, 1, 5, Horizontal, GroupC1, "Slider1");
+ Slider1->setFocusPolicy(QWidget::NoFocus);
+ Slider1->setMinimumSize(300, 0);
+ Slider1->setTickmarks(QSlider::Above);
+ Slider1->setTickInterval(10);
+ Slider1->setTracking(true);
+ Slider1->setMinValue(0);
+ Slider1->setMaxValue(100);
+ Slider1->setLineStep(1);
+ Slider1->setPageStep(10);
+ GroupC1Layout->addMultiCellWidget(Slider1, 1, 1, 0, 2);
+
+ /*************************************************************************/
+ QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
+ GroupButtons->setColumnLayout(0, Qt::Vertical);
+ GroupButtons->layout()->setSpacing(0);
+ GroupButtons->layout()->setMargin(0);
+ QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
+ GroupButtonsLayout->setAlignment(Qt::AlignTop);
+ GroupButtonsLayout->setSpacing(6);
+ GroupButtonsLayout->setMargin(11);
+
+ buttonOk = new QPushButton(GroupButtons, "buttonOk");
+ buttonOk->setText(tr("BUT_CLOSE"));
+ buttonOk->setAutoDefault(TRUE);
+ buttonOk->setDefault(TRUE);
+ GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0);
+ GroupButtonsLayout->addWidget(buttonOk, 0, 1);
+ GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2);
+
+ VisuGUI_TransparencyDlgLayout->addWidget(GroupC1, 0, 0);
+ VisuGUI_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0);
+
+ // Initial state
+ this->onSelectionChanged();
+
+ // signals and slots connections : after ValueHasChanged()
+ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(Slider1, SIGNAL(valueChanged(int)), this, SLOT(SetTransparency()));
+ connect(Slider1, SIGNAL(sliderMoved(int)), this, SLOT(ValueHasChanged()));
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
+}
+
+//=================================================================================
+// function : ~VisuGUI_TransparencyDlg()
+// purpose :
+//=================================================================================
+VisuGUI_TransparencyDlg::~VisuGUI_TransparencyDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=======================================================================
+// function : ClickOnOk()
+// purpose :
+//=======================================================================
+void VisuGUI_TransparencyDlg::ClickOnOk()
+{
+ close();
+}
+
+//=================================================================================
+// function : SetTransparency()
+// purpose : Called when value of slider change
+// : or the first time as initilisation
+//=================================================================================
+void VisuGUI_TransparencyDlg::SetTransparency()
+{
+ if( myViewWindow ) {
+ SUIT_OverrideCursor wc;
+ float opacity = this->Slider1->value() / 100.;
+
+ SALOME_ListIO aList;
+ mySelectionMgr->selectedObjects(aList);
+
+ SALOME_ListIteratorOfListIO It (aList);
+ for (;It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ VISU_Actor* anActor = VISU::FindActor(myViewWindow, IOS->getEntry());
+ if (anActor)
+ anActor->SetOpacity(opacity);
+ }
+ myViewWindow->Repaint();
+ }
+ ValueHasChanged();
+}
+
+//=================================================================================
+// function : ValueHasChanged()
+// purpose : Called when user moves a slider
+//=================================================================================
+void VisuGUI_TransparencyDlg::ValueHasChanged()
+{
+ ValueLab->setText(QString::number(this->Slider1->value()) + "%");
+}
+
+//=================================================================================
+// function : onSelectionChanged()
+// purpose : Called when selection is changed
+//=================================================================================
+void VisuGUI_TransparencyDlg::onSelectionChanged()
+{
+ if( myViewWindow ) {
+ int opacity = 100;
+
+ SALOME_ListIO aList;
+ mySelectionMgr->selectedObjects(aList);
+
+ if (aList.Extent() == 1) {
+ Handle(SALOME_InteractiveObject) FirstIOS = aList.First();
+ if (!FirstIOS.IsNull()) {
+ VISU_Actor* anActor = VISU::FindActor(myViewWindow, FirstIOS->getEntry());
+ if (anActor)
+ opacity = int(anActor->GetOpacity() * 100. + 0.5);
+ }
+ } else if (aList.Extent() > 1) {
+ SALOME_ListIteratorOfListIO It (aList);
+ int setOp = -1;
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) IO = It.Value();
+ if (!IO.IsNull()) {
+ VISU_Actor* anActor = VISU::FindActor(myViewWindow, IO->getEntry());
+ if (anActor) {
+ int op = int(anActor->GetOpacity() * 100. + 0.5);
+ if (setOp < 0)
+ setOp = op;
+ else if (setOp != op) {
+ setOp = 100;
+ break;
+ }
+ }
+ }
+ }
+ if (setOp >= 0)
+ opacity = setOp;
+ } else {
+ }
+ Slider1->setValue(opacity);
+ }
+ ValueHasChanged();
+}
--- /dev/null
+// VISU VisuGUI : GUI for VISU component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VisuGUI_TransparencyDlg.h
+// Author : Nicolas REJNERI
+// Module : VISU
+// $Header$
+
+#ifndef VISUGUI_TRANSPARENCYDLG_H
+#define VISUGUI_TRANSPARENCYDLG_H
+
+// QT Includes
+#include <qdialog.h>
+
+class QLabel;
+class QPushButton;
+class QSlider;
+class LightApp_SelectionMgr;
+class SVTK_Selector;
+class SVTK_ViewWindow;
+class VisuGUI;
+
+//=================================================================================
+// class : VisuGUI_TransparencyDlg
+// purpose :
+//=================================================================================
+class VisuGUI_TransparencyDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_TransparencyDlg( VisuGUI* = 0,
+ const char* name = 0,
+ bool modal = false,
+ WFlags fl = 0 );
+
+ ~VisuGUI_TransparencyDlg();
+
+private :
+ LightApp_SelectionMgr* mySelectionMgr;
+ SVTK_ViewWindow* myViewWindow;
+
+ QPushButton* buttonOk;
+ QLabel* TextLabelOpaque;
+ QLabel* ValueLab;
+ QLabel* TextLabelTransparent;
+ QSlider* Slider1;
+
+public slots:
+ void ClickOnOk();
+ void ValueHasChanged();
+ void SetTransparency();
+ void onSelectionChanged();
+};
+
+#endif