forked from FreeCAD/FreeCAD-macros
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFCRotateViewAbsolute.FCMacro
92 lines (64 loc) · 1.96 KB
/
FCRotateViewAbsolute.FCMacro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from FreeCAD import Base
import FreeCADGui as Gui
from math import cos,sin,pi
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.alpha=00
self.beta=180
dial = QDial()
dial.setNotchesVisible(True)
self.dial=dial
dial.setMaximum(360)
dial.setValue(self.alpha)
dial2 = QDial()
dial2.setNotchesVisible(True)
self.dial2=dial2
dial2.setMaximum(360)
dial2.setValue(self.beta)
spinbox = QSpinBox()
spinbox.setMaximum(360)
layout = QHBoxLayout()
layout.addWidget(dial)
layout.addWidget(dial2)
# layout.addWidget(spinbox)
self.setLayout(layout)
#self.connect(dial, SIGNAL("valueChanged(int)"), spinbox.setValue)
#self.connect(spinbox, SIGNAL("valueChanged(int)"), dial.setValue)
dial.valueChanged.connect(spinbox.setValue);
dial.valueChanged.connect(self.dreher);
dial2.valueChanged.connect(self.heber);
self.cami()
self.setWindowTitle("Camera position")
Gui.SendMsgToActiveView("ViewFit")
def dreher(self):
self.alpha=self.dial.value()
self.cami()
def heber(self):
self.beta=self.dial2.value()
self.cami()
def cami(self):
from pivy import coin
alpha=self.alpha
beta=self.beta
camera = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
Gui=FreeCADGui
if False:
typeCamera="Orthographic"
if typeCamera=="Orthographic":
Gui.activeDocument().activeView().setCameraType("Orthographic")
else:
Gui.activeDocument().activeView().setCameraType("Perspective")
campos=Base.Vector( 1000 * cos (pi*alpha/360)*sin(pi*beta/360), 1000*sin(pi*alpha/360)*sin(pi*beta/360), 1000*cos(pi*beta/360))
camera.position.setValue( campos)
pos3=FreeCAD.Vector(0,0,0)
pos3.sub(campos)
#if False:
camera.pointAt(coin.SbVec3f(pos3),coin.SbVec3f(0,0,1))
App.ActiveDocument.recompute()
FreeCADGui.updateGui()
form = Form()
form.show()