#include "VisuGUI_Tools.h"
#include "VisuGUI_ActionsDef.h"
+#include "VISU_ImplicitFunctionWidget.h"
+#include "SalomeApp_Study.h"
+#include "VVTK_MainWindow.h"
+#include "VISU_View_i.hh"
+
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+
+#include <sstream>
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
")) and (isVisible=false)";
mgr->setRule( action( VISU_DISPLAY ), aRule, true );
+
+ mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "$client in {'VTKViewer' 'SVTK'} and selcount=0", true );
}
//---------------------------------------------------------------
QApplication::restoreOverrideCursor();
}
+
+
+//---------------------------------------------------------------
+namespace
+{
+ void
+ GetViewParams(VVTK_MainWindow* theViewWindow,
+ const char* theSuffix,
+ std::ostringstream& theStr)
+ {
+ float backint[3];
+ vtkRenderer* aRenderer = theViewWindow->getRenderer();
+ aRenderer->GetBackground(backint);
+ Storable::DataToStream(theStr,std::string("myColor") + theSuffix + ".R",backint[0]);
+ Storable::DataToStream(theStr,std::string("myColor") + theSuffix + ".G",backint[1]);
+ Storable::DataToStream(theStr,std::string("myColor") + theSuffix + ".B",backint[2]);
+
+ double aPosition[3];
+ vtkCamera* aCamera = aRenderer->GetActiveCamera();
+ aCamera->GetPosition(aPosition);
+ Storable::DataToStream(theStr,std::string("myPosition") + theSuffix + "[0]",aPosition[0]);
+ Storable::DataToStream(theStr,std::string("myPosition") + theSuffix + "[1]",aPosition[0]);
+ Storable::DataToStream(theStr,std::string("myPosition") + theSuffix + "[2]",aPosition[0]);
+
+ double aFocalPnt[3];
+ aCamera->GetFocalPoint(aFocalPnt);
+ Storable::DataToStream(theStr,std::string("myFocalPnt") + theSuffix + "[0]",aFocalPnt[0]);
+ Storable::DataToStream(theStr,std::string("myFocalPnt") + theSuffix + "[1]",aFocalPnt[0]);
+ Storable::DataToStream(theStr,std::string("myFocalPnt") + theSuffix + "[2]",aFocalPnt[0]);
+
+ double aViewUp[3];
+ aCamera->GetViewUp(aViewUp);
+ Storable::DataToStream(theStr,std::string("myViewUp") + theSuffix + "[0]",aFocalPnt[0]);
+ Storable::DataToStream(theStr,std::string("myViewUp") + theSuffix + "[1]",aFocalPnt[0]);
+ Storable::DataToStream(theStr,std::string("myViewUp") + theSuffix + "[2]",aFocalPnt[0]);
+
+ float aParallelScale = aCamera->GetParallelScale();
+ Storable::DataToStream(theStr,std::string("myParallelScale") + theSuffix,aParallelScale);
+
+ double aScaleFactor[3];
+ theViewWindow->GetScale(aScaleFactor);
+ Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[0]",aFocalPnt[0]);
+ Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[1]",aFocalPnt[0]);
+ Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[2]",aFocalPnt[0]);
+ }
+
+ void
+ GetViewParams(VVTK_MainWindow1* theViewWindow,
+ std::ostringstream& theStr)
+ {
+ GetViewParams(theViewWindow,"1",theStr);
+
+ VISU_ImplicitFunctionWidget* aWidget = theViewWindow->GetImplicitFunctionWidget();
+ float anOrigin[3];
+ aWidget->GetOrigin(anOrigin);
+ Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
+ Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
+ Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
+
+ float aNormal[3];
+ aWidget->GetNormal(aNormal);
+ Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
+ Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
+ Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
+
+ float aDepth = aWidget->Distance();
+ Storable::DataToStream(theStr,"myCursorDepth",aDepth);
+ }
+
+ void
+ GetViewParams(VVTK_MainWindow2* theViewWindow,
+ std::ostringstream& theStr)
+ {
+ GetViewParams(theViewWindow,"2",theStr);
+ }
+
+ std::string
+ GetViewParams(VVTK_ViewWindow* theViewWindow)
+ {
+ std::ostringstream aStream;
+
+ Storable::DataToStream(aStream,"myComment","GAUSSVIEW");
+
+ GetViewParams(theViewWindow->getMainWindow1(),aStream);
+ GetViewParams(theViewWindow->getMainWindow2(),aStream);
+
+ aStream<<ends;
+
+ return aStream.str();
+ }
+}
+
+void
+VisuGUI_Module::
+OnSaveViewParams()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
+ return;
+
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+
+ SALOME_ListIO aListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+ if(aListIO.Extent() > 1)
+ return;
+
+ std::string aName;
+ if(aListIO.Extent() == 0){
+ aName = VISU::View3D_i::GenerateViewParamsName().latin1();
+ }else{
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+ aName = anIO->getName();
+ }
+
+ SUIT_ViewManager* aViewManager = getApp()->activeViewManager();
+ if(aViewManager->getType() == SVTK_Viewer::Type())
+ VISU::View3D_i::SaveViewParams(aViewManager,aName.c_str());
+ else if(aViewManager->getType() == VVTK_Viewer::Type()){
+ SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+ VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
+ std::string aValue = GetViewParams(aViewWindow);
+
+ SUIT_Study* aSStudy = aViewManager->study();
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
+ _PTR(Study) aCStudy = aStudy->studyDS();
+ std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(aName,"VISU");
+ _PTR(GenericAttribute) anAttr;
+ int iEnd = aList.size();
+ for(int i = 0; i < iEnd; i++){
+ _PTR(SObject) anObj = aList[i];
+ std::string anEntry = anObj->GetID();
+ if(anObj->FindAttribute(anAttr,"AttributeComment")){
+ _PTR(AttributeComment) aCmnt (anAttr);
+ std::string aComm (aCmnt->Value());
+ if(aComm.compare(View3D_i::myComment) >= 0){
+ aCmnt->SetValue(aValue.c_str());
+ return;
+ }
+ }
+ }
+
+ _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
+ std::string aSComponentEntry = aSComponent->GetID();
+ std::string anEntry = CreateAttributes(aCStudy,
+ aSComponentEntry.c_str(),
+ "",
+ "",
+ aName.c_str(),
+ "",
+ aValue.c_str());
+ }else
+ return;
+
+ UpdateObjBrowser(this);
+}