#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 );
anActor->SetOpacity(opacity);
else {
VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
- if (anActor)
- anActor->SetOpacity(opacity);
+ 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( opacity == UNDEF_OPACITY ? DEFAULT_OPACITY : opacity );
}
ValueHasChanged();
}