Macro FCCamera: Difference between revisions
(create page) |
(Fixed icon location for Addon Manager.) |
||
(63 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
{{Macro|Icon=FCCamera_00|Name=Macro FCCamera|Description=This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen.|Author=Mario52}} |
|||
<translate> |
|||
<!--T:1--> |
|||
{{Macro |
|||
|Name=Macro FCCamera |
|||
|Icon=FCCamera_00.png |
|||
|Description={{ColoredText|#ff0000|#ffffff|The new modified version GUI for the HD dpi (QGridLayout) runs only with FC version 0.18 and more (PySide2 Qt5)}}<br/><br/> |
|||
For previous versions, see [https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/42dc3ef73dc8db463a03b175f5a7f1f6978e3293/Macro%2520FCCamera.FCMacro FCCamera] and install it manually.<br/><br/> |
|||
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view. |
|||
|Author=Mario52 |
|||
|Version=0.14 |
|||
|Date=2020/10/20 |
|||
|FCVersion=0.18 and more |
|||
|Download=[https://wiki.freecad.org/images/2/25/FCCamera_00.png ToolBar Icon] |
|||
}} |
|||
==Description== <!--T:2--> |
|||
<!--T:63--> |
|||
==Description== |
|||
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view. |
|||
</translate> |
|||
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, |
|||
{{Codeextralink|https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/98d90ee303e9fa5d6aed6e9f2e36e7ca1a18ca19/Macro%2520FCCamera.FCMacro}} |
|||
<translate> |
|||
==Usage== <!--T:3--> |
|||
to detect the position of the camera, align view to face or to axis, align the object to view. |
|||
<!--T:5--> |
|||
==How to use== |
|||
[[File:Macro FCCamera 00.png|250px|left|FCCamera]] |
|||
<!--T:6--> |
|||
Uses aesy, |
|||
'''Camera of Axis''': The dialog box to enter the rotation value angle in degrees. |
|||
<!--T:7--> |
|||
[[File:Macro FCCamera 00.png|left|FCCamera]] |
|||
'''Angle rotation Axis in degrees''': Select the rotation axis '''X''', '''Y''' or '''Z'''. |
|||
'''Camera of Axis''' |
|||
* The dialog box to enter the rotation value angle in degrees. |
|||
'''Angle rotation Axis in degrees''' |
|||
* Select the rotation axis '''X Y''' or '''Z'''. |
|||
<!--T:8--> |
|||
'''Axe of rotation''' |
'''Axe of rotation''' |
||
<!--T:9--> |
|||
* [[File:FCCamera_01.png|24px]] {{KEY|Accept the rotation}} : Accept the rotation give to angle selected |
* [[File:FCCamera_01.png|24px]] {{KEY|Accept the rotation}} : Accept the rotation give to angle selected |
||
<!--T:10--> |
|||
'''Virtual''' |
'''Virtual''' |
||
<!--T:11--> |
|||
* [[File:FCCamera_02.png|24px]] {{KEY|Detect camera orientation}} : Detect the camera orientation and print in report view. The returned value is the value provided by the function getCameraOrientation(). |
|||
* [[File:FCCamera_02.png|24px]] {{KEY|Detect camera orientation}} : Detect the camera orientation and print in report view. The returned value is the value provided by the function '''getCameraOrientation()'''. |
|||
<!--T:12--> |
|||
'''Align view to face selected''' |
'''Align view to face selected''' |
||
<!--T:13--> |
|||
* [[File:FCCamera_03.png|24px]] {{KEY|To Face.}} : Align the view to the selected face. Click and repeat the click for '''NormalAt''' : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)" |
* [[File:FCCamera_03.png|24px]] {{KEY|To Face.}} : Align the view to the selected face. Click and repeat the click for '''NormalAt''' : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)" |
||
<!--T:14--> |
|||
* [[File:FCCamera_04.png|24px]] {{KEY|To Axis.}} : Align the view to Axis face selected. Click and repeat the click for '''Surface Axis''' : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)" |
* [[File:FCCamera_04.png|24px]] {{KEY|To Axis.}} : Align the view to Axis face selected. Click and repeat the click for '''Surface Axis''' : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)" |
||
<!--T:15--> |
|||
* [[File:FCCamera_05.png|24px]] {{KEY|Align object to view.}} : Align the object selected to the actual view. The changed values are : Rotation Axis((X, Y, Z), Angle) Same Euler angles : Yaw, Pitch, Roll, The Translation is not modify. |
|||
* [[File:FCCamera_05.png|24px]] {{KEY|Align object to view.}} : Align the object selected to the actual view. The changed values are : Rotation Axis((X, Y, Z), Angle), same Euler angles : Yaw, Pitch, Roll, The Translation is not modify. |
|||
<!--T:16--> |
|||
* [[File:FCCamera_06.png|24px]] {{KEY|Align object to view.}} : A circular plane is created facing the screen to mouse click coordinates on an object. The radius of the plane is equal to the maximum dimension of BoundBox. If no object is selected, the plane is created to 0, 0, 0 coordinates with a radius of 20 mm.<br /> (The radius is modifiable to line 494) |
|||
* [[File:FCCamera_06.png|24px]] {{KEY|Create plane of view.}} : A circular plane is created facing the screen to mouse click coordinates on an object. The radius of the plane is equal to the maximum dimension of BoundBox. If no object is selected, the plane is created to 0, 0, 0 coordinates with a radius of 20 mm. The radius is modifiable to line 515: |
|||
</translate> |
|||
{{Code|code= |
{{Code|code= |
||
rayon = 20 # Radius of plane |
rayon = 20 # Radius of plane |
||
}} |
}} |
||
<translate> |
|||
<!--T:17--> |
|||
* [[File:FCCamera_07.png|24px]] {{KEY|Reset.}} : Reset all values. |
|||
* |
*{{KEY|[[File:FCCamera_07.png|24px]] Reset.}} : Reset all values |
||
*{{KEY| [[File:FCCamera_00.png|24px]] Photo.}} : Section save the screen rotation an image in angle value |
|||
*{{KEY| [[File:FCCamera_08.png|24px]] Quit.}} : Quit FCCamera |
|||
<!--T:44--> |
|||
{{clear}} |
{{clear}} |
||
== |
==Section Photo== |
||
<!--T:45--> |
|||
Download the file image and copy in your macro repertory |
|||
[[File:Macro FCCamera 00b.png|250px|left|FCCamera]] |
|||
{{clear}} |
|||
<!--T:46--> |
|||
(Click the image, in the new window position the mouse over the image, click the right mouse and do "Save target as ...) |
|||
*{{KEY|ComboBox Actual }} : Choose your screen definition for the image format |
|||
**Available (pre-defined): |
|||
***"Actual" (definition actual of screen) |
|||
***"Icon 16 x 16" |
|||
***"Icon 32 x 32" |
|||
***"Icon 64 x 64" |
|||
***"Icon 128 x 128" |
|||
***"CGA 320 x 200" |
|||
***"QVGA 320 x 240" |
|||
***"VGA 640 x 480" |
|||
***"SVGA 800 x 600" |
|||
***"XGA 1024 x 768" |
|||
***"XGA+ 1152 x 864" |
|||
***"SXGA 1280 x 1024" |
|||
***"SXGA+ 1400 x 1050" |
|||
***"UXGA 1600 x 1200" |
|||
***"QXGA 2048 x 1536" |
|||
***"Free" |
|||
<!--T:47--> |
|||
*{{KEY|SpinBox X and Y }} |
|||
<!--T:48--> |
|||
[[File:FCCamera_00.png|Logo FCCamera]] [[File:FCCamera_01.png|Accept]] [[File:FCCamera_02.png|Detect]] [[File:FCCamera_03.png|To Face]] |
|||
*{{KEY|ComboBox Format image}} |
|||
[[File:FCCamera_04.png|To Axis]] [[File:FCCamera_05.png|Align Object to View]] [[File:FCCamera_06.png|Create plane]] [[File:FCCamera_07.png|Reset]] |
|||
**Available : |
|||
[[File:FCCamera_08.png|Quit]] |
|||
***"BMP *.bmp" |
|||
***"ICO *.ico" |
|||
***"JPEG *.jpeg" |
|||
***"JPG *.jpg" |
|||
***"PNG *.png" (by default) |
|||
***"PPM *.ppm" |
|||
***"TIF *.tif" |
|||
***"TIFF *.tiff" |
|||
***"XBM *.xbm" |
|||
***"XPM *.xpm" |
|||
<!--T:18--> |
|||
'''Macro FCCamera.FCMacro''' |
|||
*Line 1 : Number image calculated by the angle give (ex: angle 60 degrees = 360 (complete rotation) / 60 (angle) = 6 images |
|||
<!--T:49--> |
|||
{{Code|code= |
|||
*Line 2 : The definition of screen used |
|||
# -*- coding: utf-8 -*- |
|||
""" |
|||
*************************************************************************** |
|||
* Copyright (c) 2015 <mario52> * |
|||
* * |
|||
* This file is a supplement to the FreeCAD CAx development system. * |
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU Lesser General Public License (LGPL) * |
|||
* as published by the Free Software Foundation; either version 2 of * |
|||
* the License, or (at your option) any later version. * |
|||
* for detail see the LICENCE text file. * |
|||
* * |
|||
* This software 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 Library General Public License for more details. * |
|||
* * |
|||
* You should have received a copy of the GNU Library General Public * |
|||
* License along with this macro; if not, write to the Free Software * |
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
|||
* USA * |
|||
*************************************************************************** |
|||
* WARNING! All changes in this file will be lost and * |
|||
* may cause malfunction of the program * |
|||
*************************************************************************** |
|||
""" |
|||
# FCCamera 0.1 26/01/2015 |
|||
# |
|||
#OS: Windows Vista |
|||
#Word size of OS: 32-bit |
|||
#Word size of FreeCAD: 32-bit |
|||
#Version: 0.15.4502 (Git) |
|||
#Branch: master |
|||
#Hash: 3c754da0cbc86e06ade2543baecbca25701b7160 |
|||
#Python version: 2.7.8 |
|||
#Qt version: 4.8.6 |
|||
#Coin version: 4.0.0a |
|||
#OCC version: 6.7.1 |
|||
# |
|||
__title__="FCCamera" |
|||
__author__ = "Mario52" |
|||
<!--T:50--> |
|||
try: |
|||
*Background image : |
|||
import PyQt4 # PyQt4 |
|||
** Actual : save image with the screen colour actual |
|||
from PyQt4 import QtCore, QtGui # PyQt4 |
|||
** White : save image with the screen colour white |
|||
App.Console.PrintMessage("PyQt4"+"\n") |
|||
** Black : save image with the screen colour black |
|||
except Exception: |
|||
import PySide # PySide |
|||
from PySide import QtCore, QtGui # PySide |
|||
App.Console.PrintMessage("PySide"+"\n") |
|||
<!--T:51--> |
|||
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, DraftVecUtils |
|||
*{{KEY|[[File:FCCamera_00.png|24px]] Launch}} : Open the file window , give the name and the path |
|||
#import os, WorkingPlane |
|||
*{{KEY|[[File:FCCamera_07.png|24px]] Reset}} : Reset the default value |
|||
*{{KEY|[[File:FCCamera_00.png|24px]] Return}} : Quit the photo panel and return to FCCamera panel |
|||
{{clear}} |
|||
==Links== <!--T:25--> |
|||
from math import radians, degrees, sqrt, pi, sin, cos, asin |
|||
from FreeCAD import Base |
|||
from FreeCAD import Vector |
|||
import pivy |
|||
from pivy import coin |
|||
<!--T:64--> |
|||
global path ; path = "" |
|||
Related Links with FCCamera |
|||
global valeur ; valeur = 0.0 |
|||
global valeurV ; valeurV = 0.0 |
|||
global Rname ; Rname = ["","",""] |
|||
global RnameCube; RnameCube = "" |
|||
global RnameCompound; RnameCompound = "" |
|||
global datExtract; datExtract = "" |
|||
<!--T:26--> |
|||
global positionX ; positionX = 0.0 |
|||
*[[Macro_Rotate_View|Macro Rotate View]] |
|||
global positionY ; positionY = 0.0 |
|||
*[[Macro Align Object to View|Macro Align Object to View]] |
|||
global positionZ ; positionZ = 0.0 |
|||
*[[Macro_Align_Face_Object_to_View|Macro Align Face Object to View]] |
|||
*[[Macro_WorkFeatures|Macro WorkFeatures]] |
|||
<!--T:27--> |
|||
try: |
|||
Discussion Forum [http://forum.freecadweb.org/viewtopic.php?f=22&t=9056 MACRO:Work Feature 2014_12] |
|||
_fromUtf8 = QtCore.QString.fromUtf8 |
|||
except AttributeError: |
|||
def _fromUtf8(s): |
|||
return s |
|||
==Script== <!--T:22--> |
|||
try: |
|||
_encoding = QtGui.QApplication.UnicodeUTF8 |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|||
except AttributeError: |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig) |
|||
<!--T:58--> |
|||
class SelObserver: # SelObserver |
|||
Download the icon files [https://forum.freecadweb.org/download/file.php?id=79288 FCCamera_Icones.zip] |
|||
def addSelection(self,document, object, element, position): # Selection SelObserver |
|||
global positionX |
|||
global positionY |
|||
global positionZ |
|||
positionX = position[0] |
|||
positionY = position[1] |
|||
positionZ = position[2] |
|||
<!--T:42--> |
|||
def datExtract(data): |
|||
Download the macro to Gist [https://gist.github.com/mario52a/4aa545c23b323cf68824 '''Macro FCCamera.FCMacro'''] |
|||
# return a string |
|||
data = str(data) |
|||
a = "" |
|||
for i in data: |
|||
if i in ("0123456789e.- "): |
|||
a+=i |
|||
a = a.strip(" ") |
|||
a = a.split(" ") |
|||
return a |
|||
==Examples== <!--T:31--> |
|||
global Nameelement2; Nameelement2 = "" # new selection |
|||
global vueView ; vueView = 0 # passe vue |
|||
===How to place an angle hole=== <!--T:32--> |
|||
def To_Face_Or_To_Axis(ToFace): # 1=NormalAt 0=Axis #Align Face selected to Face or to Axis |
|||
global vueView |
|||
global Nameelement2 |
|||
<!--T:33--> |
|||
try: |
|||
<center> |
|||
SubElement = FreeCADGui.Selection.getSelectionEx() |
|||
<gallery widths="300" heights="280"> |
|||
Nameelement = SubElement[0].SubElementNames[0] |
|||
File:FCCamera 09.png|Create your object |
|||
if Nameelement != Nameelement2: |
|||
File:FCCamera 10.png|Create one cylinder and positionning like this.<br/>Give your axis, angle inclination and click the button [[File:FCCamera_01.png|24px]] {{KEY|Accept the rotation}} |
|||
vueView = 0 |
|||
</gallery> |
|||
Nameelement2 = Nameelement |
|||
</center> |
|||
<!--T:34--> |
|||
if ToFace == 1: |
|||
<center> |
|||
v = Gui.Selection.getSelectionEx()[0].SubObjects[0].normalAt(0,0) # NormalAt |
|||
<gallery widths="300" heights="280"> |
|||
App.Console.PrintMessage("Nor At ") |
|||
File:FCCamera 11.png|Select your cylinder for create your hole |
|||
else: |
|||
File:FCCamera 12.png|In FCCamera, click the button [[File:FCCamera_05.png|24px]] {{KEY|Align Object to View}} |
|||
v=Gui.Selection.getSelectionEx()[0].SubObjects[0].Surface.Axis # Axis |
|||
</gallery> |
|||
App.Console.PrintMessage("S Axis ") |
|||
</center> |
|||
<!--T:35--> |
|||
if vueView == 0: |
|||
<center> |
|||
r=App.Rotation(App.Vector(0,0,1),v) |
|||
<gallery widths="300" heights="280"> |
|||
App.Console.PrintMessage("0,0,1"+"\n") |
|||
File:FCCamera 13.png|The cylinder moves to 15 degrees (it takes the camera's position). Do your Boolean operation |
|||
elif vueView == 1: |
|||
File:FCCamera 14.png|Your hole 15 degrees |
|||
r=App.Rotation(App.Vector(0,0,-1),v) |
|||
</gallery> |
|||
App.Console.PrintMessage("0,0,-1"+"\n") |
|||
</center> |
|||
elif vueView == 2: |
|||
r=App.Rotation(App.Vector(0,1,0),v) |
|||
App.Console.PrintMessage("0,1,0"+"\n") |
|||
elif vueView == 3: |
|||
r=App.Rotation(App.Vector(0,-1,0),v) |
|||
App.Console.PrintMessage("0,-1,0"+"\n") |
|||
elif vueView == 4: |
|||
r=App.Rotation(App.Vector(1,0,0),v) |
|||
App.Console.PrintMessage("1,0,0"+"\n") |
|||
elif vueView == 5: |
|||
r=App.Rotation(App.Vector(-1,0,0),v) |
|||
App.Console.PrintMessage("-1,0,0"+"\n") |
|||
vueView = -1 |
|||
<!--T:36--> |
|||
Gui.ActiveDocument.ActiveView.setCameraOrientation(r.Q)# |
|||
The same result can be achieved by creating a plan in the corner given by the mouse click position and a sketch. |
|||
vueView += 1 |
|||
except: |
|||
App.Console.PrintError("Select a face"+"\n") |
|||
<!--T:53--> |
|||
class Ui_MainWindow(object): |
|||
<center> |
|||
def setupUi(self, MainWindow): |
|||
<gallery widths="750" heights="700"> |
|||
global path |
|||
File:Macro_FCCamera_Align_To_Face.gif|example of the positioning of a spring on an axis of a face |
|||
self.window = MainWindow |
|||
</gallery> |
|||
path = FreeCAD.ConfigGet("AppHomePath") |
|||
</center> |
|||
#path = FreeCAD.ConfigGet("UserAppData") |
|||
<center> |
|||
#App.Console.PrintMessage(str(path)+"\n") |
|||
<gallery widths="850" heights="550"> |
|||
File:Test_FCCamera_Photo_01.gif|Example photo rotation and save images (you must create one animate Gif [https://www.gimp.org/ with GIMP]) |
|||
</gallery> |
|||
</center> |
|||
</translate> |
|||
<translate> |
|||
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
|||
==Version== <!--T:37--> |
|||
MainWindow.resize(209, 500) |
|||
MainWindow.setMaximumSize(QtCore.QSize(209, 500)) |
|||
self.centralWidget = QtGui.QWidget(MainWindow) |
|||
self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
|||
### ---graphicsView--- |
|||
self.graphicsView = QtGui.QGraphicsView(self.centralWidget) |
|||
self.graphicsView.setGeometry(QtCore.QRect(20, 10, 171, 101)) |
|||
self.graphicsView.setFrameShape(QtGui.QFrame.StyledPanel) |
|||
self.graphicsView.setObjectName(_fromUtf8("graphicsView")) |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_X.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
### ---graphicsView--- |
|||
self.groupBox_01 = QtGui.QGroupBox(self.centralWidget) |
|||
self.groupBox_01.setGeometry(QtCore.QRect(10, 120, 191, 151)) |
|||
self.groupBox_01.setObjectName(_fromUtf8("groupBox_01")) |
|||
<!--T:62--> |
|||
self.label_02 = QtGui.QLabel(self.groupBox_01) |
|||
*'''ver 0.14 (20/10/2020):''' correction bug "Grid" not accepted |
|||
self.label_02.setGeometry(QtCore.QRect(10, 20, 181, 16)) |
|||
self.label_02.setObjectName(_fromUtf8("label_02")) |
|||
<!--T:61--> |
|||
self.RB_Angle_X = QtGui.QRadioButton(self.groupBox_01) |
|||
*'''ver 0.13 (28/06/2020):''' adding files image in source code, create plane "On point, Center face, BBox center, Center Mass", gridLayout |
|||
self.RB_Angle_X.setGeometry(QtCore.QRect(10, 90, 51, 20)) |
|||
palette = QtGui.QPalette() |
|||
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) |
|||
self.RB_Angle_X.setPalette(palette) |
|||
font = QtGui.QFont() |
|||
font.setBold(True) |
|||
font.setWeight(75) |
|||
self.RB_Angle_X.setFont(font) |
|||
self.RB_Angle_X.setMouseTracking(True) |
|||
self.RB_Angle_X.setChecked(True) |
|||
self.RB_Angle_X.setObjectName(_fromUtf8("RB_Angle_X")) |
|||
self.RB_Angle_X.setToolTip(u"Rotation of the camera on the X axis") |
|||
self.RB_Angle_X.clicked.connect(self.on_RB_Angle_X_clicked) |
|||
<!--T:60--> |
|||
self.label_03 = QtGui.QLabel(self.groupBox_01) |
|||
*'''ver 00.12.1 (12/02/2020):''' suppress the bad character lines 674 and 675 (accent...) again |
|||
self.label_03.setGeometry(QtCore.QRect(10, 70, 161, 16)) |
|||
self.label_03.setObjectName(_fromUtf8("label_03")) |
|||
<!--T:59--> |
|||
self.RB_Angle_Y = QtGui.QRadioButton(self.groupBox_01) |
|||
*'''ver 12 (01/08/2019):''' compatible Python 3 ( print to print() ) |
|||
self.RB_Angle_Y.setGeometry(QtCore.QRect(80, 90, 41, 20)) |
|||
palette = QtGui.QPalette() |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 170, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 170, 0)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) |
|||
self.RB_Angle_Y.setPalette(palette) |
|||
font = QtGui.QFont() |
|||
font.setBold(True) |
|||
font.setWeight(75) |
|||
self.RB_Angle_Y.setFont(font) |
|||
self.RB_Angle_Y.setObjectName(_fromUtf8("RB_Angle_Y")) |
|||
self.RB_Angle_Y.setToolTip(u"Rotation of the camera on the Y axis") |
|||
self.RB_Angle_Y.clicked.connect(self.on_RB_Angle_Y_clicked) |
|||
<!--T:55--> |
|||
self.RB_Angle_Z = QtGui.QRadioButton(self.groupBox_01) |
|||
*'''ver 11 (13/01/2018):''' minor |
|||
self.RB_Angle_Z.setGeometry(QtCore.QRect(150, 90, 41, 20)) |
|||
palette = QtGui.QPalette() |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) |
|||
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) |
|||
brush.setStyle(QtCore.Qt.SolidPattern) |
|||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) |
|||
self.RB_Angle_Z.setPalette(palette) |
|||
font = QtGui.QFont() |
|||
font.setBold(True) |
|||
font.setWeight(75) |
|||
self.RB_Angle_Z.setFont(font) |
|||
self.RB_Angle_Z.setObjectName(_fromUtf8("RB_Angle_Z")) |
|||
self.RB_Angle_Z.setToolTip(u"Rotation of the camera on the Z axis") |
|||
self.RB_Angle_Z.clicked.connect(self.on_RB_Angle_Z_clicked) |
|||
<!--T:56--> |
|||
self.DS_Angle = QtGui.QDoubleSpinBox(self.groupBox_01) |
|||
*'''ver 10 (13/01/2018):''' add "def centerBoundBoxGlobal():" |
|||
self.DS_Angle.setGeometry(QtCore.QRect(8, 40, 171, 22)) |
|||
self.DS_Angle.setAlignment(QtCore.Qt.AlignCenter) |
|||
self.DS_Angle.setDecimals(10) |
|||
self.DS_Angle.setMinimum(-359.0) |
|||
self.DS_Angle.setMaximum(359.0) |
|||
self.DS_Angle.setSingleStep(1.0) |
|||
self.DS_Angle.setObjectName(_fromUtf8("DS_Angle")) |
|||
self.DS_Angle.setToolTip(u"Enter the angle of rotation in degrees.\n" |
|||
" The given angle is added to the angle of the current view") |
|||
self.DS_Angle.valueChanged.connect(self.on_DS_Angle_valueChanged) #connection DS_Angle |
|||
<!--T:57--> |
|||
self.PB_Accept_View = QtGui.QPushButton(self.groupBox_01) |
|||
*'''ver 09 (08/01/2018):''' minor |
|||
self.PB_Accept_View.setGeometry(QtCore.QRect(10, 110, 171, 28)) |
|||
icon1 = QtGui.QIcon() |
|||
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_01.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Accept_View.setIcon(icon1) |
|||
self.PB_Accept_View.setToolTip(u"Accept the view given") |
|||
self.PB_Accept_View.setObjectName(_fromUtf8("PB_Accept_View")) |
|||
self.PB_Accept_View.clicked.connect(self.on_PB_Accept_View_clicked) |
|||
<!--T:52--> |
|||
self.groupBox_02 = QtGui.QGroupBox(self.centralWidget) |
|||
*'''ver 08 (08/01/2018):''' supp "Pyqt4" and adjust number image |
|||
self.groupBox_02.setGeometry(QtCore.QRect(10, 280, 191, 181)) |
|||
*'''ver 07 (03/01/2018):''' add photo panel and rotation to axis selected (wire, edge, line ) |
|||
self.groupBox_02.setObjectName(_fromUtf8("groupBox_02")) |
|||
<!--T:43--> |
|||
self.PB_Detect_Camera = QtGui.QPushButton(self.groupBox_02) |
|||
*'''ver 0.6 (13/12/2016):''' new system for search the macro path directly in the preferences |
|||
self.PB_Detect_Camera.setGeometry(QtCore.QRect(10, 20, 171, 28)) |
|||
icon2 = QtGui.QIcon() |
|||
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_02.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Detect_Camera.setIcon(icon2) |
|||
self.PB_Detect_Camera.setObjectName(_fromUtf8("PB_Detect_Camera")) |
|||
self.PB_Detect_Camera.setToolTip(u"Detect the position of the camera\n" |
|||
" The returned value is the value provided by the function getCameraOrientation()") |
|||
self.PB_Detect_Camera.clicked.connect(self.on_PB_Detect_Camera_clicked) |
|||
</translate> |
|||
self.PB_To_Face = QtGui.QPushButton(self.groupBox_02) |
|||
#path = FreeCAD.ConfigGet("AppHomePath") |
|||
self.PB_To_Face.setGeometry(QtCore.QRect(10, 70, 81, 28)) |
|||
#path = FreeCAD.ConfigGet("UserAppData") |
|||
icon3 = QtGui.QIcon() |
|||
#path = "your path" |
|||
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_03.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path |
|||
self.PB_To_Face.setIcon(icon3) |
|||
path = param.GetString("MacroPath","") + "/" # macro path |
|||
self.PB_To_Face.setObjectName(_fromUtf8("PB_To_Face")) |
|||
path = path.replace("\\","/") |
|||
self.PB_To_Face.setToolTip("Align the view to the selected face \n" |
|||
App.Console.PrintMessage("Path locality to FCCamera.....images.png [ " + path + " ]"+"\n") |
|||
"Click and repeat the click for NormalAt : \n" |
|||
<translate> |
|||
"(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)") |
|||
self.PB_To_Face.clicked.connect(self.on_PB_To_Face_clicked) # align view to face Face |
|||
<!--T:38--> |
|||
self.label_04 = QtGui.QLabel(self.groupBox_02) |
|||
*'''ver 0.5 06/09/2016:''' correct name "FCCamera_Axis_rotation_X.png" in reset block |
|||
self.label_04.setGeometry(QtCore.QRect(10, 50, 161, 20)) |
|||
self.label_04.setObjectName(_fromUtf8("label_04")) |
|||
<!--T:41--> |
|||
self.PB_To_Axis = QtGui.QPushButton(self.groupBox_02) |
|||
*'''ver 0.4 28/02/2016 :''' add display all camera detection and the [http://forum.freecadweb.org/viewtopic.php?f=13&t=14213#p114667 Direction] |
|||
self.PB_To_Axis.setGeometry(QtCore.QRect(100, 70, 81, 28)) |
|||
icon4 = QtGui.QIcon() |
|||
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_04.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_To_Axis.setIcon(icon4) |
|||
self.PB_To_Axis.setObjectName(_fromUtf8("PB_To_Axis")) |
|||
self.PB_To_Axis.setToolTip("Align the view to Axis face selected \n" |
|||
"Click and repeat the click for Surface Axis : \n" |
|||
"(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)") |
|||
self.PB_To_Axis.clicked.connect(self.on_PB_To_Axis_clicked) # Align view to face Axis |
|||
<!--T:40--> |
|||
self.PB_Align_O_To_View = QtGui.QPushButton(self.groupBox_02) |
|||
*'''ver 0.3 18/03/2015 :''' modify line 492 replace "'''pl.Base = App.Vector(0,0,0)'''" to "'''pl.Base = sel[0].Placement.Base'''" now no longer moves the form at point (0,0,0) and leaves has the coordinates |
|||
self.PB_Align_O_To_View.setGeometry(QtCore.QRect(10, 105, 171, 28)) |
|||
icon5 = QtGui.QIcon() |
|||
icon5.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_05.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Align_O_To_View.setIcon(icon5) |
|||
self.PB_Align_O_To_View.setObjectName(_fromUtf8("PB_Align_O_To_View")) |
|||
self.PB_Align_O_To_View.setToolTip("Align the object selected to the actual view \n" |
|||
"The changed values are : Rotation Axis((X, Y, Z), Angle) \n" |
|||
"Same Euler angles : Yaw, Pitch, Roll \n The Translation is not modify") |
|||
self.PB_Align_O_To_View.clicked.connect(self.on_PB_Align_O_To_View_clicked) # Align object to view |
|||
self.PB_Create_Plane = QtGui.QPushButton(self.groupBox_02) |
|||
self.PB_Create_Plane.setGeometry(QtCore.QRect(10, 140, 171, 28)) |
|||
icon6 = QtGui.QIcon() |
|||
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_06.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Create_Plane.setIcon(icon6) |
|||
self.PB_Create_Plane.setObjectName(_fromUtf8("PB_Create_Plane")) |
|||
self.PB_Create_Plane.setToolTip("A circular plane is created facing the screen to mouse click coordinates on an object \n" |
|||
"The radius of the plane is equal to the maximum dimension of BoundBox \n" |
|||
"If no object is selected, the plane is created to 0, 0, 0 coordinates with a radius of 20 mm") |
|||
self.PB_Create_Plane.clicked.connect(self.on_PB_Create_Plane_clicked) # create plane |
|||
<!--T:39--> |
|||
self.PB_Reset = QtGui.QPushButton(self.centralWidget) |
|||
*'''ver 0.2 25/02/2015 :''' correct names files in for compatibility Linux (case sensitive) thanks microelly2 |
|||
self.PB_Reset.setGeometry(QtCore.QRect(10, 465, 91, 28)) |
|||
icon7 = QtGui.QIcon() |
|||
icon7.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_07.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Reset.setIcon(icon7) |
|||
self.PB_Reset.setObjectName(_fromUtf8("PB_Reset")) |
|||
self.PB_Reset.setToolTip("Refresh alls") |
|||
self.PB_Reset.clicked.connect(self.on_PB_Reset_clicked) # refresh |
|||
</translate> |
|||
self.PB_Quit = QtGui.QPushButton(self.centralWidget) |
|||
self.PB_Quit.setGeometry(QtCore.QRect(110, 465, 91, 28)) |
|||
icon8 = QtGui.QIcon() |
|||
icon8.addPixmap(QtGui.QPixmap(_fromUtf8(path+"FCcamera_08.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|||
self.PB_Quit.setIcon(icon8) |
|||
self.PB_Quit.setObjectName(_fromUtf8("PB_Quit")) |
|||
self.PB_Quit.setToolTip("Quit FCCamera") |
|||
self.PB_Quit.clicked.connect(self.on_PB_Quit_clicked) # quit |
|||
MainWindow.setCentralWidget(self.centralWidget) |
|||
self.retranslateUi(MainWindow) |
|||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|||
def retranslateUi(self, MainWindow): |
|||
MainWindow.setWindowTitle("FCCamera") |
|||
MainWindow.setWindowIcon(QtGui.QIcon(path+'FCcamera_00.png')) # change l'icône de la fenêtre principale |
|||
try: |
|||
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant |
|||
except Exception: |
|||
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant |
|||
self.groupBox_01.setTitle("Camera of Axis") |
|||
self.label_02.setText("Angle rotation Axis in degrees") |
|||
self.label_03.setText("Axe of rotation") |
|||
self.RB_Angle_X.setText("X") |
|||
self.RB_Angle_Y.setText("Y") |
|||
self.RB_Angle_Z.setText("Z") |
|||
self.PB_Accept_View.setText("Accept the rotation") |
|||
self.groupBox_02.setTitle("Virtual") |
|||
self.PB_Detect_Camera.setText("Detect camera orientation") |
|||
self.PB_To_Face.setText("To Face.") |
|||
self.label_04.setText("Align view to face selected.") |
|||
self.PB_To_Axis.setText("To Axis.") |
|||
self.PB_Align_O_To_View.setText("Align Object to View") |
|||
self.PB_Create_Plane.setText("Create plane of view.") |
|||
self.PB_Reset.setText("Reset") |
|||
self.PB_Quit.setText("Quit") |
|||
def on_RB_Angle_X_clicked(self): # X |
|||
global path |
|||
App.Console.PrintMessage("X"+"\n") |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_X.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_RB_Angle_Y_clicked(self): # Y |
|||
global path |
|||
App.Console.PrintMessage("Y"+"\n") |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_Y.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_RB_Angle_Z_clicked(self): # Z |
|||
global path |
|||
App.Console.PrintMessage("Z"+"\n") |
|||
pic = QtGui.QPixmap(path+"FCCamera_Axis_rotation_Z.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_DS_Angle_valueChanged(self,value): # connection DS_Angle value donnee en degres |
|||
global valeur |
|||
valeur = 0.0 |
|||
valeur = math.radians(value) # valeur en degres convertie en radian |
|||
def on_PB_Detect_Camera_clicked(self): # detection Orientation camera |
|||
plan = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() |
|||
App.Console.PrintMessage("___Camera_Orientation____________________"+"\n") |
|||
App.Console.PrintMessage("Radians XYZ Q : " + str(plan)+"\n") |
|||
xP = float(datExtract(plan)[0]) |
|||
yP = float(datExtract(plan)[1]) |
|||
zP = float(datExtract(plan)[2]) |
|||
qP = float(datExtract(plan)[3]) |
|||
App.Console.PrintMessage("Degrees XYZ : " + str(degrees(xP)) + " , " +str(degrees(yP)) + " , " + str(degrees(zP)) +"\n") |
|||
App.Console.PrintMessage("Degrees Q : " + str(degrees(qP)) +"\n"+"\n") |
|||
App.Console.PrintMessage("Radians Axis.xyz A : " + str(plan.Axis) + " , " + str(plan.Angle) +"\n") |
|||
App.Console.PrintMessage("Degrees Axis.x : " + str(degrees(plan.Axis.x)) +"\n") |
|||
App.Console.PrintMessage("Degrees Axis.y : " + str(degrees(plan.Axis.y)) +"\n") |
|||
App.Console.PrintMessage("Degrees Axis.z : " + str(degrees(plan.Axis.z)) +"\n") |
|||
App.Console.PrintMessage("Degrees Angle : " + str(degrees(plan.Angle)) +"\n") |
|||
App.Console.PrintMessage("___FCCamera______________________________"+"\n\n") |
|||
App.ActiveDocument.recompute() |
|||
def on_PB_Accept_View_clicked(self): # Accept Rotation Camera to Axis |
|||
global valeur |
|||
if (valeur != 0): |
|||
Xv = 0.0;Yv = 0.0;Zv = 0.0 |
|||
cam = Gui.ActiveDocument.ActiveView.getCameraNode() |
|||
rot = coin.SbRotation() |
|||
##### |
|||
if self.RB_Angle_X.isChecked(): |
|||
Xv = 1.0 |
|||
App.Console.PrintMessage("(X ") |
|||
else: |
|||
App.Console.PrintMessage("(- ") |
|||
if self.RB_Angle_Y.isChecked(): |
|||
Yv = 1.0 |
|||
App.Console.PrintMessage("Y ") |
|||
else: |
|||
App.Console.PrintMessage("- ") |
|||
if self.RB_Angle_Z.isChecked(): |
|||
Zv = 1.0 |
|||
App.Console.PrintMessage("Z) ") |
|||
else: |
|||
App.Console.PrintMessage("-) "+"\n") |
|||
##### |
|||
rot.setValue(coin.SbVec3f(Xv,Yv,Zv),valeur) |
|||
nrot = cam.orientation.getValue() * rot |
|||
cam.orientation = nrot |
|||
App.Console.PrintMessage(str(valeur)+" rad. , "+str(math.degrees(valeur))+" deg."+"\n") |
|||
App.Console.PrintMessage("FCCamera_________________________________"+"\n\n") |
|||
if valeur == 0: |
|||
App.Console.PrintError("Value egal zero select one Value"+"\n") |
|||
def on_PB_Align_O_To_View_clicked(self): #Align and Fix Object to View |
|||
sel = FreeCADGui.Selection.getSelection() |
|||
if (len(sel)==0): |
|||
App.Console.PrintError("Select one object"+"\n") |
|||
else: |
|||
Nameelement = sel[0].Name |
|||
App.Console.PrintMessage(str(Nameelement)+"\n") |
|||
pl = FreeCAD.Placement() |
|||
pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() |
|||
pl.Base = FreeCAD.Vector(0.0,0.0,0.0) |
|||
App.ActiveDocument.getObject(Nameelement).Placement=pl |
|||
def on_PB_Create_Plane_clicked(self): # Create plane |
|||
global positionX # create plans coordinate mouse |
|||
global positionY |
|||
global positionZ |
|||
rayon = 20 # Radius of plane |
|||
selEx = FreeCADGui.Selection.getSelectionEx() |
|||
objs = [selobj.Object for selobj in selEx] |
|||
if len(objs) >= 1: # radius = > BounBox length |
|||
s = objs[0].Shape |
|||
boundBox_ = s.BoundBox |
|||
boundBoxLX = boundBox_.XLength |
|||
boundBoxLY = boundBox_.YLength |
|||
boundBoxLZ = boundBox_.ZLength |
|||
rayon = boundBoxLX |
|||
if rayon < boundBoxLY: |
|||
rayon = boundBoxLY |
|||
elif rayon < boundBoxLZ: |
|||
rayon = boundBoxLZ |
|||
radiusP = rayon # Radius of plane |
|||
App.Console.PrintMessage("Create plane ("+str(radiusP)+" mm)"+"\n") |
|||
FcPlane = doc.addObject("App::DocumentObjectGroup","FcPlane") |
|||
plan = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation() |
|||
# App.Console.PrintMessage(str(plan)+"\n") |
|||
# App.Console.PrintMessage(str(positionX)+" "+str(positionY)+" "+str(positionZ)+"\n") |
|||
xP = float(datExtract(plan)[0]) |
|||
yP = float(datExtract(plan)[1]) |
|||
zP = float(datExtract(plan)[2]) |
|||
qP = float(datExtract(plan)[3]) |
|||
pl = FreeCAD.Placement() |
|||
pl.Rotation.Q = (xP,yP,zP,qP) # rotation of object |
|||
pl.Base = FreeCAD.Vector(positionX,positionY,positionZ) # here coordinates XYZ of plan |
|||
# Draft.makeRectangle(length=radiusP,height=radiusP,placement=pl,face=False,support=None) |
|||
points=[FreeCAD.Vector(-(radiusP*1.5),0,0),FreeCAD.Vector((radiusP*1.5),0,0)] |
|||
mire01 = Draft.makeWire(points,closed=False,placement=pl,face=False,support=None) |
|||
FreeCADGui.ActiveDocument.getObject(App.ActiveDocument.ActiveObject.Name).LineColor = (1.0,0.0,0.0) |
|||
FcPlane.addObject(mire01) # contener character |
|||
points=[FreeCAD.Vector(0,-(radiusP*1.5),0),FreeCAD.Vector(0,(radiusP*1.5),0)] |
|||
mire02 = Draft.makeWire(points,closed=False,placement=pl,face=False,support=None) |
|||
FreeCADGui.ActiveDocument.getObject(App.ActiveDocument.ActiveObject.Name).LineColor = (1.0,0.0,0.0) |
|||
FcPlane.addObject(mire02) # contener character |
|||
cercle = Draft.makeCircle(radius=radiusP,placement=pl,face=False,support=None) |
|||
Rnameplane = App.ActiveDocument.ActiveObject.Name |
|||
App.ActiveDocument.ActiveObject.Label = "PlaneC" |
|||
FreeCAD.ActiveDocument.getObject(Rnameplane).MakeFace = True |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).LineColor = (1.0,0.0,0.0) |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).ShapeColor = (0.0,0.66666669,1.0) |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).Transparency = 80 |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).GridSize = '10 mm' |
|||
# FreeCADGui.ActiveDocument.getObject(Rnameplane).GridSnap = True |
|||
FreeCADGui.ActiveDocument.getObject(Rnameplane).ShowGrid = True |
|||
FcPlane.addObject(cercle) # contener character |
|||
FreeCAD.ActiveDocument.recompute() |
|||
positionX = 0.0 |
|||
positionY = 0.0 |
|||
positionZ = 0.0 |
|||
def on_PB_To_Face_clicked(self): # view to face selected Face |
|||
To_Face_Or_To_Axis(1) |
|||
def on_PB_To_Axis_clicked(self): # view to face selected Axis |
|||
To_Face_Or_To_Axis(0) |
|||
def on_PB_Reset_clicked(self): # Refresh |
|||
global valeur |
|||
global positionX |
|||
global positionY |
|||
global positionZ |
|||
global vueView |
|||
App.Console.PrintMessage("Refresh"+"\n") |
|||
Gui.activeDocument().activeView().viewTop() |
|||
Gui.SendMsgToActiveView("ViewFit") |
|||
valeur = 0.0 |
|||
self.DS_Angle.setProperty("value", 0.0) |
|||
positionX = 0.0 |
|||
positionY = 0.0 |
|||
positionZ = 0.0 |
|||
vueView = 0 |
|||
self.groupBox_01.setTitle("Camera of Axis") |
|||
self.label_02.setText("Angle rotation Axis in degrees") |
|||
self.label_03.setText("Axe of rotation") |
|||
self.RB_Angle_X.setText("X") |
|||
self.RB_Angle_Y.setText("Y") |
|||
self.RB_Angle_Z.setText("Z") |
|||
self.RB_Angle_X.setChecked(True) |
|||
pic = QtGui.QPixmap(path+"Axis_rotation_X.png") |
|||
self.scene = QtGui.QGraphicsScene() |
|||
self.scene.addPixmap(QtGui.QPixmap(pic)) |
|||
self.graphicsView.setScene(ui.scene) |
|||
def on_PB_Quit_clicked(self): # quit |
|||
App.Console.PrintMessage("Fin FCCamera"+"\n") |
|||
FreeCADGui.Selection.removeObserver(s) # desinstalle la fonction residente |
|||
self.window.hide() |
|||
##Start##### |
|||
doc = FreeCAD.ActiveDocument # create one document |
|||
if doc == None: |
|||
doc = FreeCAD.newDocument() |
|||
#Gui.ActiveDocument.ActiveView.setAxisCross(True) # GuiAxis true |
|||
s=SelObserver() # installe the function in resident mode SelObserver |
|||
FreeCADGui.Selection.addObserver(s) # installe the function in resident mode SelObserver |
|||
MainWindow = QtGui.QMainWindow() |
|||
ui = Ui_MainWindow() |
|||
ui.setupUi(MainWindow) |
|||
MainWindow.show() |
|||
}} |
Latest revision as of 21:39, 28 December 2023
Description |
---|
The new modified version GUI for the HD dpi (QGridLayout) runs only with FC version 0.18 and more (PySide2 Qt5) For previous versions, see FCCamera and install it manually. |
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
0.14 |
Date last modified |
2020/10/20 |
FreeCAD Version(s) |
0.18 and more |
Default shortcut |
None |
See also |
None |
Description
This macro can rotate the screen in a defined angle and the defined axis and creates a plan to face the screen to create a form in the specified plan positions the selected face facing the screen, to detect the position of the camera, align view to face or to axis, align the object to view.
Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro
# This code is copied instead of the original macro code # to guide the user to the online download page. # Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki # or if the RAW code URL is somewhere else in the wiki. from PySide import QtGui, QtCore diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Information", "This macro must be downloaded from this link\n" "\n" "https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/98d90ee303e9fa5d6aed6e9f2e36e7ca1a18ca19/Macro%2520FCCamera.FCMacro" + "\n" "\n" "Quit this window to access the download page") diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) diag.setWindowModality(QtCore.Qt.ApplicationModal) diag.exec_() import webbrowser webbrowser.open("https://gist.githubusercontent.com/mario52a/4aa545c23b323cf68824/raw/98d90ee303e9fa5d6aed6e9f2e36e7ca1a18ca19/Macro%2520FCCamera.FCMacro")
Usage
Camera of Axis: The dialog box to enter the rotation value angle in degrees.
Angle rotation Axis in degrees: Select the rotation axis X, Y or Z.
Axe of rotation
Virtual
- Detect camera orientation : Detect the camera orientation and print in report view. The returned value is the value provided by the function getCameraOrientation().
Align view to face selected
- To Face. : Align the view to the selected face. Click and repeat the click for NormalAt : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)"
- To Axis. : Align the view to Axis face selected. Click and repeat the click for Surface Axis : "(0,0,1) (0,0,-1) (0,1,0) (0,-1,0) (1,0,0) (-1,0,0)"
- Align object to view. : Align the object selected to the actual view. The changed values are : Rotation Axis((X, Y, Z), Angle), same Euler angles : Yaw, Pitch, Roll, The Translation is not modify.
- Create plane of view. : A circular plane is created facing the screen to mouse click coordinates on an object. The radius of the plane is equal to the maximum dimension of BoundBox. If no object is selected, the plane is created to 0, 0, 0 coordinates with a radius of 20 mm. The radius is modifiable to line 515:
rayon = 20 # Radius of plane
- Reset. : Reset all values
- Photo. : Section save the screen rotation an image in angle value
- Quit. : Quit FCCamera
Section Photo
- ComboBox Actual : Choose your screen definition for the image format
- Available (pre-defined):
- "Actual" (definition actual of screen)
- "Icon 16 x 16"
- "Icon 32 x 32"
- "Icon 64 x 64"
- "Icon 128 x 128"
- "CGA 320 x 200"
- "QVGA 320 x 240"
- "VGA 640 x 480"
- "SVGA 800 x 600"
- "XGA 1024 x 768"
- "XGA+ 1152 x 864"
- "SXGA 1280 x 1024"
- "SXGA+ 1400 x 1050"
- "UXGA 1600 x 1200"
- "QXGA 2048 x 1536"
- "Free"
- Available (pre-defined):
- SpinBox X and Y
- ComboBox Format image
- Available :
- "BMP *.bmp"
- "ICO *.ico"
- "JPEG *.jpeg"
- "JPG *.jpg"
- "PNG *.png" (by default)
- "PPM *.ppm"
- "TIF *.tif"
- "TIFF *.tiff"
- "XBM *.xbm"
- "XPM *.xpm"
- Available :
- Line 1 : Number image calculated by the angle give (ex: angle 60 degrees = 360 (complete rotation) / 60 (angle) = 6 images
- Line 2 : The definition of screen used
- Background image :
- Actual : save image with the screen colour actual
- White : save image with the screen colour white
- Black : save image with the screen colour black
- Launch : Open the file window , give the name and the path
- Reset : Reset the default value
- Return : Quit the photo panel and return to FCCamera panel
Links
Related Links with FCCamera
Discussion Forum MACRO:Work Feature 2014_12
Script
Download the icon files FCCamera_Icones.zip
Download the macro to Gist Macro FCCamera.FCMacro
Examples
How to place an angle hole
-
Create your object
-
Select your cylinder for create your hole
-
The cylinder moves to 15 degrees (it takes the camera's position). Do your Boolean operation
-
Your hole 15 degrees
The same result can be achieved by creating a plan in the corner given by the mouse click position and a sketch.
-
example of the positioning of a spring on an axis of a face
-
Example photo rotation and save images (you must create one animate Gif with GIMP)
Version
- ver 0.14 (20/10/2020): correction bug "Grid" not accepted
- ver 0.13 (28/06/2020): adding files image in source code, create plane "On point, Center face, BBox center, Center Mass", gridLayout
- ver 00.12.1 (12/02/2020): suppress the bad character lines 674 and 675 (accent...) again
- ver 12 (01/08/2019): compatible Python 3 ( print to print() )
- ver 11 (13/01/2018): minor
- ver 10 (13/01/2018): add "def centerBoundBoxGlobal():"
- ver 09 (08/01/2018): minor
- ver 08 (08/01/2018): supp "Pyqt4" and adjust number image
- ver 07 (03/01/2018): add photo panel and rotation to axis selected (wire, edge, line )
- ver 0.6 (13/12/2016): new system for search the macro path directly in the preferences
#path = FreeCAD.ConfigGet("AppHomePath") #path = FreeCAD.ConfigGet("UserAppData") #path = "your path" param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path path = param.GetString("MacroPath","") + "/" # macro path path = path.replace("\\","/") App.Console.PrintMessage("Path locality to FCCamera.....images.png [ " + path + " ]"+"\n")
- ver 0.5 06/09/2016: correct name "FCCamera_Axis_rotation_X.png" in reset block
- ver 0.4 28/02/2016 : add display all camera detection and the Direction
- ver 0.3 18/03/2015 : modify line 492 replace "pl.Base = App.Vector(0,0,0)" to "pl.Base = sel[0].Placement.Base" now no longer moves the form at point (0,0,0) and leaves has the coordinates
- ver 0.2 25/02/2015 : correct names files in for compatibility Linux (case sensitive) thanks microelly2