1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <inspector/View_Tools.hxx>
17 #include <inspector/View_Viewer.hxx>
18 #include <inspector/View_Widget.hxx>
19 #include <inspector/View_Window.hxx>
21 #include <V3d_View.hxx>
23 #include <Standard_WarningsDisable.hxx>
26 #include <Standard_WarningsRestore.hxx>
28 // =======================================================================
29 // function : CreateAction
31 // =======================================================================
32 QAction* View_Tools::CreateAction (const QString& theText, const char* theSlot, QObject* theParent, QObject* theContext)
34 QAction* anAction = new QAction (theText, theParent);
35 QObject::connect (anAction, SIGNAL (triggered (bool)), theContext, theSlot);
39 // =======================================================================
40 // function : SaveState
42 // =======================================================================
43 void View_Tools::SaveState (View_Window* theView, QMap<QString, QString>& theItems,
44 const QString& thePrefix)
46 QStringList aCameraDirection;
47 Standard_Real aVX, aVY, aVZ;
48 theView->GetView()->GetViewer()->GetView()->Proj (aVX, aVY, aVZ);
49 aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
51 theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
54 // =======================================================================
55 // function : RestoreState
57 // =======================================================================
58 bool View_Tools::RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
59 const QString& thePrefix)
61 if (theKey == thePrefix + "view_camera_direction")
63 QStringList aValues = theValue.split (",");
64 if (aValues.size() == 3)
66 Standard_Real aVX = aValues.at (0).toDouble();
67 Standard_Real aVY = aValues.at (1).toDouble();
68 Standard_Real aVZ = aValues.at (2).toDouble();
70 theView->GetView()->SetInitProj (aVX, aVY, aVZ);