From 46714cdec7e7f00a18297c6c984159ef9a72b2f7 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 28 Sep 2009 10:43:18 +0000 Subject: [PATCH] Bug 0020164: EDF 954 VISU : Constant field with Gauss points. --- resources/SalomeApp.xml | 8 +- src/OBJECT/VISU_Actor.cxx | 553 +++++++------- src/PIPELINE/VISU_Extractor.cxx | 47 +- src/PIPELINE/VISU_LookupTable.cxx | 425 ++++++----- src/VISUGUI/VisuGUI.cxx | 830 +++++++++++----------- src/VISUGUI/VisuGUI_GaussPointsDlg.cxx | 93 ++- src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 213 +++--- src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx | 70 +- 8 files changed, 1153 insertions(+), 1086 deletions(-) diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 5e96f572..aa37a110 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -73,7 +73,7 @@ - + @@ -109,9 +109,9 @@ - - - + + + diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 1c29b5d7..68b879e2 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -20,12 +20,13 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // VISU OBJECT : interactive object for VISU entities implementation -// File : -// Author : +// File : +// Author : // Module : VISU #include "VISU_Actor.h" +#include "VISU_ActorFactory.h" #include "VISU_PickingSettings.h" #include "VISU_GaussPtsDeviceActor.h" @@ -37,9 +38,12 @@ #include "VTKViewer_FramedTextActor.h" #include "VTKViewer_ShrinkFilter.h" #include "VTKViewer_GeometryFilter.h" -#include "VISU_ActorFactory.h" + #include "SALOME_InteractiveObject.hxx" - + +#include "SUIT_Session.h" +#include "SUIT_ResourceMgr.h" + #include #include @@ -138,14 +142,14 @@ VISU_Actor myFeatureEdges->Delete(); myEventCallbackCommand->Delete(); - myEventCallbackCommand->SetClientData(this); + myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VISU_Actor::ProcessEvents); if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() ) - aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - + aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + //Definition of values labeling pipeline myValLblDataSet = vtkUnstructuredGrid::New(); @@ -156,17 +160,27 @@ VISU_Actor myValMaskPoints = vtkMaskPoints::New(); myValMaskPoints->SetInput(myValCellCenters->GetOutput()); myValMaskPoints->SetOnRatio(1); - + myValSelectVisiblePoints = vtkSelectVisiblePoints::New(); myValSelectVisiblePoints->SetInput(myValMaskPoints->GetOutput()); myValSelectVisiblePoints->SelectInvisibleOff(); myValSelectVisiblePoints->SetTolerance(0.1); - + + char aFormat[16] = "%g"; + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + if (aResourceMgr) { + int aFloatingPrec = aResourceMgr->integerValue("VISU", "floating_point_precision", 6); + sprintf(aFormat, "%%.%dg", aFloatingPrec); + //cout << "$$$ aFormat = " << aFormat << endl; + } + myValLabeledDataMapper = vtkLabeledDataMapper::New(); myValLabeledDataMapper->SetInput(myValSelectVisiblePoints->GetOutput()); - myValLabeledDataMapper->SetLabelFormat("%g"); + //myValLabeledDataMapper->SetLabelFormat("%g"); + //myValLabeledDataMapper->SetLabelFormat("%.20g"); + myValLabeledDataMapper->SetLabelFormat(aFormat); myValLabeledDataMapper->SetLabelModeToLabelScalars(); - + vtkTextProperty* aClsTextProp = vtkTextProperty::New(); aClsTextProp->SetFontFamilyToTimes(); static int aCellsFontSize = 12; @@ -176,7 +190,7 @@ VISU_Actor aClsTextProp->SetShadow(0); myValLabeledDataMapper->SetLabelTextProperty(aClsTextProp); aClsTextProp->Delete(); - + myIsValLabeled = false; myValLabels = vtkActor2D::New(); @@ -241,58 +255,58 @@ VISU_Actor } //---------------------------------------------------------------------------- -void +void VISU_Actor ::setIO(const Handle(SALOME_InteractiveObject)& theIO) { - Superclass::setIO(theIO); - myName = theIO->getName(); + Superclass::setIO(theIO); + myName = theIO->getName(); } //---------------------------------------------------------------------------- -void +void VISU_Actor ::SetPrs3d(VISU::Prs3d_i* thePrs3d) -{ +{ myPrs3d = thePrs3d; } -VISU::Prs3d_i* +VISU::Prs3d_i* VISU_Actor ::GetPrs3d() -{ +{ return myPrs3d; } //---------------------------------------------------------------------------- void VISU_Actor -::SetPipeLine(VISU_PipeLine* thePipeLine) +::SetPipeLine(VISU_PipeLine* thePipeLine) { myPipeLine = thePipeLine; if(thePipeLine){ if(vtkMapper *aMapper = myPipeLine->GetMapper()){ if(vtkDataSet *aDataSet = aMapper->GetInput()){ - SetShrinkable(thePipeLine->IsShrinkable()); - SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed()); - SetMapperInput(aDataSet); + SetShrinkable(thePipeLine->IsShrinkable()); + SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed()); + SetMapperInput(aDataSet); } } } this->Modified(); } -VISU_PipeLine* +VISU_PipeLine* VISU_Actor -::GetPipeLine() -{ +::GetPipeLine() +{ return myPipeLine.GetPointer(); } -VISU_PipeLine* +VISU_PipeLine* VISU_Actor -::GetCurrentPL() -{ +::GetCurrentPL() +{ return GetPipeLine(); } @@ -300,8 +314,8 @@ VISU_Actor //---------------------------------------------------------------------------- void VISU_Actor -::SetRepresentation(int theMode) -{ +::SetRepresentation(int theMode) +{ Superclass::SetRepresentation(theMode); if(myRepresentation == VTK_POINTS) { @@ -316,7 +330,7 @@ void VISU_Actor ::SetShrink() { - if(!myIsShrinkable) + if(!myIsShrinkable) return; if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ myShrinkFilter->SetInput(aDataSet); @@ -329,7 +343,7 @@ void VISU_Actor ::UnShrink() { - if(!myIsShrunk) + if(!myIsShrunk) return; if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ myPassFilter[1]->SetInput(aDataSet); @@ -355,8 +369,8 @@ VISU_Actor bool VISU_Actor -::IsShrunkable() -{ +::IsShrunkable() +{ return myIsShrinkable; } @@ -379,8 +393,8 @@ VISU_Actor //---------------------------------------------------------------------------- bool VISU_Actor -::IsFeatureEdgesAllowed() -{ +::IsFeatureEdgesAllowed() +{ return myIsFeatureEdgesAllowed; } @@ -402,7 +416,7 @@ void VISU_Actor ::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled) { - if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled ) + if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled ) return; if ( vtkPolyData* aPolyData = myPassFilter[ 2 ]->GetPolyDataOutput() ) @@ -442,9 +456,9 @@ VISU_Actor void VISU_Actor ::GetFeatureEdgesFlags(bool& theIsFeatureEdges, - bool& theIsBoundaryEdges, - bool& theIsManifoldEdges, - bool& theIsNonManifoldEdges) + bool& theIsBoundaryEdges, + bool& theIsManifoldEdges, + bool& theIsNonManifoldEdges) { theIsFeatureEdges = myFeatureEdges->GetFeatureEdges(); theIsBoundaryEdges = myFeatureEdges->GetBoundaryEdges(); @@ -455,9 +469,9 @@ VISU_Actor void VISU_Actor ::SetFeatureEdgesFlags(bool theIsFeatureEdges, - bool theIsBoundaryEdges, - bool theIsManifoldEdges, - bool theIsNonManifoldEdges) + bool theIsBoundaryEdges, + bool theIsManifoldEdges, + bool theIsNonManifoldEdges) { myFeatureEdges->SetFeatureEdges(theIsFeatureEdges); myFeatureEdges->SetBoundaryEdges(theIsBoundaryEdges); @@ -492,7 +506,7 @@ VISU_Actor vtkFloatingPointType VISU_Actor ::GetOpacity() -{ +{ return GetProperty()->GetOpacity(); } @@ -538,12 +552,12 @@ VISU_Actor theRenderer->RemoveActor(myAnnotationActor.GetPointer()); theRenderer->RemoveActor(myTextActor.GetPointer()); theRenderer->RemoveActor(myValLabels); - Superclass::RemoveFromRender(theRenderer); + Superclass::RemoveFromRender(theRenderer); myDestroySignal(this); } //---------------------------------------------------------------------------- -void +void VISU_Actor ::SetVisibility(int theMode) { @@ -562,14 +576,14 @@ VISU_Actor return GetFactory()->GetActiveState(); } //---------------------------------------------------------------------------- -void +void VISU_Actor ::SetVTKMapping(bool theIsVTKMapping) { myIsVTKMapping = theIsVTKMapping; } -bool +bool VISU_Actor ::IsVTKMapping() const { @@ -577,7 +591,7 @@ VISU_Actor } //---------------------------------------------------------------------------- -vtkDataSet* +vtkDataSet* VISU_Actor ::GetInput() { @@ -665,7 +679,7 @@ VISU_Actor return VISU::GetElemVTKID(GetMapper()->GetInput(), theID); } -vtkCell* +vtkCell* VISU_Actor ::GetElemCell(vtkIdType theObjID) { @@ -679,9 +693,9 @@ VISU_Actor //---------------------------------------------------------------------------- bool VISU_Actor -::isSubElementsHighlighted() -{ - return myIsSubElementsHighlighted; +::isSubElementsHighlighted() +{ + return myIsSubElementsHighlighted; } @@ -689,9 +703,9 @@ VISU_Actor inline void ChangeZoom(vtkFloatingPointType theZoomFactor, - vtkRenderer* theRenderer, - vtkIdType theInitialHasIndex, - vtkIdType theCurrentHasIndex) + vtkRenderer* theRenderer, + vtkIdType theInitialHasIndex, + vtkIdType theCurrentHasIndex) { //printf( "VISU_Actor::ChangeZoom( %d, %d )", theInitialHasIndex, theCurrentHasIndex ); if(theInitialHasIndex + theCurrentHasIndex == 1){ @@ -711,7 +725,7 @@ ChangeZoom(vtkFloatingPointType theZoomFactor, } /*! - Updates visibility of the highlight devices + Updates visibility of the highlight devices */ void VISU_Actor @@ -743,9 +757,9 @@ VISU_Actor { vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor(); ChangeZoom(aZoomFactor, - GetRenderer(), - anInitialHasIndex, - aCurrentHasIndex); + GetRenderer(), + anInitialHasIndex, + aCurrentHasIndex); } } @@ -757,95 +771,95 @@ VISU_Actor */ bool VISU_Actor -::PreHighlight(vtkInteractorStyle* theInteractorStyle, - SVTK_SelectionEvent* theSelectionEvent, - bool theIsHighlight) +::PreHighlight(vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight) { bool aRet = Superclass::PreHighlight(theInteractorStyle, - theSelectionEvent, - theIsHighlight); + theSelectionEvent, + theIsHighlight); #ifndef ENABLE_ANNOTATION return aRet; -#endif +#endif // myAnnotationActor->SetVisibility(0); if(theIsHighlight){ switch(mySelectionMode){ - case CellSelection:{ + case CellSelection:{ vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer(); - myCellPicker->Pick(theSelectionEvent->myX, - theSelectionEvent->myY, - 0.0, - aRenderer); + myCellPicker->Pick(theSelectionEvent->myX, + theSelectionEvent->myY, + 0.0, + aRenderer); if(myCellPicker->GetActor() != this) - return false; + return false; vtkIdType aVTKId = myCellPicker->GetCellId(); if(aVTKId >= 0 && mySelector->IsValid(this,aVTKId,true) && hasIO()){ - vtkIdType anObjId = GetElemObjId(aVTKId); - if(vtkCell* aCell = GetElemCell(anObjId)){ - vtkPoints* aPts = aCell->GetPoints(); - if(int aNbPts = aCell->GetNumberOfPoints()){ - vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0}; - for(int i = 0; i < aNbPts; i++){ - vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); - aCoord[0] += aPntCoord[0]; - aCoord[1] += aPntCoord[1]; - aCoord[2] += aPntCoord[2]; - } - // Display coordinates - vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0}; - aRenderer->SetWorldPoint(aWorldCoord); - aRenderer->WorldToDisplay(); - vtkFloatingPointType aSelectionPoint[3]; - aRenderer->GetDisplayPoint(aSelectionPoint); - myAnnotationActor->SetPosition(aSelectionPoint); - // - // To prepare the annotation text - std::ostringstream aStr; - aStr<<"Cell ID: "<< anObjId; - std::string aString = aStr.str(); - myAnnotationMapper->SetInput(aString.c_str()); - - myAnnotationActor->SetVisibility(1); - return true; - } - } + vtkIdType anObjId = GetElemObjId(aVTKId); + if(vtkCell* aCell = GetElemCell(anObjId)){ + vtkPoints* aPts = aCell->GetPoints(); + if(int aNbPts = aCell->GetNumberOfPoints()){ + vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0}; + for(int i = 0; i < aNbPts; i++){ + vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); + aCoord[0] += aPntCoord[0]; + aCoord[1] += aPntCoord[1]; + aCoord[2] += aPntCoord[2]; + } + // Display coordinates + vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myAnnotationActor->SetPosition(aSelectionPoint); + // + // To prepare the annotation text + std::ostringstream aStr; + aStr<<"Cell ID: "<< anObjId; + std::string aString = aStr.str(); + myAnnotationMapper->SetInput(aString.c_str()); + + myAnnotationActor->SetVisibility(1); + return true; + } + } } break; } - case NodeSelection:{ + case NodeSelection:{ vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer(); - myPointPicker->Pick(theSelectionEvent->myX, - theSelectionEvent->myY, - 0.0, - aRenderer); + myPointPicker->Pick(theSelectionEvent->myX, + theSelectionEvent->myY, + 0.0, + aRenderer); if(myPointPicker->GetActor() != this) - return false; + return false; vtkIdType aVtkId = myPointPicker->GetPointId(); if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ - vtkIdType anObjId = GetNodeObjId( aVtkId ); - if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){ - // Display coordinates - vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; - aRenderer->SetWorldPoint(aWorldCoord); - aRenderer->WorldToDisplay(); - vtkFloatingPointType aSelectionPoint[3]; - aRenderer->GetDisplayPoint(aSelectionPoint); - myAnnotationActor->SetPosition(aSelectionPoint); - // - // To prepare the annotation text - std::ostringstream aStr; - aStr<<"Node ID: "<< anObjId; - std::string aString = aStr.str(); - myAnnotationMapper->SetInput(aString.c_str()); - - myAnnotationActor->SetVisibility(1); - return true; - } + vtkIdType anObjId = GetNodeObjId( aVtkId ); + if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){ + // Display coordinates + vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myAnnotationActor->SetPosition(aSelectionPoint); + // + // To prepare the annotation text + std::ostringstream aStr; + aStr<<"Node ID: "<< anObjId; + std::string aString = aStr.str(); + myAnnotationMapper->SetInput(aString.c_str()); + + myAnnotationActor->SetVisibility(1); + return true; + } } break; } @@ -909,13 +923,13 @@ template std::string getVector(TData* theData, int theId) */ bool VISU_Actor -::Highlight(vtkInteractorStyle* theInteractorStyle, - SVTK_SelectionEvent* theSelectionEvent, - bool theIsHighlight) +::Highlight(vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight) { return Superclass::Highlight(theInteractorStyle, - theSelectionEvent, - theIsHighlight); + theSelectionEvent, + theIsHighlight); } //------------------------------------------------------------------------- @@ -928,7 +942,7 @@ VISU_Actor VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode != ActorSelection; - + TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); bool aCurrentHasIndex = aMapIndex.Extent() == 1; @@ -946,131 +960,131 @@ VISU_Actor { case ActorSelection: { - ResetTextActor(); - break; + ResetTextActor(); + break; } case CellSelection: { - if( !aCurrentHasIndex ) - { - myTextActor->SetVisibility(false); - break; - } - - int anObjId = aMapIndex(1); - vtkCellData* aCellData = aDataSet->GetCellData(); - if(vtkCell* aCell = GetElemCell(anObjId)){ - vtkPoints* aPts = aCell->GetPoints(); - if(int aNbPts = aCell->GetNumberOfPoints()){ - vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0}; - for(int i = 0; i < aNbPts; i++){ - vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); - aCoord[0] += aPntCoord[0]; - aCoord[1] += aPntCoord[1]; - aCoord[2] += aPntCoord[2]; - } - - aFlyTo = true; - aFlyToCoord[0] = aCoord[0] / aNbPts; - aFlyToCoord[1] = aCoord[1] / aNbPts; - aFlyToCoord[2] = aCoord[2] / aNbPts; - - vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0}; - aRenderer->SetWorldPoint(aWorldCoord); - aRenderer->WorldToDisplay(); - vtkFloatingPointType aSelectionPoint[3]; - aRenderer->GetDisplayPoint(aSelectionPoint); - myTextActor->SetPosition(aSelectionPoint); - myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); - myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); - myTextActor->SetWorldPoint(aWorldCoord); - - std::ostringstream aStr; - aStr << "Cell ID: " << anObjId; - - vtkCell* aCell = GetElemCell(anObjId); - int aVTKID = GetElemVTKID(anObjId); - if (aCell) { - int aNbOfPoints = aCell->GetNumberOfPoints(); - if ( aNbOfPoints > 0 ) { - aStr << getScalar(aCellData, aVTKID); - aStr << getVector(aCellData, aVTKID); - } - } - - std::string aString = aStr.str(); - myTextActor->SetText(aString.c_str()); - } - } - break; + if( !aCurrentHasIndex ) + { + myTextActor->SetVisibility(false); + break; + } + + int anObjId = aMapIndex(1); + vtkCellData* aCellData = aDataSet->GetCellData(); + if(vtkCell* aCell = GetElemCell(anObjId)){ + vtkPoints* aPts = aCell->GetPoints(); + if(int aNbPts = aCell->GetNumberOfPoints()){ + vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0}; + for(int i = 0; i < aNbPts; i++){ + vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); + aCoord[0] += aPntCoord[0]; + aCoord[1] += aPntCoord[1]; + aCoord[2] += aPntCoord[2]; + } + + aFlyTo = true; + aFlyToCoord[0] = aCoord[0] / aNbPts; + aFlyToCoord[1] = aCoord[1] / aNbPts; + aFlyToCoord[2] = aCoord[2] / aNbPts; + + vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myTextActor->SetPosition(aSelectionPoint); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetWorldPoint(aWorldCoord); + + std::ostringstream aStr; + aStr << "Cell ID: " << anObjId; + + vtkCell* aCell = GetElemCell(anObjId); + int aVTKID = GetElemVTKID(anObjId); + if (aCell) { + int aNbOfPoints = aCell->GetNumberOfPoints(); + if ( aNbOfPoints > 0 ) { + aStr << getScalar(aCellData, aVTKID); + aStr << getVector(aCellData, aVTKID); + } + } + + std::string aString = aStr.str(); + myTextActor->SetText(aString.c_str()); + } + } + break; } case NodeSelection: - { - if( !aCurrentHasIndex ) - { - myTextActor->SetVisibility(false); - break; - } - - int anObjId = aMapIndex(1); - vtkPointData* aPntData = aDataSet->GetPointData(); - if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){ - aFlyTo = true; - aFlyToCoord[0] = aCoord[0]; - aFlyToCoord[1] = aCoord[1]; - aFlyToCoord[2] = aCoord[2]; - - vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; - aRenderer->SetWorldPoint(aWorldCoord); - aRenderer->WorldToDisplay(); - vtkFloatingPointType aSelectionPoint[3]; - aRenderer->GetDisplayPoint(aSelectionPoint); - myTextActor->SetPosition(aSelectionPoint); - myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); - myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); - myTextActor->SetWorldPoint(aWorldCoord); - - std::ostringstream aStr; - aStr << "Point ID: " << anObjId; - - int aVTKID = GetNodeVTKID(anObjId); - if(aVTKID >= 0) { - aStr << getScalar(aPntData, aVTKID); - aStr << getVector(aPntData, aVTKID); - } - - const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper(); - //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId); - VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(anObjId); - - aStr << "\nCoordinates: " << "["; - aStr << aCoord[0]; - //if( aVec.size() > 0 ) - if (aVec[0] != -1) - aStr << " (" << aVec[0] << ")"; - aStr << "; "; - - aStr << aCoord[1]; - //if( aVec.size() > 1 ) - if (aVec[1] != -1) - aStr << " (" << aVec[1] << ")"; - aStr << "; "; - - aStr << aCoord[2]; - //if( aVec.size() > 2 ) - if (aVec[2] != -1) - aStr << " (" << aVec[2] << ")"; - aStr << "]"; - - std::string aString = aStr.str(); - myTextActor->SetText(aString.c_str()); - } - break; + { + if( !aCurrentHasIndex ) + { + myTextActor->SetVisibility(false); + break; + } + + int anObjId = aMapIndex(1); + vtkPointData* aPntData = aDataSet->GetPointData(); + if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){ + aFlyTo = true; + aFlyToCoord[0] = aCoord[0]; + aFlyToCoord[1] = aCoord[1]; + aFlyToCoord[2] = aCoord[2]; + + vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myTextActor->SetPosition(aSelectionPoint); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetWorldPoint(aWorldCoord); + + std::ostringstream aStr; + aStr << "Point ID: " << anObjId; + + int aVTKID = GetNodeVTKID(anObjId); + if(aVTKID >= 0) { + aStr << getScalar(aPntData, aVTKID); + aStr << getVector(aPntData, aVTKID); + } + + const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper(); + //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId); + VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(anObjId); + + aStr << "\nCoordinates: " << "["; + aStr << aCoord[0]; + //if( aVec.size() > 0 ) + if (aVec[0] != -1) + aStr << " (" << aVec[0] << ")"; + aStr << "; "; + + aStr << aCoord[1]; + //if( aVec.size() > 1 ) + if (aVec[1] != -1) + aStr << " (" << aVec[1] << ")"; + aStr << "; "; + + aStr << aCoord[2]; + //if( aVec.size() > 2 ) + if (aVec[2] != -1) + aStr << " (" << aVec[2] << ")"; + aStr << "]"; + + std::string aString = aStr.str(); + myTextActor->SetText(aString.c_str()); + } + break; } case EdgeOfCellSelection: - break; + break; default: - break; + break; } } @@ -1079,9 +1093,9 @@ VISU_Actor { vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor(); ChangeZoom(aZoomFactor, - GetRenderer(), - anInitialHasIndex, - aCurrentHasIndex); + GetRenderer(), + anInitialHasIndex, + aCurrentHasIndex); } // FlyTo @@ -1090,7 +1104,7 @@ VISU_Actor vtkRenderWindowInteractor* anInteractor = myInteractor; vtkFloatingPointType aDollyWas = anInteractor->GetDolly(); int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames(); - + double aPosition[3]; GetPosition( aPosition ); for( int i = 0; i < 3; i++ ) @@ -1117,8 +1131,8 @@ VISU_Actor GetBounds(aCoord); vtkFloatingPointType aWorldCoord[4] = { ( aCoord[0] + aCoord[1] ) / 2, - ( aCoord[2] + aCoord[3] ) / 2, - ( aCoord[4] + aCoord[5] ) / 2, 1.0}; + ( aCoord[2] + aCoord[3] ) / 2, + ( aCoord[4] + aCoord[5] ) / 2, 1.0}; vtkRenderer* aRenderer = GetRenderer(); aRenderer->SetWorldPoint(aWorldCoord); aRenderer->WorldToDisplay(); @@ -1145,17 +1159,17 @@ VISU_Actor } //------------------------------------------------------------------------- -void +void VISU_Actor -::ProcessEvents(vtkObject* vtkNotUsed(theObject), - unsigned long theEvent, - void* theClientData, - void* vtkNotUsed(theCallData)) +::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long theEvent, + void* theClientData, + void* vtkNotUsed(theCallData)) { if(vtkObject* anObject = reinterpret_cast(theClientData)) if(VISU_Actor* self = dynamic_cast(anObject)) { if(theEvent == VISU::UpdatePickingSettingsEvent) - self->UpdatePickingSettings(); + self->UpdatePickingSettings(); } } @@ -1184,7 +1198,7 @@ void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled ) vtkDataSet* aGrid = GetValLabelsInput(); if ( !aGrid ) return; - + bool isOnPnt = VISU::IsDataOnPoints( aGrid ); bool isOnCell = VISU::IsDataOnCells( aGrid ); if ( !isOnPnt && !isOnCell ) @@ -1215,7 +1229,7 @@ void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled ) return; } } - + myIsValLabeled = theIsValLabeled; if ( myIsValLabeled ) @@ -1234,7 +1248,7 @@ void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled ) } else myValLabels->SetVisibility( false ); - + Modified(); } @@ -1249,7 +1263,7 @@ bool VISU_Actor::GetValuesLabeled() const vtkTextProperty* VISU_Actor::GetsValLabelsProps() const { - return myValLabeledDataMapper->GetLabelTextProperty(); + return myValLabeledDataMapper->GetLabelTextProperty(); } //---------------------------------------------------------------------------- @@ -1266,8 +1280,7 @@ vtkDataSet* VISU_Actor::GetValLabelsInput() } - -VISU_Actor::EQuadratic2DRepresentation +VISU_Actor::EQuadratic2DRepresentation VISU_Actor::GetQuadratic2DRepresentation() const { if(Superclass::GetQuadraticArcMode()){ diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index 241e0cbd..8dce35e7 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -28,6 +28,9 @@ #include "VISU_ConvertorUtils.hxx" #include "VISU_MeshValue.hxx" +#include +#include + #include #include @@ -96,6 +99,22 @@ VISU_Extractor return myGaussMetric; } +//---------------------------------------------------------------------------- +vtkFloatingPointType CutValue (vtkFloatingPointType theValue, int theDecimals) +{ + vtkFloatingPointType v = theValue; + vtkFloatingPointType aDegree = 0.0; + if (abs((long long)v) > 1) + aDegree = (long long)log10(abs((long long)v)) + 1; + aDegree = theDecimals - aDegree; + //printf("$$$ 1 v = %.20g , aDegree = %lld \n", v, (long long)aDegree); + if (aDegree > 0) { + aDegree = pow(10, aDegree); + v = ((vtkFloatingPointType)((long long)(v * aDegree))) / aDegree; + //printf("$$$ 2 v = %.20g , aDegree = %lld \n", v, (long long)aDegree); + } + return v; +} //---------------------------------------------------------------------------- template @@ -104,6 +123,11 @@ Module2Scalars(vtkDataArray *theInputDataArray, TValueType* theOutputPtr, vtkIdType theNbOfTuples) { + // jfa try begin + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6); + // jfa try end + vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents(); std::vector anArray(aNbComp < 3? 3: aNbComp); for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){ @@ -112,7 +136,10 @@ Module2Scalars(vtkDataArray *theInputDataArray, vtkFloatingPointType aScalar = sqrt(aVector[0]*aVector[0] + aVector[1]*aVector[1] + aVector[2]*aVector[2]); - *theOutputPtr = TValueType(aScalar); + //*theOutputPtr = TValueType(aScalar); + // jfa try begin + *theOutputPtr = TValueType(CutValue(aScalar, aDecimals)); + // jfa try end theOutputPtr++; } } @@ -124,6 +151,11 @@ Module2ScalarsMOD(vtkDataArray *theInputDataArray, vtkIdType theNbOfTuples, VISU::TGaussMetric theGaussMetric) { + // jfa try begin + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6); + // jfa try end + vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents(); if (aNbComp != 3) // Min, Max, Avg return; @@ -135,6 +167,9 @@ Module2ScalarsMOD(vtkDataArray *theInputDataArray, case VISU::MAXIMUM_METRIC: *theOutputPtr = TValueType(anArray[1]); break; case VISU::AVERAGE_METRIC: *theOutputPtr = TValueType(anArray[2]); break; } + // jfa try begin + *theOutputPtr = TValueType(CutValue(*theOutputPtr, aDecimals)); + // jfa try end theOutputPtr++; } } @@ -149,9 +184,17 @@ Component2Scalars(vtkDataArray *theInputDataArray, vtkIdType theNbOfTuples, vtkIdType theComponentId) { + // jfa try begin + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6); + // jfa try end + vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents(); - for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){ + for (vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) { *theOutputPtr = *(theInputPtr + theComponentId); + // jfa try begin + *theOutputPtr = TValueType(CutValue(*theOutputPtr, aDecimals)); + // jfa try end theInputPtr += aNbComp; theOutputPtr++; } diff --git a/src/PIPELINE/VISU_LookupTable.cxx b/src/PIPELINE/VISU_LookupTable.cxx index 2400418b..938b8293 100644 --- a/src/PIPELINE/VISU_LookupTable.cxx +++ b/src/PIPELINE/VISU_LookupTable.cxx @@ -23,7 +23,7 @@ // File : VISU_LookupTable.cxx // Author : Vitaliy Smetannikov // Module : VISU -// + #include "VISU_LookupTable.hxx" #include @@ -40,9 +40,9 @@ vtkStandardNewMacro(VISU_LookupTable); //---------------------------------------------------------------------------- VISU_LookupTable ::VISU_LookupTable(int sze, int ext): - vtkLookupTable(sze, ext), - myScale(1.0), - myBicolor(false) + vtkLookupTable(sze, ext), + myScale(1.0), + myBicolor(false) {} //---------------------------------------------------------------------------- @@ -63,8 +63,8 @@ namespace void VISU_LookupTable ::MarkValueByColor( vtkFloatingPointType theValue, - unsigned char* theColor ) -{ + unsigned char* theColor ) +{ vtkIdType anIndex = this->GetIndex( theValue ); unsigned char *aTablePtr = this->GetPointer( anIndex ); CopyColor( aTablePtr, theColor ); @@ -91,11 +91,11 @@ VISU_LookupTable { unsigned char aRedPtr[3] = {255, 0, 0}; unsigned char aBluePtr[3] = {0, 0, 255}; - + vtkFloatingPointType aRange[2]; this->GetTableRange(aRange); vtkIdType aNbColors = this->GetNumberOfColors(); - + vtkFloatingPointType aDelta = (aRange[1]-aRange[0])/aNbColors; vtkFloatingPointType aValue = aRange[0]+0.5*aDelta; for(int i = 0; i < aNbColors; i++){ @@ -112,7 +112,7 @@ VISU_LookupTable //---------------------------------------------------------------------------- -void +void VISU_LookupTable ::SetMapScale(vtkFloatingPointType theScale) { @@ -133,10 +133,10 @@ void VISU_LookupTable::SetBicolor( bool theBicolor ) } -int +int VISU_LookupTable -::ComputeLogRange(vtkFloatingPointType inRange[2], - vtkFloatingPointType outRange[2]) +::ComputeLogRange(vtkFloatingPointType inRange[2], + vtkFloatingPointType outRange[2]) { if(inRange[0] >= inRange[1]) return -1; @@ -155,9 +155,9 @@ VISU_LookupTable return -1; } -unsigned char* +unsigned char* VISU_LookupTable -::MapValue(vtkFloatingPointType v) +::MapValue(vtkFloatingPointType v) { if(GetScale() == VTK_SCALE_LOG10) { vtkFloatingPointType aLowBound = log10(this->TableRange[0]); @@ -174,55 +174,47 @@ VISU_LookupTable } // Apply log to value, with appropriate constraints. -inline -vtkFloatingPointType -VISU_ApplyLogScale(vtkFloatingPointType v, - vtkFloatingPointType range[2], - vtkFloatingPointType logRange[2]) +inline +vtkFloatingPointType +VISU_ApplyLogScale(vtkFloatingPointType v, + vtkFloatingPointType range[2], + vtkFloatingPointType logRange[2]) { // is the range set for negative numbers? - if (range[0] < 0) - { - if (v < 0) - { + if (range[0] < 0) { + if (v < 0) { v = log10(-static_cast(v)); - } - else if (range[0] > range[1]) - { + } + else if (range[0] > range[1]) { v = logRange[0]; - } - else - { + } + else { v = logRange[1]; - } } - else - { - if (v > 0) - { + } + else { + if (v > 0) { v = log10(static_cast(v)); - } - else if (range[0] < range[1]) - { + } + else if (range[0] < range[1]) { v = logRange[0]; - } - else - { + } + else { v = logRange[1]; - } } + } return v; -} +} // Apply shift/scale to the scalar value v and do table lookup. -inline +inline unsigned char * -VISU_LinearLookup(vtkFloatingPointType v, - unsigned char *table, - vtkFloatingPointType maxIndex, - vtkFloatingPointType shift, - vtkFloatingPointType scale, - bool bicolor) +VISU_LinearLookup(vtkFloatingPointType v, + unsigned char *table, + vtkFloatingPointType maxIndex, + vtkFloatingPointType shift, + vtkFloatingPointType scale, + bool bicolor) { if( !bicolor ) { @@ -247,14 +239,14 @@ VISU_LinearLookup(vtkFloatingPointType v, // of 8-bit chunks template void -VISU_LookupTableMapData(vtkLookupTable *self, - T *input, - unsigned char *output, - int length, - int inIncr, - int outFormat, - vtkFloatingPointType theMapScale, - bool bicolor) +VISU_LookupTableMapData(vtkLookupTable *self, + T *input, + unsigned char *output, + int length, + int inIncr, + int outFormat, + vtkFloatingPointType theMapScale, + bool bicolor) { int i = length; vtkFloatingPointType *range = self->GetTableRange(); @@ -264,267 +256,267 @@ VISU_LookupTableMapData(vtkLookupTable *self, unsigned char *cptr; vtkFloatingPointType alpha; - if ( (alpha=self->GetAlpha()) >= 1.0 ) //no blending required - { + if ( (alpha=self->GetAlpha()) >= 1.0 ) //no blending required + { if (self->GetScale() == VTK_SCALE_LOG10) - { + { vtkFloatingPointType val; vtkFloatingPointType logRange[2]; VISU_LookupTable::ComputeLogRange(range, logRange); shift = -logRange[0]; if (logRange[1] <= logRange[0]) - { + { scale = VTK_LARGE_FLOAT; - } + } else - { + { scale = (maxIndex + 1)/(logRange[1] - logRange[0]); - } + } /* correct scale scale = maxIndex/(logRange[1] - logRange[0]); */ if (outFormat == VTK_RGBA) + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; - *output++ = *cptr++; input += inIncr; - } } + } else if (outFormat == VTK_RGB) + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; input += inIncr; - } } + } else if (outFormat == VTK_LUMINANCE_ALPHA) + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); *output++ = cptr[3]; input += inIncr; - } } + } else // outFormat == VTK_LUMINANCE + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); input += inIncr; - } } - }//if log scale + } + }//if log scale else //not log scale - { + { shift = -range[0]; if (range[1] <= range[0]) - { + { scale = VTK_LARGE_FLOAT; - } + } else - { + { scale = (maxIndex + 1)/(range[1] - range[0]); - } + } /* correct scale scale = maxIndex/(range[1] - range[0]); */ if (outFormat == VTK_RGBA) + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; - *output++ = *cptr++; input += inIncr; - } } + } else if (outFormat == VTK_RGB) + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; input += inIncr; - } } + } else if (outFormat == VTK_LUMINANCE_ALPHA) + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); *output++ = cptr[3]; input += inIncr; - } } + } else // outFormat == VTK_LUMINANCE + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); input += inIncr; - } } - }//if not log lookup - }//if blending not needed + } + }//if not log lookup + }//if blending not needed else //blend with the specified alpha - { + { if (self->GetScale() == VTK_SCALE_LOG10) - { + { vtkFloatingPointType val; vtkFloatingPointType logRange[2]; VISU_LookupTable::ComputeLogRange(range, logRange); shift = -logRange[0]; if (logRange[1] <= logRange[0]) - { + { scale = VTK_LARGE_FLOAT; - } + } else - { + { scale = (maxIndex + 1)/(logRange[1] - logRange[0]); - } + } /* correct scale scale = maxIndex/(logRange[1] - logRange[0]); */ if (outFormat == VTK_RGBA) + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; *output++ = static_cast((*cptr)*alpha); cptr++; input += inIncr; - } } + } else if (outFormat == VTK_RGB) + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; input += inIncr; - } } + } else if (outFormat == VTK_LUMINANCE_ALPHA) + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); *output++ = static_cast(alpha*cptr[3]); input += inIncr; - } } + } else // outFormat == VTK_LUMINANCE + { + while (--i >= 0) { - while (--i >= 0) - { val = VISU_ApplyLogScale(*input, range, logRange); - cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); input += inIncr; - } } - }//log scale with blending + } + }//log scale with blending else //no log scale with blending - { + { shift = -range[0]; if (range[1] <= range[0]) - { + { scale = VTK_LARGE_FLOAT; - } + } else - { + { scale = (maxIndex + 1)/(range[1] - range[0]); - } + } /* correct scale scale = maxIndex/(range[1] - range[0]); */ if (outFormat == VTK_RGBA) + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; *output++ = static_cast((*cptr)*alpha); cptr++; input += inIncr; - } } + } else if (outFormat == VTK_RGB) + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); *output++ = *cptr++; *output++ = *cptr++; *output++ = *cptr++; input += inIncr; - } } + } else if (outFormat == VTK_LUMINANCE_ALPHA) + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); *output++ = static_cast(cptr[3]*alpha); input += inIncr; - } } + } else // outFormat == VTK_LUMINANCE + { + while (--i >= 0) { - while (--i >= 0) - { - cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); - *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + + cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor); + *output++ = static_cast(cptr[0]*0.30 + cptr[1]*0.59 + cptr[2]*0.11 + 0.5); input += inIncr; - } } - }//no log scale - }//alpha blending + } + }//no log scale + }//alpha blending } // Although this is a relatively expensive calculation, @@ -532,14 +524,14 @@ VISU_LookupTableMapData(vtkLookupTable *self, // for subsequent renders. template void -VISU_LookupTableMapMag(vtkLookupTable *self, - T *input, - unsigned char *output, - int length, - int inIncr, - int outFormat, - vtkFloatingPointType theMapScale, - bool bicolor) +VISU_LookupTableMapMag(vtkLookupTable *self, + T *input, + unsigned char *output, + int length, + int inIncr, + int outFormat, + vtkFloatingPointType theMapScale, + bool bicolor) { double tmp, sum; double *mag; @@ -547,16 +539,16 @@ VISU_LookupTableMapMag(vtkLookupTable *self, mag = new double[length]; for (i = 0; i < length; ++i) - { + { sum = 0; for (j = 0; j < inIncr; ++j) - { - tmp = (double)(*input); + { + tmp = (double)(*input); sum += (tmp * tmp); ++input; - } - mag[i] = sqrt(sum); } + mag[i] = sqrt(sum); + } VISU_LookupTableMapData(self, mag, output, length, 1, outFormat, theMapScale, bicolor); @@ -564,24 +556,24 @@ VISU_LookupTableMapMag(vtkLookupTable *self, } -void VISU_LookupTable::MapScalarsThroughTable2(void *input, - unsigned char *output, - int inputDataType, - int numberOfValues, - int inputIncrement, - int outputFormat) +void VISU_LookupTable::MapScalarsThroughTable2(void *input, + unsigned char *output, + int inputDataType, + int numberOfValues, + int inputIncrement, + int outputFormat) { if (this->UseMagnitude && inputIncrement > 1) - { + { switch (inputDataType) - { + { case VTK_BIT: vtkErrorMacro("Cannot comput magnitude of bit array."); break; case VTK_CHAR: VISU_LookupTableMapMag(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); - return; + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + return; case VTK_UNSIGNED_CHAR: VISU_LookupTableMapMag(this,static_cast(input),output, numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); @@ -621,84 +613,83 @@ void VISU_LookupTable::MapScalarsThroughTable2(void *input, default: vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType"); return; - } } + } switch (inputDataType) - { + { case VTK_BIT: - { + { vtkIdType i, id; vtkBitArray *bitArray = vtkBitArray::New(); bitArray->SetVoidArray(input,numberOfValues,1); vtkUnsignedCharArray *newInput = vtkUnsignedCharArray::New(); newInput->SetNumberOfValues(numberOfValues); for (id=i=0; iSetValue(i, bitArray->GetValue(id)); - } + } VISU_LookupTableMapData(this, - static_cast(newInput->GetPointer(0)), - output,numberOfValues, - inputIncrement,outputFormat,myScale,myBicolor); + static_cast(newInput->GetPointer(0)), + output,numberOfValues, + inputIncrement,outputFormat,myScale,myBicolor); newInput->Delete(); bitArray->Delete(); - } - break; - + } + break; + case VTK_CHAR: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_UNSIGNED_CHAR: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_SHORT: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_UNSIGNED_SHORT: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_INT: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_UNSIGNED_INT: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_LONG: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_UNSIGNED_LONG: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_FLOAT: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + case VTK_DOUBLE: VISU_LookupTableMapData(this,static_cast(input),output, - numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); + numberOfValues,inputIncrement,outputFormat,myScale,myBicolor); break; - + default: vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType"); return; - } -} - + } +} diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index d44e6e7f..ee360335 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -246,54 +246,54 @@ VisuGUI if ( !aFileInfo.exists() ) { // file not exist errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). - arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); } else { try { - if ( !toUseBuildProgress ) { - // build progress is not used, use build flags from settings - bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); - bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); - bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); - bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); - bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); - - QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " ); - application()->putInfo( anInfo ); - - VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() ); - - if ( CORBA::is_nil( aResult.in() ) ) { - errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). - arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); - } - else { - aResult->SetBuildFields( toBuildFields, toBuildMinMax ); - aResult->SetBuildGroups( toBuildGroups ); - aResult->Build( toBuildAll, toBuildAtOnce ); - application()->putInfo( anInfo + tr("INF_DONE") ); - } - } // if ( !toUseBuildProgress ) - else { - // use build progress - wc.suspend(); - VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); - aBuildProgressDlg->setFileName( aFileInfo.filePath() ); - aBuildProgressDlg->setGenerator( GetVisuGen(this) ); - aBuildProgressDlg->exec(); - wc.resume(); - } + if ( !toUseBuildProgress ) { + // build progress is not used, use build flags from settings + bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true ); + bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true ); + bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true ); + bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false ); + bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false ); + + QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " ); + application()->putInfo( anInfo ); + + VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() ); + + if ( CORBA::is_nil( aResult.in() ) ) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + aResult->SetBuildFields( toBuildFields, toBuildMinMax ); + aResult->SetBuildGroups( toBuildGroups ); + aResult->Build( toBuildAll, toBuildAtOnce ); + application()->putInfo( anInfo + tr("INF_DONE") ); + } + } // if ( !toUseBuildProgress ) + else { + // use build progress + wc.suspend(); + VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) ); + aBuildProgressDlg->setFileName( aFileInfo.filePath() ); + aBuildProgressDlg->setGenerator( GetVisuGen(this) ); + aBuildProgressDlg->exec(); + wc.resume(); + } } // try catch(...) { - errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); } } // else // if ( !aFileInfo.exists() ) } // for (...) if ( errors.count() > 0 ) { SUIT_MessageBox::critical( GetDesktop(this), - tr("ERR_ERROR"), - tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); } else { UpdateObjBrowser(this); @@ -317,9 +317,9 @@ VisuGUI anInitialPath = QDir::currentPath(); QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this), - anInitialPath, - aFilter, - tr("TLT_IMPORT_TABLE")); + anInitialPath, + aFilter, + tr("TLT_IMPORT_TABLE")); if ( aFiles.count() == 0 ) return; // nothing selected @@ -329,33 +329,33 @@ VisuGUI if ( !aFileInfo.exists() ) { errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). - arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); + arg( tr( "ERR_FILE_NOT_EXISTS" ) ) ); } else { try { - QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); - application()->putInfo( anInfo ); - - CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData()); - - if (CORBA::is_nil(anObject.in())) { - errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). - arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); - } - else { - application()->putInfo( anInfo + tr("INF_DONE") ); - } + QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." ); + application()->putInfo( anInfo ); + + CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData()); + + if (CORBA::is_nil(anObject.in())) { + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ). + arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) ); + } + else { + application()->putInfo( anInfo + tr("INF_DONE") ); + } } catch(...) { - errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); + errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) ); } } } if ( errors.count() > 0 ) { SUIT_MessageBox::critical( GetDesktop(this), - tr("ERR_ERROR"), - tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + tr("ERR_ERROR"), + tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); } else { UpdateObjBrowser(this); @@ -408,8 +408,8 @@ VisuGUI if (!aTabAttr) return; aTitle = aTabAttr->GetTitle().c_str(); } else { - _PTR(AttributeTableOfInteger) aTabAttr (anAttr); - if (!aTabAttr) return; + _PTR(AttributeTableOfInteger) aTabAttr (anAttr); + if (!aTabAttr) return; aTitle = aTabAttr->GetTitle().c_str(); } aTitle.simplified(); @@ -441,25 +441,25 @@ VisuGUI QString aFile = aFileInfo.filePath(); if (!aFile.isEmpty()) { application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ..."); - aDir = Qtx::dir(aFile, true); + aDir = Qtx::dir(aFile, true); aResourceMgr->setValue("VISU", "OutputDir", aDir); - try { - GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), (const char*)aFile.toLatin1()); + try { + GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), (const char*)aFile.toLatin1()); application()->putInfo(aFile + " " + tr("INF_DONE")); - } catch(std::exception& exc) { - INFOS(exc.what()); - SUIT_MessageBox::warning(GetDesktop(this), + } catch(std::exception& exc) { + INFOS(exc.what()); + SUIT_MessageBox::warning(GetDesktop(this), tr("WRN_VISU"), - tr("ERR_ERROR_DURING_EXPORT") + " " + tr(exc.what()) ); + tr("ERR_ERROR_DURING_EXPORT") + " " + tr(exc.what()) ); - } catch(...) { - INFOS((const char*)tr("ERR_ERROR_DURING_EXPORT").toLatin1()); - SUIT_MessageBox::warning( GetDesktop(this), + } catch(...) { + INFOS((const char*)tr("ERR_ERROR_DURING_EXPORT").toLatin1()); + SUIT_MessageBox::warning( GetDesktop(this), tr("WRN_VISU"), - tr("ERR_ERROR_DURING_EXPORT") ); + tr("ERR_ERROR_DURING_EXPORT") ); - } + } } } } @@ -637,29 +637,29 @@ CreateCurves( SalomeApp_Module* theModule, if( aTblObj ) { _PTR(GenericAttribute) anAttr; if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) { - _PTR(ChildIterator) aChildIter = aStudy->NewChildIterator( aTblObj ); - SalomeApp_Study* salome_study = GetAppStudy( theModule ); - for( aChildIter->InitEx( false ); aChildIter->More(); aChildIter->Next() ){ - salome_study->deleteReferencesTo( aChildIter->Value() ); - _PTR(SObject) aSO = aChildIter->Value(); - if(aSO){ - Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aSO); - if (aRestoringMap["myComment"] == "CURVE") { - CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSO); - if(!CORBA::is_nil(aCORBAObject)){ - PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); - if(VISU::Curve_i* aCurve = dynamic_cast(aServant.in())){ - PlotRemoveCurve(theModule, aCurve); - } - } - } - } - - } + _PTR(ChildIterator) aChildIter = aStudy->NewChildIterator( aTblObj ); + SalomeApp_Study* salome_study = GetAppStudy( theModule ); + for( aChildIter->InitEx( false ); aChildIter->More(); aChildIter->Next() ){ + salome_study->deleteReferencesTo( aChildIter->Value() ); + _PTR(SObject) aSO = aChildIter->Value(); + if(aSO){ + Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aSO); + if (aRestoringMap["myComment"] == "CURVE") { + CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSO); + if(!CORBA::is_nil(aCORBAObject)){ + PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); + if(VISU::Curve_i* aCurve = dynamic_cast(aServant.in())){ + PlotRemoveCurve(theModule, aCurve); + } + } + } + } + + } aBuilder->RemoveObjectWithChildren( aTblObj ); // We should have only one child - //UpdateObjBrowser(theModule,true,aTblObj); + //UpdateObjBrowser(theModule,true,aTblObj); break; } } @@ -874,16 +874,16 @@ VisuGUI switch (aType) { case VISU::TPOINTMAP3D: if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this)){ - displayer()->Display(anIO->getEntry()); - aViewWindow->highlight(anIO, 1); - aViewWindow->getRenderer()->ResetCameraClippingRange(); - aViewWindow->Repaint(); - break; + displayer()->Display(anIO->getEntry()); + aViewWindow->highlight(anIO, 1); + aViewWindow->getRenderer()->ResetCameraClippingRange(); + aViewWindow->Repaint(); + break; } else { - if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) - aPlot2d->Repaint(); - displayer()->Display(anIO->getEntry()); + if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) + aPlot2d->Repaint(); + displayer()->Display(anIO->getEntry()); } case VISU::TCURVE: case VISU::TCONTAINER: @@ -893,12 +893,12 @@ VisuGUI default: { VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase); if(aPrs3d){ - if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this)){ - displayer()->Display(anIO->getEntry()); - aViewWindow->highlight(anIO, 1); - aViewWindow->getRenderer()->ResetCameraClippingRange(); - aViewWindow->Repaint(); - } + if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this)){ + displayer()->Display(anIO->getEntry()); + aViewWindow->highlight(anIO, 1); + aViewWindow->getRenderer()->ResetCameraClippingRange(); + aViewWindow->Repaint(); + } } } } @@ -915,7 +915,7 @@ VisuGUI LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); if (!aSelectionMgr) return; - + SALOME_ListIO aSel, aList; aSelectionMgr->selectedObjects(aSel); extractContainers(aSel, aList); @@ -970,16 +970,16 @@ void VisuGUI::activateAppropriateViewer( Handle(SALOME_InteractiveObject) theIO aChild = anIter->Value(); CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aChild); if(!CORBA::is_nil(aCORBAObject)){ - PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); - if( dynamic_cast(aServant.in())) - hasCurvesChildren = true; + PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); + if( dynamic_cast(aServant.in())) + hasCurvesChildren = true; } } if (hasCurvesChildren && ( aViewerType == SPlot2d_Viewer::Type() || aViewerType == SVTK_Viewer::Type() ) ) { return; } else { - // activate SVTK Viewer + // activate SVTK Viewer getApp()->getViewManager( SVTK_Viewer::Type(), true ); return; } @@ -1025,7 +1025,7 @@ VisuGUI for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) { if (anActor->GetVisibility() > 0) if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) { - RemoveScalarBarPosition(this, vw, anVISUActor->GetPrs3d()); + RemoveScalarBarPosition(this, vw, anVISUActor->GetPrs3d()); anVISUActor->VisibilityOff(); } } @@ -1042,7 +1042,7 @@ namespace //---------------------------------------------------------------------------- VISU::Prs3d_i* GetPrsToModify(const SalomeApp_Module* theModule, - Handle(SALOME_InteractiveObject)& theIO) + Handle(SALOME_InteractiveObject)& theIO) { VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); if(aSelectionInfo.empty()) @@ -1318,8 +1318,8 @@ VisuGUI QColor aColor (int(255*anOldColor.R), - int(255*anOldColor.G), - int(255*anOldColor.B)); + int(255*anOldColor.G), + int(255*anOldColor.B)); QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this)); if (aColorNew.isValid()) { aNewColor.R = aColorNew.red()/255.; @@ -1494,8 +1494,8 @@ VisuGUI aGauss->SetBarVisible( theVisibility ); RecreateActor(this, aGauss); update = true; - } - } + } + } } } } @@ -1549,34 +1549,34 @@ VisuGUI anIO = it.Value(); if (anIO->hasEntry()) { if (IsRemovable(anIO->getEntry(), this)) { - aNameList.append("\n - "); - // Get Name Of the Main Object if it's a referenced object - VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); - if(_PTR(SObject) aSObject = anObjectInfo.mySObject){ - _PTR(SObject) aRefSObject; - if (aSObject->ReferencedObject(aRefSObject)) { - QString aRefName = QString::fromStdString ( aRefSObject->GetName() ); - aNameList.append( aRefName ); - } - else - aNameList.append(anIO->getName()); - } - anEntries[i++] = anIO->getEntry(); + aNameList.append("\n - "); + // Get Name Of the Main Object if it's a referenced object + VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); + if(_PTR(SObject) aSObject = anObjectInfo.mySObject){ + _PTR(SObject) aRefSObject; + if (aSObject->ReferencedObject(aRefSObject)) { + QString aRefName = QString::fromStdString ( aRefSObject->GetName() ); + aNameList.append( aRefName ); + } + else + aNameList.append(anIO->getName()); + } + anEntries[i++] = anIO->getEntry(); } } } nbSelected = i; if (nbSelected < 1) { SUIT_MessageBox::warning(GetDesktop(this), - QObject::tr("WRN_VISU"), - QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); + QObject::tr("WRN_VISU"), + QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); return; } if ( SUIT_MessageBox::question( GetDesktop(this), - QObject::tr( "WRN_VISU" ), - QObject::tr( "VISU_REALLY_DELETE" ).arg( nbSelected ).arg( aNameList ), - SUIT_MessageBox::Yes | SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) + QObject::tr( "WRN_VISU" ), + QObject::tr( "VISU_REALLY_DELETE" ).arg( nbSelected ).arg( aNameList ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) return; // There is a transaction @@ -1589,32 +1589,32 @@ VisuGUI emit beforeObjectDelete(QString(aSObject->GetID().c_str())); _PTR(SObject) aRefSObject; if (aSObject->ReferencedObject(aRefSObject)) { - // It can be a reference on curve, published under a container. - // In this case the curve should be removed from the container. - // See bug 10441. - VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(this), aRefSObject->GetID()); - VISU::Base_i* aRefBase = aRefObjectInfo.myBase; - if(aRefBase && aRefBase->GetType() == VISU::TMESH){ - DeleteSObject(this, aCStudy, aRefSObject); - UpdateObjBrowser(this, true, aRefSObject); - }else if(aRefBase && aRefBase->GetType() == VISU::TCURVE){ - CORBA::Object_var anObject = ClientSObjectToObject(aRefSObject); - VISU::Curve_var aCurve = VISU::Curve::_narrow(anObject); - _PTR(SObject) aParentSO = aSObject->GetFather(); - VISU::TObjectInfo aParentObjectInfo = GetObjectByEntry(GetAppStudy(this), aParentSO->GetID()); - if(VISU::Base_i* aParentBase = aParentObjectInfo.myBase){ - if(VISU::Container_i* aContainer = dynamic_cast(aParentBase)){ - if(aContainer->GetNbCurves() > 0){ - aContainer->RemoveCurve(aCurve); - UpdateObjBrowser(this, true, aParentSO); - } - } - } - } + // It can be a reference on curve, published under a container. + // In this case the curve should be removed from the container. + // See bug 10441. + VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(this), aRefSObject->GetID()); + VISU::Base_i* aRefBase = aRefObjectInfo.myBase; + if(aRefBase && aRefBase->GetType() == VISU::TMESH){ + DeleteSObject(this, aCStudy, aRefSObject); + UpdateObjBrowser(this, true, aRefSObject); + }else if(aRefBase && aRefBase->GetType() == VISU::TCURVE){ + CORBA::Object_var anObject = ClientSObjectToObject(aRefSObject); + VISU::Curve_var aCurve = VISU::Curve::_narrow(anObject); + _PTR(SObject) aParentSO = aSObject->GetFather(); + VISU::TObjectInfo aParentObjectInfo = GetObjectByEntry(GetAppStudy(this), aParentSO->GetID()); + if(VISU::Base_i* aParentBase = aParentObjectInfo.myBase){ + if(VISU::Container_i* aContainer = dynamic_cast(aParentBase)){ + if(aContainer->GetNbCurves() > 0){ + aContainer->RemoveCurve(aCurve); + UpdateObjBrowser(this, true, aParentSO); + } + } + } + } } else{ - DeleteSObject(this, aCStudy, aSObject); - UpdateObjBrowser(this, true, aSObject); + DeleteSObject(this, aCStudy, aSObject); + UpdateObjBrowser(this, true, aSObject); } } } @@ -1637,65 +1637,65 @@ VisuGUI if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){ if(aBase->GetType() == VISU::TTABLE || aBase->GetType() == VISU::TPOINTMAP3D) { if(VISU::Table_i* aTable = dynamic_cast(aBase)){ - _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); - _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() ); - if(IsSObjectTable(aSObject)){ - VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); - if(aDlg->exec() == QDialog::Accepted){ - if(!IsStudyLocked(aStudy)){ - // if study is not locked - create new container, create curves and insert them - // into container, then plot container if current viewer is of VIEW_PLOT2D type - int horIndex; - QList verIndices, zIndices; - aDlg->getCurvesSource( horIndex, verIndices, zIndices ); - if( horIndex >= 0 && verIndices.count() > 0 ){ - CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer(); - if(VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObj).in())){ - for( int i = 0; i < verIndices.count(); i++ ){ - VISU::Curve_var aCurveObject = - GetVisuGen(this)->CreateCurveWithZ(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); - if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ - bool isAuto; - int marker, line, lineWidth; - QColor color; - if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker, - line, lineWidth, color) && !isAuto ) - { - SALOMEDS::Color c; - c.R = color.red() /255.; - c.G = color.green()/255.; - c.B = color.blue() /255.; - aCurve->SetColor( c ); - aCurve->SetMarker( ( VISU::Curve::MarkerType )marker ); - aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth ); - } - aContainer->AddCurve(aCurveObject); - } - } - UpdateObjBrowser(this); - PlotContainer( this, aContainer, VISU::eDisplay ); - } - } - } else { - // get name of SObject - QString aSObjectName; - _PTR(GenericAttribute) anAttr; - if(aSObject->FindAttribute( anAttr, "AttributeName" )){ - _PTR(AttributeName) aName = anAttr; - aSObjectName = QString( aName->Value().c_str() ); - } - // if study is locked just get curves info and plot them - // if current viewer is of VIEW_PLOT2D type - QList container; - aDlg->getCurves( container ); - if ( !container.isEmpty() ) { - GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true ); - GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName ); - } - } - } - delete aDlg; - } + _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); + _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() ); + if(IsSObjectTable(aSObject)){ + VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); + if(aDlg->exec() == QDialog::Accepted){ + if(!IsStudyLocked(aStudy)){ + // if study is not locked - create new container, create curves and insert them + // into container, then plot container if current viewer is of VIEW_PLOT2D type + int horIndex; + QList verIndices, zIndices; + aDlg->getCurvesSource( horIndex, verIndices, zIndices ); + if( horIndex >= 0 && verIndices.count() > 0 ){ + CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer(); + if(VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObj).in())){ + for( int i = 0; i < verIndices.count(); i++ ){ + VISU::Curve_var aCurveObject = + GetVisuGen(this)->CreateCurveWithZ(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); + if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ + bool isAuto; + int marker, line, lineWidth; + QColor color; + if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker, + line, lineWidth, color) && !isAuto ) + { + SALOMEDS::Color c; + c.R = color.red() /255.; + c.G = color.green()/255.; + c.B = color.blue() /255.; + aCurve->SetColor( c ); + aCurve->SetMarker( ( VISU::Curve::MarkerType )marker ); + aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth ); + } + aContainer->AddCurve(aCurveObject); + } + } + UpdateObjBrowser(this); + PlotContainer( this, aContainer, VISU::eDisplay ); + } + } + } else { + // get name of SObject + QString aSObjectName; + _PTR(GenericAttribute) anAttr; + if(aSObject->FindAttribute( anAttr, "AttributeName" )){ + _PTR(AttributeName) aName = anAttr; + aSObjectName = QString( aName->Value().c_str() ); + } + // if study is locked just get curves info and plot them + // if current viewer is of VIEW_PLOT2D type + QList container; + aDlg->getCurves( container ); + if ( !container.isEmpty() ) { + GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true ); + GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName ); + } + } + } + delete aDlg; + } } } }else if(!aSelectionItem.myIO.IsNull()){ @@ -1704,7 +1704,7 @@ VisuGUI if(IsSObjectTable(aSObject)){ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); if(aDlg->exec() == QDialog::Accepted){ - _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); + _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); if(!IsStudyLocked(aStudy)){ // if study is not locked - create new table and container objects, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type @@ -1714,41 +1714,41 @@ VisuGUI if ( horIndex >= 0 && verIndices.count() > 0 ) { VISU::Table_var aTableObject = GetVisuGen(this)->CreateTable(aSObject->GetID().c_str()); if(!CORBA::is_nil(aTableObject)){ - VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer(); + VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer(); VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObject).in()); - for ( int i = 0; i < verIndices.count(); i++ ) { - VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZ - ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1 ); - if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ - bool isAuto; - int marker, line, lineWidth; - QColor color; - if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker, - line, lineWidth, color) && !isAuto ) - { - SALOMEDS::Color c; - c.R = color.red()/255.; - c.G = color.green()/255.; - c.B = color.blue()/255.; - aCurve->SetColor( c ); - aCurve->SetMarker( ( VISU::Curve::MarkerType )marker ); - aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth ); - } - aContainerObject->AddCurve(aCurveObject); - } - } - UpdateObjBrowser(this); - PlotContainer( this, aContainer, VISU::eDisplay ); - } - } + for ( int i = 0; i < verIndices.count(); i++ ) { + VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZ + ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1 ); + if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ + bool isAuto; + int marker, line, lineWidth; + QColor color; + if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker, + line, lineWidth, color) && !isAuto ) + { + SALOMEDS::Color c; + c.R = color.red()/255.; + c.G = color.green()/255.; + c.B = color.blue()/255.; + aCurve->SetColor( c ); + aCurve->SetMarker( ( VISU::Curve::MarkerType )marker ); + aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth ); + } + aContainerObject->AddCurve(aCurveObject); + } + } + UpdateObjBrowser(this); + PlotContainer( this, aContainer, VISU::eDisplay ); + } + } } else { - // get name of SObject - QString aSObjectName; - _PTR(GenericAttribute) anAttr; - if(aSObject->FindAttribute(anAttr, "AttributeName")){ - _PTR(AttributeName) aName = anAttr; - aSObjectName = QString( aName->Value().c_str() ); - } + // get name of SObject + QString aSObjectName; + _PTR(GenericAttribute) anAttr; + if(aSObject->FindAttribute(anAttr, "AttributeName")){ + _PTR(AttributeName) aName = anAttr; + aSObjectName = QString( aName->Value().c_str() ); + } // if study is locked just get curves info and plot them QList container; aDlg->getCurves( container ); @@ -1992,7 +1992,7 @@ VisuGUI ViewManagerList aViewManagerList; getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList); SUIT_ViewManager* aViewManager; - foreach( aViewManager, aViewManagerList ) { + foreach( aViewManager, aViewManagerList ) { if (Plot2d_ViewManager* aManager = dynamic_cast(aViewManager)) { if (SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) aViewer->renameAll( anIO, Name.toLatin1().constData() ); @@ -2008,8 +2008,8 @@ VisuGUI if (!isAny) { SUIT_MessageBox::warning(GetDesktop(this), - QObject::tr("WRN_VISU"), - QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); + QObject::tr("WRN_VISU"), + QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); } } @@ -2183,12 +2183,12 @@ VisuGUI if( myPanels.find( SelectionPanelId ) != myPanels.end() ) { if( VisuGUI_SelectionPanel* aSelectionPanel = - dynamic_cast( myPanels[ SelectionPanelId ] ) ) + dynamic_cast( myPanels[ SelectionPanelId ] ) ) { - if( aSelectionPanel->isVisible() ) - aSelectionPanel->hide(); - else - aSelectionPanel->show(); + if( aSelectionPanel->isVisible() ) + aSelectionPanel->hide(); + else + aSelectionPanel->show(); } } } @@ -2217,8 +2217,8 @@ VisuGUI else if( myPanels.find( SelectionPanelId ) != myPanels.end() ) { if( VisuGUI_SelectionPanel* aSelectionPanel = - dynamic_cast( myPanels[ SelectionPanelId ] ) ) - aSelectionPanel->setSelectionMode( anId - VISU_ACTOR_SELECTION ); + dynamic_cast( myPanels[ SelectionPanelId ] ) ) + aSelectionPanel->setSelectionMode( anId - VISU_ACTOR_SELECTION ); } } // At least one action must be checked @@ -2778,19 +2778,19 @@ VisuGUI createAction( VISU_FILTERSCALARS, tr("MEN_FILTER_SCALARS"), QIcon(), tr("MEN_FILTER_SCALARS"), "", 0, aParent, false, this, SLOT(OnFilterScalars())); - + createAction( VISU_VALUES_LABELING, tr("MEN_VALUES_LABELING"), QIcon(), tr("MEN_VALUES_LABELING"), "", 0, aParent, true, - this, SLOT(OnValuesLabeling())); + this, SLOT(OnValuesLabeling())); createAction( VISU_VALUES_LABELING_PARAMS, tr("VISU_VALUES_LABELING_PARAMS"), QIcon(), tr("VISU_VALUES_LABELING_PARAMS"), "", 0, aParent, false, - this, SLOT(OnValuesLabelingParams())); + this, SLOT(OnValuesLabelingParams())); - createAction(VISU_ARCQUAD_MODE, tr("MEN_VISU_ARCQUAD_MODE"), QIcon(), + createAction(VISU_ARCQUAD_MODE, tr("MEN_VISU_ARCQUAD_MODE"), QIcon(), tr("MEN_VISU_ARCQUAD_MODE"), "",0, aParent, true, this, SLOT(OnArcQuadMode())); - + createAction(VISU_LINEQUAD_MODE, tr("MEN_VISU_LINEQUAD_MODE"),QIcon(), tr("MEN_VISU_LINEQUAD_MODE"), "",0, aParent, true, this, SLOT(OnLineQuadMode())); @@ -2833,7 +2833,7 @@ VisuGUI parentId = createMenu( tr( "MEN_2D_QUADRATIC_MODE" ), aMenuId, 10 ); // 2D quadratic mode createMenu( VISU_LINEQUAD_MODE, parentId, 10 ); // lines createMenu( VISU_ARCQUAD_MODE, parentId, 10 ); // arcs - + } void @@ -2930,7 +2930,7 @@ VisuGUI // delete mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 ); - + // labeling mgr->insert( separator(), -1, -1, -1 ); mgr->insert( action( VISU_VALUES_LABELING ), -1, -1, -1 ); @@ -3016,10 +3016,10 @@ VisuGUI QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " - "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCOLOREDPRS3DHOLDER'"); + "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCOLOREDPRS3DHOLDER'"); QString aSimplePrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " - "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " - "'VISU::TSCALARMAPONDEFORMEDSHAPE'"); + "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " + "'VISU::TSCALARMAPONDEFORMEDSHAPE'"); // VISU root commands QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'"; @@ -3080,7 +3080,7 @@ VisuGUI aRule = "selcount=1 and $type in { " + aSimplePrsAll + "}"; mgr->setRule( action( VISU_FILTERSCALARS ), aRule ); - + // labeling aRule = "hasActor=1 and selcount=1 and $type in { 'VISU::TGAUSSPOINTS'" + aPrsAll + " }"; @@ -3182,27 +3182,27 @@ VisuGUI mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule ); mgr->setRule( action( VISU_EDIT_SCALARMAP ), - "selcount=1 and type='VISU::TSCALARMAP'" ); + "selcount=1 and type='VISU::TSCALARMAP'" ); mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ), - "selcount=1 and type='VISU::TDEFORMEDSHAPE'" ); + "selcount=1 and type='VISU::TDEFORMEDSHAPE'" ); mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPEANDSCALARMAP ), - "selcount=1 and $type in {'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}" ); + "selcount=1 and $type in {'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}" ); mgr->setRule( action( VISU_EDIT_CUTPLANES ), - "selcount=1 and type='VISU::TCUTPLANES'" ); + "selcount=1 and type='VISU::TCUTPLANES'" ); mgr->setRule( action( VISU_EDIT_CUTLINES ), - "selcount=1 and type='VISU::TCUTLINES'" ); + "selcount=1 and type='VISU::TCUTLINES'" ); mgr->setRule( action( VISU_EDIT_CUTSEGMENT ), - "selcount=1 and type='VISU::TCUTSEGMENT'" ); + "selcount=1 and type='VISU::TCUTSEGMENT'" ); mgr->setRule( action( VISU_EDIT_ISOSURFACES ), - "selcount=1 and type='VISU::TISOSURFACES'" ); + "selcount=1 and type='VISU::TISOSURFACES'" ); mgr->setRule( action( VISU_EDIT_VECTORS ), - "selcount=1 and type='VISU::TVECTORS'" ); + "selcount=1 and type='VISU::TVECTORS'" ); mgr->setRule( action( VISU_EDIT_STREAMLINES ), - "selcount=1 and type='VISU::TSTREAMLINES'" ); + "selcount=1 and type='VISU::TSTREAMLINES'" ); mgr->setRule( action( VISU_EDIT_PLOT3D ), - "selcount=1 and type='VISU::TPLOT3D'" ); + "selcount=1 and type='VISU::TPLOT3D'" ); mgr->setRule( action( VISU_EDIT_POINTMAP3D ), - "selcount=1 and type='VISU::TPOINTMAP3D'" ); + "selcount=1 and type='VISU::TPOINTMAP3D'" ); aRule = "selcount=1 and $type in {'VISU::TCUTLINES' 'VISU::TCUTSEGMENT'} and nbNamedChildren=0"; mgr->setRule( action( VISU_CREATE_TABLE ), aRule ); @@ -3226,7 +3226,7 @@ VisuGUI mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1" ); mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1" ); mgr->setRule( action( VISU_EDIT_PLOT3D ), - "selcount=1 and type='VISU::TPLOT3D'" ); + "selcount=1 and type='VISU::TPLOT3D'" ); //aRule = "client='ObjectBrowser' and type='MEDFIELD'"; //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); @@ -3292,29 +3292,29 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin if (!anIO.IsNull() && anIO->hasEntry()) { _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); if ( !aSObject ) - continue; + continue; if ( !isOBClient ) { - QString aName = QString( aSObject->GetName().c_str() ); - while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of popup - aName.remove( (aName.length() - 1), 1 ); - theTitle = aName; + QString aName = QString( aSObject->GetName().c_str() ); + while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of popup + aName.remove( (aName.length() - 1), 1 ); + theTitle = aName; } CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject); if (CORBA::is_nil(aCORBAObject)) { - VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject ); - if (aType == VISU::TTIMESTAMP) { - _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject); - _PTR(SObject) aPrs; - for (; anIter->More(); anIter->Next()) { - aPrs = anIter->Value(); - if (!aPrs) - continue; - std::vector aSubList = GetPrs3dList(this, aPrs); - nbPrs += aSubList.size(); - } - } + VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject ); + if (aType == VISU::TTIMESTAMP) { + _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject); + _PTR(SObject) aPrs; + for (; anIter->More(); anIter->Next()) { + aPrs = anIter->Value(); + if (!aPrs) + continue; + std::vector aSubList = GetPrs3dList(this, aPrs); + nbPrs += aSubList.size(); + } + } } } } @@ -3333,18 +3333,18 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin if (!anIO.IsNull() && anIO->hasEntry()) { _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); if ( !aSObject ) - continue; + continue; VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject ); if (aType == VISU::TCURVE) { - isCurves = true; + isCurves = true; } else { - VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); - if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){ - if (aPrsObject->GetType() == VISU::TCUTPLANES) { - if (VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject)) - isOneCutPlane = aCutPrs->GetNbPlanes() == 1; - } - } + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); + if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){ + if (aPrsObject->GetType() == VISU::TCUTPLANES) { + if (VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject)) + isOneCutPlane = aCutPrs->GetNbPlanes() == 1; + } + } } } } @@ -3418,7 +3418,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin if (aSFather1) { std::string aValue = aSFather1->GetName(); if (strcmp(aValue.c_str(), "MEDFIELD") == 0) { - theMenu->addAction( action( VISU_IMPORT_MED_FIELD ) ); // "Import Field" + theMenu->addAction( action( VISU_IMPORT_MED_FIELD ) ); // "Import Field" } } } @@ -3501,7 +3501,7 @@ VisuGUI action(VISU_RENAME )->setEnabled(false); // Rename: Key_F2 bool aResult = SalomeApp_Module::deactivateModule( theStudy ); - + emit moduleDeactivated(); return aResult; @@ -3518,7 +3518,7 @@ VisuGUI void VisuGUI::studyActivated() { GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this)))); - + } /* @@ -3625,7 +3625,7 @@ void VisuGUI::createPreferences() setPreferenceProperty( numcol, "max", 256 ); addPreference( tr( "VISU_IS_UNITS" ), colorsLabelsGr, - LightApp_Preferences::Bool, "VISU", "scalar_bar_display_units" ); + LightApp_Preferences::Bool, "VISU", "scalar_bar_display_units" ); int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" ); @@ -3637,7 +3637,7 @@ void VisuGUI::createPreferences() setPreferenceProperty( lPrec, "min", 1 ); setPreferenceProperty( lPrec, "max", 100 ); - + int frame = addPreference( "", sbarTab, LightApp_Preferences::Frame, "", "" ); //setPreferenceProperty( frame, "orientation", "vertical" ); setPreferenceProperty( frame, "columns", "2" ); @@ -3667,7 +3667,7 @@ void VisuGUI::createPreferences() //setPreferenceProperty( psSzFrame, "columns", "2" ); int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), - frame, LightApp_Preferences::GroupBox ); + frame, LightApp_Preferences::GroupBox ); setPreferenceProperty( posVSizeGr, "columns", 2 ); int xv = addPreference( tr( "VISU_X" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" ); @@ -3681,10 +3681,10 @@ void VisuGUI::createPreferences() int twv = addPreference( tr( "VISU_TITLE_SIZE" ), posVSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_size" ); - + int lwv = addPreference( tr( "VISU_LABEL_SIZE" ), posVSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_size" ); - + int bwv = addPreference( tr( "VISU_BAR_WIDTH" ), posVSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_width" ); int bhv = addPreference( tr( "VISU_BAR_HEIGHT" ), posVSizeGr, @@ -3717,7 +3717,7 @@ void VisuGUI::createPreferences() // group: "Origin & Size Horizontal" int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), - frame, LightApp_Preferences::GroupBox ); + frame, LightApp_Preferences::GroupBox ); setPreferenceProperty( posHSizeGr, "columns", 2 ); int xh = addPreference( tr( "VISU_X" ), posHSizeGr, @@ -3732,10 +3732,10 @@ void VisuGUI::createPreferences() int twh = addPreference( tr( "VISU_TITLE_SIZE" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_size" ); - + int lwh = addPreference( tr( "VISU_LABEL_SIZE" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_size" ); - + int bwh = addPreference( tr( "VISU_BAR_WIDTH" ), posHSizeGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_width" ); int bhh = addPreference( tr( "VISU_BAR_HEIGHT" ), posHSizeGr, @@ -3785,22 +3785,22 @@ void VisuGUI::createPreferences() { int cacheGroup = addPreference( tr( "VISU_3DCACHE_PREFERENCES" ), animationTab ); setPreferenceProperty( cacheGroup, "columns", 2 ); - + int memory_mode = addPreference( tr( "VISU_MEMORY_MODE" ), cacheGroup, - LightApp_Preferences::Selector, "VISU", "cache_memory_mode" ); - + LightApp_Preferences::Selector, "VISU", "cache_memory_mode" ); + modes.clear(); modes.append( tr( "VISU_MINIMAL" ) ); modes.append( tr( "VISU_LIMITED" ) ); setPreferenceProperty( memory_mode, "strings", modes ); - + indices.clear(); indices.append( 0 ); indices.append( 1 ); setPreferenceProperty( memory_mode, "indexes", indices ); - + int memory_limit = addPreference( tr( "VISU_MEMORY_LIMIT" ), cacheGroup, - LightApp_Preferences::IntSpin, "VISU", "cache_memory_limit" ); + LightApp_Preferences::IntSpin, "VISU", "cache_memory_limit" ); setPreferenceProperty( memory_limit, "min", 1 ); setPreferenceProperty( memory_limit, "max", 5000 ); setPreferenceProperty( memory_limit, "step", 10 ); @@ -3810,12 +3810,16 @@ void VisuGUI::createPreferences() { int animationGroup = addPreference( tr( "VISU_ANIMATION_PREFERENCES" ), animationTab ); setPreferenceProperty( animationGroup, "columns", 3 ); - - int speed = addPreference( tr( "Speed" ), animationGroup, LightApp_Preferences::IntSpin, "VISU", "speed" ); - addPreference( tr( "Cycled animation" ), animationGroup, LightApp_Preferences::Bool, "VISU", "cycled_animation" ); - addPreference( tr( "Use proportional timing" ), animationGroup, LightApp_Preferences::Bool, "VISU", "use_proportional_timing" ); - addPreference( tr( "Clean memory at each frame" ), animationGroup, LightApp_Preferences::Bool, "VISU", "clean_memory_at_each_frame" ); - + + int speed = addPreference( tr( "Speed" ), animationGroup, + LightApp_Preferences::IntSpin, "VISU", "speed" ); + addPreference( tr( "Cycled animation" ), animationGroup, + LightApp_Preferences::Bool, "VISU", "cycled_animation" ); + addPreference( tr( "Use proportional timing" ), animationGroup, + LightApp_Preferences::Bool, "VISU", "use_proportional_timing" ); + addPreference( tr( "Clean memory at each frame" ), animationGroup, + LightApp_Preferences::Bool, "VISU", "clean_memory_at_each_frame" ); + setPreferenceProperty( speed, "min", 1 ); setPreferenceProperty( speed, "max", 99 ); } @@ -3824,8 +3828,9 @@ void VisuGUI::createPreferences() { int sweepGroup = addPreference( tr( "VISU_SWEEPING_PREF" ), animationTab ); setPreferenceProperty( sweepGroup, "columns", 2 ); - - int modeSw = addPreference( tr( "VISU_SWEEPING_MODES" ), sweepGroup, LightApp_Preferences::Selector, "VISU", "sweeping_modes" ); + + int modeSw = addPreference( tr( "VISU_SWEEPING_MODES" ), sweepGroup, + LightApp_Preferences::Selector, "VISU", "sweeping_modes" ); QStringList sweep_modes; sweep_modes.append( tr( "VISU_LINEAR_SWEEP" ) ); sweep_modes.append( tr( "VISU_COS_SWEEP" ) ); @@ -3836,13 +3841,13 @@ void VisuGUI::createPreferences() indices.append( 2 ); setPreferenceProperty( modeSw, "strings", sweep_modes ); setPreferenceProperty( modeSw, "indexes", indices ); - + int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGroup, - LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" ); + LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" ); /* int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGroup, - LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );*/ + LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );*/ int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGroup, - LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" ); + LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" ); int rangeSw = addPreference( tr( "VISU_IS2PI" ), sweepGroup, LightApp_Preferences::Selector, "VISU", "sweeping_is2PI" ); QStringList ranges; ranges.append( tr( "PERIOD_PI" ) ); @@ -3852,7 +3857,7 @@ void VisuGUI::createPreferences() indices.append( 1 ); setPreferenceProperty( rangeSw, "strings", ranges ); setPreferenceProperty( rangeSw, "indexes", indices ); - + setPreferenceProperty( timestep, "min", 0.1 ); setPreferenceProperty( timestep, "step", 0.1 ); setPreferenceProperty( timestep, "max", 1000 ); @@ -3971,7 +3976,7 @@ void VisuGUI::createPreferences() addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_def_shrink" ); int point_precision = addPreference( tr( "VISU_FLOATING_POINT_PRECISION" ), representGr, - LightApp_Preferences::IntSpin, "VISU", "floating_point_precision" ); + LightApp_Preferences::IntSpin, "VISU", "floating_point_precision" ); setPreferenceProperty( point_precision, "min", 1 ); setPreferenceProperty( point_precision, "max", 16 ); setPreferenceProperty( point_precision, "step", 1 ); @@ -4026,7 +4031,7 @@ void VisuGUI::createPreferences() setPreferenceProperty( featureEdgesGr, "columns", 2 ); int featureEdgesAnglePref = addPreference( tr( "VISU_FEATURE_EDGES_ANGLE" ), featureEdgesGr, - LightApp_Preferences::DblSpin, "VISU", "feature_edges_angle" ); + LightApp_Preferences::DblSpin, "VISU", "feature_edges_angle" ); setPreferenceProperty( featureEdgesAnglePref, "step", 10.0 ); setPreferenceProperty( featureEdgesAnglePref, "min", 0.0 ); setPreferenceProperty( featureEdgesAnglePref, "max", 90.0 ); @@ -4036,9 +4041,9 @@ void VisuGUI::createPreferences() addPreference( tr( "VISU_SHOW_MANIFOLD_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_manifold_edges" ); addPreference( tr( "VISU_SHOW_NON_MANIFOLD_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_non_manifold_edges" ); //addPreference( tr( "VISU_FEATURE_EDGES_COLORING" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "feature_edges_coloring" ); - + // TAB: "Values labels" - + int valLblTab = addPreference( tr( "VALUES_LABELING" ) ); // "Font" group @@ -4049,7 +4054,7 @@ void VisuGUI::createPreferences() addVtkFontPref( tr( "LABELS" ), valLblFontGr, "values_labeling_font", true ); // color - addPreference( tr( "COLOR" ), valLblFontGr, + addPreference( tr( "COLOR" ), valLblFontGr, LightApp_Preferences::Color, "VISU", "values_labeling_color" ); } @@ -4105,8 +4110,8 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) aResourceMgr->setValue("VISU", "scalar_bar_horizontal_y", sbY1); aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH); } - } - + } + if ( !aWarning.isEmpty() ){ aWarning += "The default values are applied instead."; SUIT_MessageBox::warning(GetDesktop(this), @@ -4118,7 +4123,7 @@ void VisuGUI::preferencesChanged( const QString& a, const QString& b) SUIT_ViewManager* VisuGUI ::getViewManager(const QString& theType, - const bool theIsCreate) + const bool theIsCreate) { return getApp()->getViewManager(theType,theIsCreate); } @@ -4162,13 +4167,13 @@ void VisuGUI::OnPlot3dFromCutPlane() if (!anIO.IsNull() && anIO->hasEntry()) { aSObject = aCStudy->FindObjectID(anIO->getEntry()); if ( !aSObject ) - continue; + continue; VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){ if (aPrsObject->GetType() == VISU::TCUTPLANES) { - aCutPrs = dynamic_cast(aPrsObject); - if (aCutPrs) - break; + aCutPrs = dynamic_cast(aPrsObject); + if (aCutPrs) + break; } } } @@ -4183,7 +4188,7 @@ void VisuGUI::OnPlot3dFromCutPlane() Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aTimeStampSObj); VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aRestoringMap ); if (aType != TTIMESTAMP ) - return; + return; QString aMeshName = aRestoringMap["myMeshName"]; QString anEntity = aRestoringMap["myEntityId"]; @@ -4193,51 +4198,51 @@ void VisuGUI::OnPlot3dFromCutPlane() int aPos; SUIT_ViewWindow* aViewWindow = 0; // if (anIsVVTK) { -// aViewWindow = GetViewWindow(this); -// aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(aViewWindow)); +// aViewWindow = GetViewWindow(this); +// aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(aViewWindow)); // } else { - aViewWindow = GetViewWindow(this); - aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(GetViewWindow(this))); - // } + aViewWindow = GetViewWindow(this); + aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(GetViewWindow(this))); + // } GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos); VISU::Plot3D_i* aPrs3d = CreatePrs3dFromFactory(this, - aTimeStampSObj, - (const char*)aMeshName.toLatin1(), - (Entity)anEntity.toInt(), - (const char*)aFieldName.toLatin1(), - aTimeStampId.toInt(), - ColoredPrs3d_i::EPublishUnderTimeStamp); + aTimeStampSObj, + (const char*)aMeshName.toLatin1(), + (Entity)anEntity.toInt(), + (const char*)aFieldName.toLatin1(), + aTimeStampId.toInt(), + ColoredPrs3d_i::EPublishUnderTimeStamp); if (aPrs3d) { - SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); - int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); - if (!aValue) { - VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(this); - aDlg->initFromPrsObject(aPrs3d, true); - int aOrient = aCutPrs->GetOrientationType(); // Plot3d has the same orientation type - double aRotX = aCutPrs->GetRotateX(); - double aRotY = aCutPrs->GetRotateY(); - double aPlanePos = aCutPrs->GetPlanePosition(0); - aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos); - - if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) { - DeletePrs3d(this, aPrs3d); - delete aDlg; - return; - } - delete aDlg; - UpdateObjBrowser(this, true, aTimeStampSObj); - } - SVTK_ViewWindow* aSVtkWindow = dynamic_cast(aViewWindow); - if ( aSVtkWindow ) { - PublishInView(this, aPrs3d, aSVtkWindow, /*highlight = */true); - aSVtkWindow->onFitAll(); - - AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos); - } - if (aPrs3d) - emit presentationCreated(aPrs3d); + SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); + int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); + if (!aValue) { + VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(this); + aDlg->initFromPrsObject(aPrs3d, true); + int aOrient = aCutPrs->GetOrientationType(); // Plot3d has the same orientation type + double aRotX = aCutPrs->GetRotateX(); + double aRotY = aCutPrs->GetRotateY(); + double aPlanePos = aCutPrs->GetPlanePosition(0); + aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos); + + if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) { + DeletePrs3d(this, aPrs3d); + delete aDlg; + return; + } + delete aDlg; + UpdateObjBrowser(this, true, aTimeStampSObj); + } + SVTK_ViewWindow* aSVtkWindow = dynamic_cast(aViewWindow); + if ( aSVtkWindow ) { + PublishInView(this, aPrs3d, aSVtkWindow, /*highlight = */true); + aSVtkWindow->onFitAll(); + + AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos); + } + if (aPrs3d) + emit presentationCreated(aPrs3d); } } application()->putInfo(QObject::tr("INF_DONE")); @@ -4379,10 +4384,10 @@ void VisuGUI::OnExportMED() QFileInfo aFileInfo = SUIT_FileDlg::getFileName(GetDesktop(this), - aPath, - aFilter, - tr("MEN_EXPORT_MED"), // "Export To Med File" - false); + aPath, + aFilter, + tr("MEN_EXPORT_MED"), // "Export To Med File" + false); QString aFile = aFileInfo.filePath(); if ( aFile.length() > 0 ) { @@ -4397,9 +4402,9 @@ void VisuGUI::OnFilterScalars() } /*! - \brief SLOT called when "Labeling" popup menu item of presentation is clicked - activates/deactivates labeling of results of the screen. This functionality works - to numbering in SMESH module but is intended for showing results on the screen + \brief SLOT called when "Labeling" popup menu item of presentation is clicked + activates/deactivates labeling of results of the screen. This functionality works + to numbering in SMESH module but is intended for showing results on the screen instead of elements numbers \sa OnValuesLabelingParams() */ @@ -4413,23 +4418,23 @@ void VisuGUI::OnValuesLabeling() TSelectionItem aSelectionItem = GetSelectedObjects(this).front(); VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); - if(!aPrs3d) + if (!aPrs3d) return; SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); - if(!aViewWindow) + if (!aViewWindow) return; VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d); - if(!anActor) + if (!anActor) return; - if( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor) ) + if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor) ) { aScalarMapActor->SetValuesLabeled( !aScalarMapActor->GetValuesLabeled() ); aViewWindow->Repaint(); } - else if( VISU_GaussPtsAct* aGaussPtsAct = dynamic_cast(anActor) ) + else if ( VISU_GaussPtsAct* aGaussPtsAct = dynamic_cast(anActor) ) { aGaussPtsAct->SetValuesLabeled( !aGaussPtsAct->GetValuesLabeled() ); aViewWindow->Repaint(); @@ -4437,7 +4442,7 @@ void VisuGUI::OnValuesLabeling() } /*! - \brief SLOT called when "Labeling parameters" popup menu item of presentation + \brief SLOT called when "Labeling parameters" popup menu item of presentation is clicked launch dialog box for changing parameters of labeling \sa OnValuesLabeling() */ @@ -4445,7 +4450,7 @@ void VisuGUI::OnValuesLabelingParams() { Handle(SALOME_InteractiveObject) anIO; if ( VISU::Prs3d_i* aPrs3d = GetPrsToModify( this, anIO ) ) - EditPrs3d(this, anIO, aPrs3d); + EditPrs3d(this, anIO, aPrs3d); } /*! \brief Adds preferences for dfont of VTK viewer @@ -4454,14 +4459,14 @@ void VisuGUI::OnValuesLabelingParams() \param param parameter \return identifier of preferences */ -int VisuGUI::addVtkFontPref( - const QString& label, - const int pId, - const QString& param, +int VisuGUI::addVtkFontPref( + const QString& label, + const int pId, + const QString& param, const bool useSize ) { int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param ); - + setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom ); QStringList fam; @@ -4481,7 +4486,7 @@ int VisuGUI::addVtkFontPref( } /*! - \brief SLOT called when "2D Quadratic -> Arcs" popup menu item + \brief SLOT called when "2D Quadratic -> Arcs" popup menu item \ of presentation is cliked */ void VisuGUI::OnArcQuadMode(){ @@ -4489,10 +4494,9 @@ void VisuGUI::OnArcQuadMode(){ } /*! - \brief SLOT called when "2D Quadratic -> Lines" popup menu item + \brief SLOT called when "2D Quadratic -> Lines" popup menu item \ of presentation is cliked */ void VisuGUI::OnLineQuadMode(){ ChangeQuadratic2DRepresentation(this,VISU::LINES); } - diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 6492ca1f..89ddfa56 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -23,7 +23,7 @@ // File : VisuGUI_GaussPointsDlg.cxx // Author : Oleg UVAROV // Module : VISU -// + #include "VisuGUI_GaussPointsDlg.h" #include "VISUConfig.hh" @@ -104,7 +104,7 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): QButtonGroup* BarTypeGroup = new QButtonGroup( ActiveBarGroup ); QGroupBox* aGB = new QGroupBox( ActiveBarGroup ); QVBoxLayout* aVBLay = new QVBoxLayout( aGB ); - + BarTypeGroup->setExclusive( true ); //aGB->setFrameStyle( QFrame::NoFrame ); aVBLay->setMargin( 0 ); @@ -142,10 +142,16 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): RangeGroup->addButton( RBFieldRange ); RangeGroup->addButton( RBImposedRange ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); + + QDoubleValidator* dv = new QDoubleValidator(this); + dv->setDecimals(aPrecision); + MinEdit = new QLineEdit( aGB ); MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MinEdit->setMinimumWidth( 70 ); - MinEdit->setValidator( new QDoubleValidator(this) ); + MinEdit->setValidator( dv ); MinEdit->setText( "0.0" ); QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB); MinLabel->setBuddy(MinEdit); @@ -153,7 +159,7 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): MaxEdit = new QLineEdit( aGB ); MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MaxEdit->setMinimumWidth( 70 ); - MaxEdit->setValidator( new QDoubleValidator(this) ); + MaxEdit->setValidator( dv ); MaxEdit->setText( "0.0" ); QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB); MaxLabel->setBuddy(MaxEdit); @@ -313,10 +319,10 @@ VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent): aMainLayout->addWidget( aSaveBox ); QHBoxLayout* aHBoxLay = new QHBoxLayout( aSaveBox ); - + myTextBtn = new QPushButton("Text properties...", aSaveBox); aHBoxLay->addWidget( myTextBtn ); - + myBarBtn = new QPushButton("Bar properties...", aSaveBox); aHBoxLay->addWidget( myBarBtn ); @@ -380,8 +386,11 @@ void VisuGUI_GaussScalarBarPane::onGlobalScalarBar() MinEdit->setEnabled( false ); MaxEdit->setEnabled( false ); - MinEdit->setText( QString::number( myPrsCopy->GetMin() ) ); - MaxEdit->setText( QString::number( myPrsCopy->GetMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(myPrsCopy->GetMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(myPrsCopy->GetMax(), 'g', aPrecision)); } @@ -401,8 +410,11 @@ void VisuGUI_GaussScalarBarPane::onLocalScalarBar() MinEdit->setEnabled( RBImposedRange->isChecked() ); MaxEdit->setEnabled( RBImposedRange->isChecked() ); - MinEdit->setText( QString::number( myPrsCopy->GetMin() ) ); - MaxEdit->setText( QString::number( myPrsCopy->GetMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(myPrsCopy->GetMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(myPrsCopy->GetMax(), 'g', aPrecision)); } @@ -419,8 +431,11 @@ void VisuGUI_GaussScalarBarPane::fieldRangeClicked() MinEdit->setEnabled( false ); MaxEdit->setEnabled( false ); - MinEdit->setText( QString::number( myPrsCopy->GetMin() ) ); - MaxEdit->setText( QString::number( myPrsCopy->GetMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(myPrsCopy->GetMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(myPrsCopy->GetMax(), 'g', aPrecision)); } @@ -446,8 +461,11 @@ void VisuGUI_GaussScalarBarPane::changeScalarMode( int theMode ) { myPrsCopy->SetScalarMode( theMode ); if ( UseFieldRange() ) { - MinEdit->setText( QString::number( myPrsCopy->GetSourceMin() ) ); - MaxEdit->setText( QString::number( myPrsCopy->GetSourceMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(myPrsCopy->GetSourceMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(myPrsCopy->GetSourceMax(), 'g', aPrecision)); } } @@ -455,7 +473,7 @@ void VisuGUI_GaussScalarBarPane::changeScalarMode( int theMode ) * Initialise dialog box from presentation object */ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, - bool theInit ) + bool theInit ) { myPrsCopy = thePrs; @@ -474,16 +492,19 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, MaxEdit->setEnabled( false ); } - MinEdit->setText( QString::number( thePrs->GetMin() ) ); - MaxEdit->setText( QString::number( thePrs->GetMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(thePrs->GetMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(thePrs->GetMax(), 'g', aPrecision)); setPosAndSize( thePrs->GetPosX(), - thePrs->GetPosY(), - thePrs->GetWidth(), - thePrs->GetHeight(), - thePrs->GetBarOrientation()); + thePrs->GetPosY(), + thePrs->GetWidth(), + thePrs->GetHeight(), + thePrs->GetBarOrientation()); - if(RBvert->isChecked()) { + if (RBvert->isChecked()) { myVerTS = thePrs->GetTitleSize(); myVerLS = thePrs->GetLabelSize(); myVerBW = thePrs->GetBarWidth(); @@ -538,7 +559,7 @@ void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs, QString anUnit = QString(aUnitNames[i].c_str()).simplified(); if(anUnit.isNull() || anUnit == "") anUnit = "-"; - + aComponent = aComponent + ", " + anUnit; myModeCombo->addItem(aComponent); @@ -633,8 +654,8 @@ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetShadowTitle(isTitleShadow); thePrs->SetTitFontType(aTitleFontFamily); thePrs->SetTitleColor(aTitColor.red()/255., - aTitColor.green()/255., - aTitColor.blue()/255.); + aTitColor.green()/255., + aTitColor.blue()/255.); // "Label" QColor aLblColor (255, 255, 255); @@ -651,8 +672,8 @@ int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) { thePrs->SetShadowLabel(isLabelShadow); thePrs->SetLblFontType(aLabelFontFamily); thePrs->SetLabelColor(aLblColor.red()/255., - aLblColor.green()/255., - aLblColor.blue()/255.); + aLblColor.green()/255., + aLblColor.blue()/255.); } return 1; @@ -813,7 +834,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule): PrsGroup->addButton( myResultsButton ); PrsGroup->addButton( myGeometryButton ); PrsGroup->addButton( myDefShapeButton ); - + myTabBox = new QTabWidget (this); @@ -842,13 +863,13 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule): aDefShapeLayout->setAlignment(Qt::AlignTop); aDefShapeLayout->setSpacing(6); aDefShapeLayout->setMargin(11); - + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); QLabel* aScaleLabel = new QLabel( tr( "SCALE_FACTOR" ), myDefShapeBox ); myScaleSpinBox = new QtxDoubleSpinBox( 0.0, 10.0, 0.1, aPrecision*(-1), 32, myDefShapeBox ); - + aDefShapeLayout->addWidget( aScaleLabel, 0, 0 ); aDefShapeLayout->addWidget( myScaleSpinBox, 0, 1 ); @@ -908,7 +929,7 @@ VisuGUI_GaussPointsDlg::~VisuGUI_GaussPointsDlg() {} void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, - bool theInit ) + bool theInit ) { if( theInit ) myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); @@ -1002,18 +1023,18 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) myPrsCopy->SetMagnification( mySizeBox->getMagnification() ); myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() ); - VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); - + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); + //Set created Gauss points presentation selected, //Issue 0019874(EDF 746 VISU: Picking alphanumeric Gauss) if(thePrs){ SALOME_ListIO aListIO; - // LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule); + //LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule); Handle(SALOME_InteractiveObject) anIO = thePrs->GetIO(); if(anIO && anIO->hasEntry()) { aListIO.Append(anIO); VISU::UpdateObjBrowser(myModule,true); - //IPAL20836 aSelectionMgr->setSelectedObjects(aListIO); + //IPAL20836 aSelectionMgr->setSelectedObjects(aListIO); } else myInputPane->SetRestoreInitialSelection(true); @@ -1045,7 +1066,7 @@ void VisuGUI_GaussPointsDlg::accept() aWarning.append( "presentation might be too important to ensure an acceptable frame rate.\n\n" ); aWarning.append( "Can you please confirm that you want to continue anyway?" ); if( SUIT_MessageBox::warning( this, tr( "Warning" ), aWarning, tr( "&OK" ), tr( "&Cancel" ) ) == 1 ) - return; + return; } /* diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index 58bbb712..d0cb296d 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -23,7 +23,7 @@ // File : VisuGUI_Prs3dDlg.cxx // Author : Laurent CORNABE & Hubert ROLLAND // Module : VISU -// + #include "VisuGUI_Prs3dDlg.h" #include "VisuGUI.h" @@ -97,7 +97,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) QGroupBox* aTitleGrp = new QGroupBox ( tr("LBL_TITLE"), this); QVBoxLayout* aVBLay = new QVBoxLayout( aTitleGrp ); - // edit line + // edit line myTitleEdt = new QLineEdit (aTitleGrp); aVBLay->addWidget( myTitleEdt); @@ -123,7 +123,7 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) aHBLay = new QHBoxLayout( aHBox ); aHBLay->setSpacing(5); - + myLabelFont = new SVTK_FontWidget (aHBox); aHBLay->addWidget( myLabelFont ); @@ -197,7 +197,8 @@ void VisuGUI_TextPrefDlg::onHelp() else { SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"), QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName), + arg(app->resourceMgr()->stringValue("ExternalBrowser", + "application")).arg(aHelpFileName), QObject::tr("BUT_OK")); } } @@ -280,7 +281,7 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) aMainLay->setMargin( 5 ); // dimensions - + QGroupBox* aDimGrp = new QGroupBox( this ); QGridLayout* aDimGrpLay = new QGridLayout( aDimGrp ); aDimGrpLay->setSpacing( 5 ); @@ -293,7 +294,7 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) myTitleSizeSpin->setValue( 0 ); myTitleSizeSpin->setSpecialValueText( tr( "AUTO" ) ); QLabel* aTitleSizeLbl = new QLabel( tr( "LBL_TITLE_W" ), aDimGrp ); - + myLabelSizeSpin = new QSpinBox( aDimGrp ); myLabelSizeSpin->setRange( 0, 100 ); myLabelSizeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); @@ -301,7 +302,7 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) myLabelSizeSpin->setValue( 0 ); myLabelSizeSpin->setSpecialValueText( tr( "AUTO" ) ); QLabel* aLabelSizeLbl = new QLabel( tr( "LBL_LABEL_W" ), aDimGrp ); - + myBarWidthSpin = new QSpinBox( aDimGrp ); myBarWidthSpin->setRange( 0, 100 ); myBarWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); @@ -309,7 +310,7 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) myBarWidthSpin->setValue( 0 ); myBarWidthSpin->setSpecialValueText( tr( "AUTO" ) ); QLabel* aBarWidthLbl = new QLabel( tr( "LBL_BAR_W" ), aDimGrp ); - + myBarHeightSpin = new QSpinBox( aDimGrp ); myBarHeightSpin->setRange( 0, 100 ); myBarHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); @@ -323,11 +324,11 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) QLabel* aPrecLbl = new QLabel( tr( "PRECISION" ), aDimGrp ); myPrecisionSpin = new QSpinBox( aDimGrp ); myPrecisionSpin->setRange( 1, 100 ); - + myUnitsChk = new QCheckBox( tr( "LBL_SHOW_UNITS" ), aDimGrp ); - + // layout - + aDimGrpLay->addWidget( aTitleSizeLbl, 0, 0 ); aDimGrpLay->addWidget( myTitleSizeSpin, 0, 1 ); aDimGrpLay->addWidget( aLabelSizeLbl, 0, 2 ); @@ -339,7 +340,7 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) aDimGrpLay->addWidget( aPrecLbl, 2, 0 ); aDimGrpLay->addWidget( myPrecisionSpin, 2, 1 ); aDimGrpLay->addWidget( myUnitsChk, 2, 2, 1, 2 ); - + aMainLay->addWidget( aDimGrp ); // Common buttons =========================================================== @@ -382,7 +383,7 @@ VisuGUI_BarPrefDlg::VisuGUI_BarPrefDlg( QWidget* parent ) //---------------------------------------------------------------------------- void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth, - int barRatioWidth, int barRatioHeight ) + int barRatioWidth, int barRatioHeight ) { myTitleSizeSpin->setValue( myTitleSize = titleRatioSize ); myLabelSizeSpin->setValue( myLabelSize = labelRatioWidth ); @@ -393,7 +394,7 @@ void VisuGUI_BarPrefDlg::setRatios( int titleRatioSize, int labelRatioWidth, //---------------------------------------------------------------------------- void VisuGUI_BarPrefDlg::getRatios( int& titleRatioSize, int& labelRatioWidth, - int& barRatioWidth, int& barRatioHeight ) + int& barRatioWidth, int& barRatioHeight ) { titleRatioSize = myTitleSizeSpin->value(); labelRatioWidth = myLabelSizeSpin->value(); @@ -438,10 +439,10 @@ void VisuGUI_BarPrefDlg::onHelp() } else { SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ), - tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). - arg( app->resourceMgr()->stringValue( "ExternalBrowser", - "application" ) ). - arg( aHelpFileName ) ); + tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). + arg( app->resourceMgr()->stringValue( "ExternalBrowser", + "application" ) ). + arg( aHelpFileName ) ); } } @@ -484,18 +485,18 @@ void VisuGUI_BarPrefDlg::accept() { QString dVal; int aBWH = myOrientation == 1 ? myBarWidthSpin->value() : myBarHeightSpin->value(); - if( ( myLabelSizeSpin->value()+ aBWH ) > 100 ) + if( ( myLabelSizeSpin->value()+ aBWH ) > 100 ) { SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE" ) ); return; - } - + } + if ( myTitleSizeSpin->value() > 100 ) { SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "MSG_BIG_SCALE_TLT" ) ); return; } - + myTitleSize = myTitleSizeSpin->value(); myLabelSize = myLabelSizeSpin->value(); myBarWidth = myBarWidthSpin->value(); @@ -531,7 +532,7 @@ void VisuGUI_BarPrefDlg::keyPressEvent( QKeyEvent* e ) Constructor */ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplayGaussMetric, bool thePreview ) - : QWidget( parent ), + : QWidget( parent ), myPreviewActor( 0 ), myScalarMap( 0 ), myScalarMapPL( 0 ), @@ -549,7 +550,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay myVerLS = aResourceMgr->integerValue("VISU", propertyName + "label_size", 0); myVerBW = aResourceMgr->integerValue("VISU", propertyName + "bar_width", 0); myVerBH = aResourceMgr->integerValue("VISU", propertyName + "bar_height",0); - + propertyName = QString("scalar_bar_horizontal_"); myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); @@ -596,10 +597,14 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay RangeGroup->addButton( RBIrange, 1 ); RBFrange->setChecked( true ); + int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 ); + QDoubleValidator* dv = new QDoubleValidator(this); + dv->setDecimals(aPrecision); + MinEdit = new QLineEdit( aGB ); MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); //MinEdit->setMinimumWidth( 70 ); - MinEdit->setValidator( new QDoubleValidator(this) ); + MinEdit->setValidator( dv ); MinEdit->setText( "0.0" ); QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB); MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); @@ -608,7 +613,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay MaxEdit = new QLineEdit( aGB ); MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); //MaxEdit->setMinimumWidth( 70 ); - MaxEdit->setValidator( new QDoubleValidator(this) ); + MaxEdit->setValidator( dv ); MaxEdit->setText( "0.0" ); QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB); MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); @@ -648,7 +653,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay LabelSpin->setMinimum( 2 ); LabelSpin->setMaximum( 65 ); LabelSpin->setSingleStep( 1 ); - + LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); //LabelSpin->setMinimumWidth( 70 ); LabelSpin->setValue( 5 ); @@ -735,7 +740,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay QHBoxLayout* aVBLay = new QHBoxLayout( aSaveBox ); aVBLay->addWidget( myTextBtn = new QPushButton("Text properties...", aSaveBox) ); aVBLay->addWidget( myBarBtn = new QPushButton("Bar properties...", aSaveBox) ); - + aMainLayout->addWidget( myTextDlg = new VisuGUI_TextPrefDlg(this) ); myTextDlg->setTitleVisible(!thePreview); myBarDlg = new VisuGUI_BarPrefDlg(this); @@ -744,11 +749,11 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay aMainLayout->addWidget( CheckGroup ); //QHBoxLayout* CheckGroupLayout = new QHBoxLayout( CheckGroup ); QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup ); - + myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup); myPreviewCheck->setChecked(false); CheckGroupLayout->addWidget(myPreviewCheck, 0, 0); - + myHideBar = new QCheckBox(tr("HIDE_SCALAR_BAR"), CheckGroup); myHideBar->setChecked(false); CheckGroupLayout->addWidget(myHideBar, 0, 1); @@ -775,7 +780,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay int lp = aResourceMgr->integerValue( "VISU", propertyName + "scalar_bar_label_precision", 3 ); myBarDlg->setLabelsPrecision( lp ); - + myBarDlg->setUnitsVisible(aResourceMgr->booleanValue("VISU", propertyName + "display_units", true)); // signals and slots connections =========================================== @@ -790,9 +795,9 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool theIsDisplay connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) ); connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); - + connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV - + connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); @@ -861,10 +866,10 @@ void VisuGUI_ScalarBarPane::storeToResources() { } else aResourceMgr->setValue("VISU", "scalar_range_type", 0); - + aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic()); aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV - + //// if (myIsStoreTextProp) { @@ -879,11 +884,11 @@ void VisuGUI_ScalarBarPane::storeToResources() { isTitleBold, isTitleItalic, isTitleShadow); QFont aTitleFont; - + aTitleFont.setBold(isTitleBold); aTitleFont.setItalic(isTitleItalic); aTitleFont.setOverline(isTitleShadow); - + QString titleFontFamily; switch (aTitleFontFamily) { case VTK_ARIAL: @@ -897,11 +902,11 @@ void VisuGUI_ScalarBarPane::storeToResources() { break; } aTitleFont.setFamily(titleFontFamily); - + aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont); - + aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor); - + // "Label" QColor aLabelColor (255, 255, 255); int aLabelFontFamily = VTK_ARIAL; @@ -914,7 +919,7 @@ void VisuGUI_ScalarBarPane::storeToResources() { QFont aLabelFont; - + aLabelFont.setBold(isLabelBold); aLabelFont.setItalic(isLabelItalic); aLabelFont.setOverline(isLabelShadow); @@ -933,7 +938,7 @@ void VisuGUI_ScalarBarPane::storeToResources() { } aLabelFont.setFamily(labelFontFamily); - + aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont); aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor); @@ -985,7 +990,7 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) QString anUnit = QString(aUnitNames[i].c_str()).simplified(); if(anUnit.isNull() || anUnit == "") anUnit = "-"; - + aComponent = aComponent + ", " + anUnit; myModeCombo->addItem(aComponent); @@ -998,7 +1003,7 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myModeLbl->setEnabled(isScalarMode); myModeCombo->setEnabled(isScalarMode); - // Gauss Metric option should be visible only if at least one + // Gauss Metric option should be visible only if at least one // of mesh values on geometry is based on multiple gauss points bool isEnableGaussMetric = false; if( myIsDisplayGaussMetric ) { @@ -1007,7 +1012,7 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) if ( anIter != aValField.end() ) { VISU::PValForTime aValForTime = anIter->second; if( aValForTime && aValForTime->GetMaxNbGauss() > 1 ) - isEnableGaussMetric = true; + isEnableGaussMetric = true; } } @@ -1027,10 +1032,10 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) myTitle = aTitle.in(); setPosAndSize( myScalarMap->GetPosX(), - myScalarMap->GetPosY(), - myScalarMap->GetWidth(), - myScalarMap->GetHeight(), - myScalarMap->GetBarOrientation()); + myScalarMap->GetPosY(), + myScalarMap->GetWidth(), + myScalarMap->GetHeight(), + myScalarMap->GetBarOrientation()); if(RBvert->isChecked()) { myVerTS = myScalarMap->GetTitleSize(); @@ -1109,7 +1114,7 @@ void VisuGUI_ScalarBarPane::createScalarBar() myScalarMapPL = VISU_ScalarMapPL::New(); if(myScalarMap->GetSpecificPL()) myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true); - + if ( myBusy ) return; myBusy = true; @@ -1126,7 +1131,7 @@ void VisuGUI_ScalarBarPane::createScalarBar() myPreviewActor->GetScalarBar()->VisibilityOn(); myPreviewActor->PickableOff(); //myPreviewActor->SetBarVisibility(!myHideBar->isChecked()); - + myScalarMapPL->SetScalarMode(myModeCombo->currentIndex()); if(isLogarithmic()) myScalarMapPL->SetScaling(VISU::LOGARITHMIC); @@ -1145,13 +1150,13 @@ void VisuGUI_ScalarBarPane::createScalarBar() myScalarMapPL->SetScalarRange( aRange ); } - myScalarMapPL->SetNbColors(sbCol); + myScalarMapPL->SetNbColors(sbCol); myScalarMapPL->Update(); - + aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable()); aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() ); aScalarBarActor->SetDistributionVisibility( isShowDistribution() ); - + if (!myTextDlg->getTitleText().isEmpty()) { VISU::PValForTime aValForTime; const VISU::PField& aField = myScalarMap->GetScalarField(); @@ -1164,12 +1169,12 @@ void VisuGUI_ScalarBarPane::createScalarBar() std::strstream aStream; const VISU::TTime& aTime = aValForTime->myTime; aStream<< myTextDlg->getTitleText().toLatin1().data() <<" "; - if(myBarDlg->isUnitsVisible()) - aStream<isUnitsVisible()) + aStream<SetTitle(aScalarBarTitle.c_str()); @@ -1194,16 +1199,16 @@ void VisuGUI_ScalarBarPane::createScalarBar() bool isTitleItalic; bool isTitleShadow; myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily, - isTitleBold,isTitleItalic,isTitleShadow); + isTitleBold,isTitleItalic,isTitleShadow); vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty(); aTitleProp->SetFontFamily(aTitleFontFamily); aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255., - vtkFloatingPointType(aTitleColor.green())/255., - vtkFloatingPointType(aTitleColor.blue())/255.); + vtkFloatingPointType(aTitleColor.green())/255., + vtkFloatingPointType(aTitleColor.blue())/255.); (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff(); (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff(); (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff(); - + // label text property QColor aLabelColor; int aLabelFontFamily; @@ -1211,17 +1216,17 @@ void VisuGUI_ScalarBarPane::createScalarBar() bool isLabelItalic; bool isLabelShadow; myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily, - isLabelBold, isLabelItalic, isLabelShadow); + isLabelBold, isLabelItalic, isLabelShadow); vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty(); aLabelProp->SetFontFamily(aLabelFontFamily); aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255., - vtkFloatingPointType(aLabelColor.green())/255., - vtkFloatingPointType(aLabelColor.blue())/255.); + vtkFloatingPointType(aLabelColor.green())/255., + vtkFloatingPointType(aLabelColor.blue())/255.); (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff(); (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); - int VerTS, VerTH, VerLS, VerBW, VerBH; + int VerTS, VerLS, VerBW, VerBH; myBarDlg->getRatios(VerTS, VerLS, VerBW, VerBH); aScalarBarActor->SetRatios(VerTS, VerLS, VerBW, VerBH); @@ -1242,7 +1247,7 @@ void VisuGUI_ScalarBarPane::createScalarBar() void VisuGUI_ScalarBarPane::deleteScalarBar() { if ( myBusy ) return; - + if (myPreviewActor == 0) return; vtkRenderer* aRend = myPreviewActor->GetRenderer(); vtkRenderWindow* aWnd = aRend->GetRenderWindow(); @@ -1319,8 +1324,8 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetShadowTitle(isTitleShadow); myScalarMap->SetTitFontType(aTitleFontFamily); myScalarMap->SetTitleColor(aTitColor.red()/255., - aTitColor.green()/255., - aTitColor.blue()/255.); + aTitColor.green()/255., + aTitColor.blue()/255.); // "Label" QColor aLblColor (255, 255, 255); @@ -1337,8 +1342,8 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { myScalarMap->SetShadowLabel(isLabelShadow); myScalarMap->SetLblFontType(aLabelFontFamily); myScalarMap->SetLabelColor(aLblColor.red()/255., - aLblColor.green()/255., - aLblColor.blue()/255.); + aLblColor.green()/255., + aLblColor.blue()/255.); myIsStoreTextProp = false; } @@ -1440,8 +1445,11 @@ void VisuGUI_ScalarBarPane::changeScalarMode( int theMode ) myScalarMap->SetScalarMode(theMode); if ( RBFrange->isChecked() ) { - MinEdit->setText( QString::number( myScalarMap->GetSourceMin() ) ); - MaxEdit->setText( QString::number( myScalarMap->GetSourceMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision)); } updatePreview(); @@ -1457,8 +1465,11 @@ void VisuGUI_ScalarBarPane::changeGaussMetric( int theGaussMetric ) myScalarMap->SetGaussMetric((VISU::GaussMetric)theGaussMetric); if ( RBFrange->isChecked() ) { - MinEdit->setText( QString::number( myScalarMap->GetSourceMin() ) ); - MaxEdit->setText( QString::number( myScalarMap->GetSourceMax() ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(myScalarMap->GetSourceMin(), 'g', aPrecision)); + MaxEdit->setText(QString::number(myScalarMap->GetSourceMax(), 'g', aPrecision)); } updatePreview(); @@ -1471,8 +1482,12 @@ void VisuGUI_ScalarBarPane::changeGaussMetric( int theGaussMetric ) */ void VisuGUI_ScalarBarPane::setRange( double imin, double imax, bool sbRange ) { - MinEdit->setText( QString::number( imin ) ); - MaxEdit->setText( QString::number( imax ) ); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aPrecision = aResourceMgr->integerValue("VISU", "floating_point_precision", 0); + + MinEdit->setText(QString::number(imin, 'g', aPrecision)); + MaxEdit->setText(QString::number(imax, 'g', aPrecision)); + if( sbRange ) RBIrange->setChecked( true ); else @@ -1626,8 +1641,8 @@ bool VisuGUI_ScalarBarPane::check() if ( RBIrange->isChecked() ) { if (minVal >= maxVal) { SUIT_MessageBox::warning( this,tr("WRN_VISU"), - tr("MSG_MINMAX_VALUES"), - tr("BUT_OK")); + tr("MSG_MINMAX_VALUES"), + tr("BUT_OK")); return false; } } @@ -1636,23 +1651,23 @@ bool VisuGUI_ScalarBarPane::check() if ( CBLog->isChecked() ) { if ( minVal <= 0.0 || maxVal <= 0.0 ) { if ( RBIrange->isChecked() ) { - SUIT_MessageBox::warning( this, + SUIT_MessageBox::warning( this, tr("WRN_VISU"), tr("WRN_LOGARITHMIC_RANGE"), tr("BUT_OK")); } else { - if ( minVal == 0 || maxVal == 0 ) - SUIT_MessageBox::warning( this, - tr("WRN_VISU"), - tr("WRN_LOGARITHMIC_RANGE"), - tr("BUT_OK")); - else - SUIT_MessageBox::warning( this, - tr("WRN_VISU"), - tr("WRN_LOGARITHMIC_FIELD_RANGE"), - tr("BUT_OK")); - RBIrange->setChecked(true); - changeRange(1); + if ( minVal == 0 || maxVal == 0 ) + SUIT_MessageBox::warning( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_RANGE"), + tr("BUT_OK")); + else + SUIT_MessageBox::warning( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_FIELD_RANGE"), + tr("BUT_OK")); + RBIrange->setChecked(true); + changeRange(1); } return false; } @@ -1720,10 +1735,10 @@ void VisuGUI_Prs3dDlg::onHelp() } else { SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ), - tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). - arg( app->resourceMgr()->stringValue( "ExternalBrowser", - "application" ) ). - arg( aHelpFileName ) ); + tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). + arg( app->resourceMgr()->stringValue( "ExternalBrowser", + "application" ) ). + arg( aHelpFileName ) ); } } @@ -1734,7 +1749,7 @@ void VisuGUI_Prs3dDlg::keyPressEvent( QKeyEvent* e ) QDialog::keyPressEvent( e ); if ( e->isAccepted() ) return; - + if ( e->key() == Qt::Key_F1 ) { e->accept(); onHelp(); @@ -1757,7 +1772,7 @@ VisuGUI_ScalarBarBaseDlg::~VisuGUI_ScalarBarBaseDlg() //---------------------------------------------------------------------------- void VisuGUI_ScalarBarBaseDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, - bool theInit ) + bool theInit ) { myScalarPane->initFromPrsObject( thePrs ); } diff --git a/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx b/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx index 53a159bb..54c71d16 100755 --- a/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ValuesLabelingDlg.cxx @@ -1,21 +1,21 @@ // 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : VisuGUI_ValuesLabelingDlg.cxx // Author : Litonin SERGEY @@ -34,7 +34,7 @@ /*! \class VisuGUI_ValuesLabelingDlg - \brief This class is intended for changing parameters of labeling values + \brief This class is intended for changing parameters of labeling values of 3D colored presentations */ @@ -89,7 +89,7 @@ VisuGUI_ValuesLabelingDlg::VisuGUI_ValuesLabelingDlg( SalomeApp_Module* theModul aBtnLay->addWidget( aHelp, 0, 3 ); myFont->setMode( QtxFontEdit::Custom ); - myFont->setFeatures( QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | + myFont->setFeatures( QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow | QtxFontEdit::UserSize | QtxFontEdit::Size ); QStringList fam; fam.append( tr( "VISU_FONT_ARIAL" ) ); @@ -98,13 +98,13 @@ VisuGUI_ValuesLabelingDlg::VisuGUI_ValuesLabelingDlg( SalomeApp_Module* theModul myFont->setFonts( fam ); // Layout widgets - + QVBoxLayout* aMainLay = new QVBoxLayout( this ); aMainLay->setSpacing( 5 ); aMainLay->setMargin( 5 ); aMainLay->addWidget( aFGrp ); aMainLay->addWidget( aBtnGrp ); - + // Connect signals and slots connect( anOK,SIGNAL( clicked() ), SLOT( accept() ) ); connect( aCancel, SIGNAL( clicked() ), SLOT( reject() ) ); @@ -121,9 +121,9 @@ VisuGUI_ValuesLabelingDlg::~VisuGUI_ValuesLabelingDlg() } /*! - \brief Initializes dialog fields using specified presentation + \brief Initializes dialog fields using specified presentation \param thePrs presentation - \param theInit not used + \param theInit not used \sa storeToPrsObject() */ void VisuGUI_ValuesLabelingDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool ) @@ -174,7 +174,7 @@ void VisuGUI_ValuesLabelingDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, int VisuGUI_ValuesLabelingDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) { if ( !thePrs ) - return 0; + return 0; QFont aFont = myFont->currentFont(); @@ -198,7 +198,7 @@ int VisuGUI_ValuesLabelingDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) // color QColor aColor = myColor->color(); - thePrs->SetValLblFontColor( + thePrs->SetValLblFontColor( aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255. ); return 1; @@ -211,23 +211,3 @@ QString VisuGUI_ValuesLabelingDlg::GetContextHelpFilePath() { return "viewing_3d_presentations_page.html#labeling_parameters_anchor"; } - - - - - - - - - - - - - - - - - - - - -- 2.39.2