-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// VISU VISUGUI : GUI of VISU component
// File : VisuGUI_TransparencyDlg.cxx
// Author : Nicolas REJNERI
#include <QGroupBox>
#include <QKeyEvent>
-using namespace std;
+const int DEFAULT_OPACITY = 100;
+const int UNDEF_OPACITY = -1;
//=================================================================================
// class : VisuGUI_TransparencyDlg()
//=================================================================================
VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule,
bool modal )
- : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
- myModule(theModule),
- mySelectionMgr( VISU::GetSelectionMgr( theModule ) ),
- myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule) )
+ : QDialog( VISU::GetDesktop( theModule ), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+ myModule(theModule),
+ mySelectionMgr( VISU::GetSelectionMgr( theModule ) ),
+ myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule) )
{
setModal( modal );
setAttribute( Qt::WA_DeleteOnClose );
GroupC1Layout->setMargin(11);
TextLabelTransparent = new QLabel(tr("TRANSPARENCY_TRANSPARENT" ), GroupC1);
- TextLabelTransparent->setAlignment(Qt::AlignLeft);
- GroupC1Layout->addWidget(TextLabelTransparent, 0, 0);
+ TextLabelTransparent->setAlignment(Qt::AlignRight);
+ GroupC1Layout->addWidget(TextLabelTransparent, 0, 2);
ValueLab = new QLabel(GroupC1);
ValueLab->setAlignment(Qt::AlignCenter);
GroupC1Layout->addWidget(ValueLab, 0, 1);
TextLabelOpaque = new QLabel(tr("TRANSPARENCY_OPAQUE" ), GroupC1);
- TextLabelOpaque->setAlignment(Qt::AlignRight);
- GroupC1Layout->addWidget(TextLabelOpaque, 0, 2);
+ TextLabelOpaque->setAlignment(Qt::AlignLeft);
+ GroupC1Layout->addWidget(TextLabelOpaque, 0, 1);
Slider1 = new QSlider( Qt::Horizontal, GroupC1 );
Slider1->setMinimum( 0 );
//=======================================================================
void VisuGUI_TransparencyDlg::ClickOnHelp()
{
- QString aHelpFileName = "viewing_3d_presentations_intro_page.html#width_opacity_anchor";
+ QString aHelpFileName = "viewing_3d_presentations_page.html#width_opacity_anchor";
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
if (app) {
VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
}
else {
- QString platform;
+ QString platform;
#ifdef WIN32
- platform = "winapplication";
+ platform = "winapplication";
#else
- platform = "application";
+ platform = "application";
#endif
SUIT_MessageBox::warning(0, tr("WRN_WARNING"),
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
{
if( myViewWindow ) {
SUIT_OverrideCursor wc;
- float opacity = this->Slider1->value() / 100.;
+ float opacity = (100 - this->Slider1->value() ) / 100.;
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList);
for (; anIter.More(); anIter.Next()) {
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
- if (anActor)
- anActor->SetOpacity(opacity);
- else {
- VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
if (anActor)
anActor->SetOpacity(opacity);
+ else {
+ VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
+ if (anActor)
+ anActor->SetOpacity(opacity);
}
}
myViewWindow->Repaint();
//=================================================================================
void VisuGUI_TransparencyDlg::onSelectionChanged()
{
- if( myViewWindow ) {
- int opacity = 100;
+ if ( myViewWindow ) {
+ int opacity = UNDEF_OPACITY;
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList);
- if (aList.Extent() == 1) {
- Handle(SALOME_InteractiveObject) FirstIOS = aList.First();
- if (!FirstIOS.IsNull()) {
- VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), 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(VISU::GetAppStudy(myModule), 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;
- }
+ SALOME_ListIteratorOfListIO It (aList);
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) IO = It.Value();
+ if (!IO.IsNull()) {
+ int op = UNDEF_OPACITY;
+ VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry());
+ if (anActor) {
+ op = int(anActor->GetOpacity() * 100. + 0.5);
+ }
+ else {
+ VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry());
+ if (anActor)
+ op = int(anActor->GetOpacity() * 100. + 0.5);
+ }
+ if ( op != UNDEF_OPACITY ) {
+ if ( opacity == UNDEF_OPACITY )
+ opacity = op;
+ else if ( opacity != op ) {
+ opacity = DEFAULT_OPACITY;
+ break;
}
}
}
- if (setOp >= 0)
- opacity = setOp;
- } else {
}
- Slider1->setValue(opacity);
+ Slider1->setValue( 100 - ( opacity == UNDEF_OPACITY ? DEFAULT_OPACITY : opacity ) );
}
ValueHasChanged();
}