Skip to content

Instantly share code, notes, and snippets.

@mario52a
Last active June 26, 2023 21:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mario52a/61571ce0bd41af0471995df7c3ea855f to your computer and use it in GitHub Desktop.
Save mario52a/61571ce0bd41af0471995df7c3ea855f to your computer and use it in GitHub Desktop.
This macro allows to save the 3D view in the desired format. The 3D view or the full 3D window of FreeCAD takes the desired dimensions. A rotation of the selected object or of the 3D view is possible to give a rotation angle the number of images is calculated automatically it is possible to give a departure angle and an arrival angle. You must u…
# -*- coding: utf-8 -*-
"""
***************************************************************************
* Copyright (c) 2019 2020 2021 2022 2023 <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. *
** **
* Use at your own risk. The author assumes no liability for data loss. *
* It is advised to backup your data frequently. *
* If you do not trust the software do not use it. *
** **
* 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 *
***************************************************************************
"""
## http://forum.freecadweb.org/viewtopic.php?f=22&t=9295 # piffpoof code
## http://forum.freecadweb.org/viewtopic.php?f=22&t=10488 # microelly2 code
## http://forum.freecadweb.org/viewtopic.php?f=22&t=19620 # microelly2 code
## https://forum.freecadweb.org/viewtopic.php?f=22&t=10157 # wmayer code
##
#Macro_Screen_Wiki 10/03/2019, 2020/03/21, 2020/05/04, 2020/10/29, 2021/01/13, 2021/05/21, 26/06/2023
#
#OS: Windows 10 build 19045 #OS: Linux Mint 20.1 (X-Cinnamon/cinnamon)
#Word size of FreeCAD: 64-bit #Word size of FreeCAD: 64-bit
#Version: 0.21.0.33263 (Git) #Version: 0.20.24847 (Git) AppImage
#Build type: Release #Build type: Release
#Branch: master #Branch: master
#Hash: 864f99bf984c237ef38d9451fd6f3a5ec34e6eb4 #Hash: 20e756306d9aa624fcbf465f0345d721673ce720
#Python 3.10.11, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3 #Python version: 3.9.2
#Qt version: 5.12.9
#Coin version: 4.0.0
#OCC version: 7.5.1
#Locale: French/Mars (fr_MA) #Locale: French/Mars (fr_MA)
#
__title__ = "Screen_Wiki"
__author__ = "Mario52"
__url__ = "https://forum.freecadweb.org/index.php"
__Wiki__ = "https://wiki.freecadweb.org/index.php?title=Macro_Screen_Wiki" #Macro_Screen_Wiki
__Forum__ = "https://forum.freecad.org/viewtopic.php?t=50457" #Screen_Wiki macro
__version__ = "00.06b"
__date__ = "2023/06/27" #YYYY/MM/DD
import PySide2
from PySide2 import (QtWidgets, QtCore, QtGui)
from PySide2.QtWidgets import (QWidget, QApplication, QSlider, QGraphicsView, QGraphicsScene, QVBoxLayout, QStyle, QDockWidget, QToolBar, QDialog)
from PySide2.QtGui import (QPainter, QColor, QIcon)
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtSvg import *
import PySide2.QtXml
from PySide2 import QtOpenGL
from PySide2.QtOpenGL import *
import pivy
from pivy import coin
import time, math
import FreeCADGui, FreeCAD
import os
import os.path
import Draft
##############################################
global path
#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 for the icons : " + path + "\n")
##############################################
#####################################################################################################
#global testing ; testing = 3 # if testing == 1 MainWindow separate
# # if testing == 2 RightDock
# # else == other LeftDock
#####################################################################################################
Gui = FreeCADGui
App = FreeCAD
global ui ; ui = ""
global so ; so = ""
global sel ; sel = ""
global pathFile ; pathFile = ""
global mainWindowCoinSupX ; mainWindowCoinSupX = 0 # depart coin gauche X
global mainWindowCoinSupY ; mainWindowCoinSupY = 0 # depart coin gauche Y
global originalState ; originalState = "" # etat original en entree
global switchMainWindow ; switchMainWindow = 0 # switch wainWindowFC
global ecranCompletX ; ecranCompletX = 0 # ecran Complet X
global ecranCompletY ; ecranCompletY = 0 # ecran Complet Y
global parameterBackground ; parameterBackground = "" # pour couleur de fond
global pos_X_Tile_Window ; pos_X_Tile_Window = 0 # Position fenetre Tile
global pos_Y_Tile_Window ; pos_Y_Tile_Window = 0 # Position fenetre Tile
global counterName ; counterName = 0 # compteur pour Follow
global switchFollow ; switchFollow = 0 # switch Follow/New
global SaveName ; SaveName = ""
global SaveNameMemo ; SaveNameMemo = ""
global neutralImage ; neutralImage = 0 # switch nom neutre
global switchToolBarActived ; switchToolBarActived = 0 # switch toolBar actived
global switchRunning ; switchRunning = 0 # switch macro running
global switchTitleBoxToolBar; switchTitleBoxToolBar= 0 # switch Title Box of ToolBar
global switchMini ; switchMini = 0 # switch Mini toolBar
#### section Rotation
global dim_Horizont ; dim_Horizont = 0
global dim_Vertical ; dim_Vertical = 0
global formatFichier ; formatFichier = 0
global axis ; axis = "X"
global ctPoint ; ctPoint = ""
global itemctPoint ; itemctPoint = ""
global switch_Create_Point ; switch_Create_Point = True
global switchValue ; switchValue = False
global valeurAngle ; valeurAngle = 0.0
global delayTime ; delayTime = 0.0
global beginRotation ; beginRotation = 0.0
global endRotation ; endRotation = 360.0
global angleRotation ; angleRotation = 0.0
global numberPhoto ; numberPhoto = 0.0 # float convert in int() after calcul
global switchTestRotation ; switchTestRotation = False
global degreesNumberDecimal #; degreesNumberDecimal = 4
degreesNumberDecimal = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("degreesNumberDecimal", 4) # degreesNumberDecimal
###Config begin##############################################
global pos_X_Window; pos_X_Window = 0 # Position begin X window
global pos_Y_Window; pos_Y_Window = 0 # Position begin Y window
###Config end##############################################
miniMaxiIcon = [
"24 24 7 1",
" c None",
". c #01040C",
"+ c #000A0B",
"@ c #CC0000",
"# c #71A0CF",
"$ c #18CFD1",
"% c #BABDB6",
" ",
" @@@@@@@@@@@@@@@@@@ ",
" @++++++++++++++++@ ",
" @+##############+@% ",
"%%+++#++#+#######+@% ",
"%%+##############+@% ",
" @++++++#########+@% ",
" @+##############+@% ",
" @++#++++#++#####+@% ",
" @+##############+@% ",
" @++++++#########+@% ",
" @+##############+@% ",
" @+++++##########+@% ",
" @+###########%##%%% % ",
" @++++#+#####@%@@%%@@%@ ",
" @+##########@........@ ",
"%%+++#++++###@.$$$$$$.@%",
"%%+##########@...$.$$.@%",
" @+##########@.$$$$$$.@%",
" @+++++++++++@..$.$$$.@%",
" @@@@@@@@@@@@@.$$$$$$.@%",
" %%%%%%%%%%%@........@%",
" @@@@@@@@@@%",
" %%%%%%%%%"]
miniToolBarIcon = [
"24 24 9 1",
" c None",
". c #8D0401",
"+ c #4F514F",
"@ c #355799",
"# c #365F8E",
"$ c #929491",
"% c #A4B0BE",
"& c #D5D7D4",
"* c #F6F4F2",
" ",
" ",
" ",
" $$$$$$$$$$$$$$$$$$$$ ",
" $%%%%%%%%%%%%%%%%%*$ ",
" ...................... ",
" .@***@****@***@***@**. ",
" .@***@****@***@***@**. ",
" ...................... ",
" &############@@@@%&$ ",
" &############@@@@%&$ ",
" &############@@@@%&$ ",
" &#########@@@@@@@%&$ ",
" &@@@@@@@@@@@@@@@@%&$ ",
" &@@@@@@@@@@@@@@@@%&$ ",
" &@@@@@@@@@@@@@@@@%&$ ",
" &%%%%%%%%%%%%%%%%%&$ ",
" &&&&&&&&&&&&&&&&&&&$ ",
" ++++++++++++++&+&+&$ ",
" ++++++++ ",
" +$$%%$%$$+ ",
" +$$$$$$$$+ ",
" ++++++++ ",
" "]
newImageIcon = [
"24 24 9 1",
" c None",
". c #154A89",
"+ c #235C19",
"@ c #4B9414",
"# c #61B600",
"$ c #C3A000",
"% c #6CC118",
"& c #82DB32",
"* c #FDFFFC",
" ",
" ...................... ",
" . $ $ . ",
" .$$$ $ $ . ",
" .$ $$ $ . ",
" . $ $ . ",
" .$$$ $ . ",
" . $ $ @@ @@ @@ . ",
" . $ $ @&%&&%&@ . ",
" . @&&%&&%&&@ . ",
" . @&&&&&&&&@ . ",
" . @&&&&&&&&@ . ",
" . #&&&&&&% . ",
" . + @#&&&&#@ ++ . ",
" . @& +@&+ @@ . ",
" . @%& @& &&@ . ",
" . @%%& @& &%&@ . ",
" . @%%%& @& &%%&@ . ",
" . @&%%& @&&%%&@@ . ",
" . @&&& @@&&&@@ . ",
" . @@@ @@@@@ . ",
" . . ",
" ...................... ",
" "]
import WebGui
#WebGui.openBrowser("https://forum.freecadweb.org/index.php")
#### Detect version macro ###########################################
global switchVesionMacroSearch#; switchVesionMacroSearch = False
try:
def vesionSearch():
import requests
contentPage = requests.get("https://wiki.freecadweb.org/Macro_" + __title__).text
for i in contentPage.split("\n"): # list page to line
if "ctEven macro-version" in i:
versionDetect = (i.split(">")[1])
if "ctEven macro-date" in i:
dateDetect = (i.split(">")[1])
try:
if (len(versionDetect) != 0) and (len(dateDetect) != 0):
break
except Exception:
None
try:
if (versionDetect == __version__) and (dateDetect == __date__):
None
else:
msg = ("New version availlable : " + "\n" +
str(versionDetect) + ":" + str(dateDetect) + "\n" +
"You can install with AddonManager")
FreeCAD.Console.PrintMessage("your actual version : " + str(__version__) + " : " + str(__date__) + "\n")
FreeCAD.Console.PrintMessage("new version availlable : " + str(versionDetect) + " : " + str(dateDetect) + "\n")
diag = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Information, 'New Version', msg)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
except Exception:
None
return versionDetect, dateDetect
switchVesionMacroSearch = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchVesionMacroSearch")
if switchVesionMacroSearch == 0:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchVesionMacroSearch", switchVesionMacroSearch)
if switchVesionMacroSearch == True:
vesionSearch()
except Exception:
FreeCAD.Console.PrintMessage("Failed to establish a connection or..." + "\n")
#### Detect version macro ###########################################
#def errorDialog(msg):
# diag = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical,u"Error FreeCAD Version",msg )
# diag.setWindowFlags(PySide2.QtCore.Qt.WindowStaysOnTopHint) # PySide #cette fonction met la fenetre en avant
# diag.setStyleSheet("QLabel {color : #ffffff; background-color : #FF3300; font: bold}")
# diag.exec_()
# diag.setStyleSheet("QLabel {Base}")
#if int(FreeCAD.Version()[1]) < 19: # Version de FreeCAD
# errorDialog("\n" + "This macro work only with FreeCAD 0.19 +" + "\n"
# "The image saved with other version give Black image" + "\n")
####
global switchQFileDialogMint
switchQFileDialogMint = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchQFileDialogMint")
if switchQFileDialogMint == 0:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchQFileDialogMint", switchQFileDialogMint)
try:
if os.uname()[1] == "mint":
switchQFileDialogMint = 1
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchQFileDialogMint", switchQFileDialogMint)
except Exception:
None
global switchAppConsolePrintMessage
switchAppConsolePrintMessage = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchAppConsolePrintMessage")
if switchAppConsolePrintMessage == 0:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchAppConsolePrintMessage", switchAppConsolePrintMessage)
def AppConsolePrintMessage(text):
global switchAppConsolePrintMessage
if switchAppConsolePrintMessage == True:
App.Console.PrintMessage(text)
####
global switchAppConsolePrintError
switchAppConsolePrintError = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchAppConsolePrintError")
if switchAppConsolePrintError == 0:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchAppConsolePrintError", switchAppConsolePrintError)
def AppConsolePrintError(text):
global switchAppConsolePrintError
if switchAppConsolePrintError == True:
App.Console.PrintError(text)
####
class Ui_MainWindow(object):
def __init__(self, MainWindow):
global path
global pathFile
self.window = MainWindow
self.PointSize = 8 #heigth text
####
self.Color = ""
self.Length = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("setLengthImage")
if self.Length == 0:
self.Length = 640
self.Heigth = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetInt("setHeigthImage")
if self.Heigth == 0:
self.Heigth = 480
self.path = path
def setupUi(self, MainWindow):
self.window = MainWindow
global sel
global delayTime
global beginRotation
global endRotation
global angleRotation
global ui
#MainWindow.setObjectName("MainWindow")
# MainWindow.setMinimumSize(QtCore.QSize(295, 600))
MainWindow.resize(295, 600)
# MainWindow.setMinimumSize(QtCore.QSize(295, 680))
# MainWindow.resize(295, 680)
## MainWindow.setGeometry(0, 0, 295, 680) # demarrage sans rotation x0 y0
## MainWindow.resize(590, 680) # demarrage avec Rotation
## MainWindow.move(1150, 100) # position window dans l ecran
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.groupBox_img_01_definition = QtWidgets.QGroupBox()
self.RD_01_400x200 = QtWidgets.QRadioButton()
self.RD_01_400x200.clicked.connect(self.on_radioButton_Config)
self.RD_02_600x400 = QtWidgets.QRadioButton()
# self.RD_02_600x400.setEnabled(True)
# self.RD_02_600x400.setChecked(True)
self.RD_02_600x400.clicked.connect(self.on_radioButton_Config)
self.RD_03_1024x768 = QtWidgets.QRadioButton()
self.RD_03_1024x768.clicked.connect(self.on_radioButton_Config)
self.RD_04_320x240 = QtWidgets.QRadioButton()
self.RD_04_320x240.clicked.connect(self.on_radioButton_Config)
self.RD_05_320x480 = QtWidgets.QRadioButton()
self.RD_05_320x480.clicked.connect(self.on_radioButton_Config)
self.RD_06_400x300 = QtWidgets.QRadioButton()
self.RD_06_400x300.clicked.connect(self.on_radioButton_Config)
self.RD_07_480x360 = QtWidgets.QRadioButton()
self.RD_07_480x360.clicked.connect(self.on_radioButton_Config)
self.RD_08_640x480 = QtWidgets.QRadioButton()
self.RD_08_640x480.clicked.connect(self.on_radioButton_Config)
self.RD_09_768x576 = QtWidgets.QRadioButton()
self.RD_09_768x576.clicked.connect(self.on_radioButton_Config)
self.RD_10_800x600 = QtWidgets.QRadioButton()
self.RD_10_800x600.clicked.connect(self.on_radioButton_Config)
self.RD_11_960x720 = QtWidgets.QRadioButton()
self.RD_11_960x720.clicked.connect(self.on_radioButton_Config)
self.RD_12_1024x768 = QtWidgets.QRadioButton()
self.RD_12_1024x768.clicked.connect(self.on_radioButton_Config)
self.RD_13_1400x600 = QtWidgets.QRadioButton()
# self.RD_13_1400x600.setChecked(True) # (actif) or False (inactif)
self.RD_13_1400x600.clicked.connect(self.on_radioButton_Config)
self.RD_14_1600x800 = QtWidgets.QRadioButton()
self.RD_14_1600x800.clicked.connect(self.on_radioButton_Config)
####
self.groupBox_img_02_Format = QtWidgets.QGroupBox()
self.LAB_01_Length = QtWidgets.QLabel()
self.LAB_02_Heigth = QtWidgets.QLabel()
self.SPB_01_Length = QtWidgets.QSpinBox()
self.SPB_01_Length.setMinimum(1)
self.SPB_01_Length.setMaximum(9999999)
self.SPB_01_Length.setValue(self.Length)
self.SPB_01_Length.valueChanged.connect(self.on_SPB_01_Length)
self.SPB_02_Heigth = QtWidgets.QSpinBox()
self.SPB_02_Heigth.setMinimum(1)
self.SPB_02_Heigth.setMaximum(9999999)
self.SPB_02_Heigth.setValue(self.Heigth)
self.SPB_02_Heigth.valueChanged.connect(self.on_SPB_02_Heigth)
####
self.groupBox_img_03_Window = QtWidgets.QGroupBox()
self.RD_01_MWindow = QtWidgets.QRadioButton()
self.RD_02_Screen = QtWidgets.QRadioButton()
self.RD_02_Screen.setChecked(True)
####
self.groupBox_img_04_BackGround = QtWidgets.QGroupBox()
self.RB_01_Actual = QtWidgets.QRadioButton()
self.RB_01_Actual.setChecked(True)
self.RB_01_Actual.clicked.connect(self.on_radioButton_FreeCAD)
self.RB_02_Color = QtWidgets.QRadioButton()
self.RB_02_Color.clicked.connect(self.on_radioButton_Color)
self.PB_01_Color = QtWidgets.QPushButton()
self.PB_01_Color.setVisible(False)
self.PB_01_Color.clicked.connect(self.on_PB_01_Color)
self.RB_03_Transparent = QtWidgets.QRadioButton()
self.RB_03_Transparent.clicked.connect(self.on_radioButton_FreeCAD)
self.PB_02_OriginalBaGr = QtWidgets.QPushButton()
self.PB_02_OriginalBaGr.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_BrowserReload))) #
self.PB_02_OriginalBaGr.setVisible(False)
self.PB_02_OriginalBaGr.clicked.connect(self.on_PB_02_OriginalBaGr)
####
self.groupBox_img_05_Command = QtWidgets.QGroupBox()
self.PB_01_SetScreen = QtWidgets.QPushButton()
self.PB_01_SetScreen.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ComputerIcon)))
self.PB_01_SetScreen.clicked.connect(self.on_PB_01_SetScreen)
self.PB_02_SetScreenTile = QtWidgets.QPushButton()
self.PB_02_SetScreenTile.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DesktopIcon)))
self.PB_02_SetScreenTile.clicked.connect(self.on_PB_02_SetScreenTile)
self.PB_03_SaveImage = QtWidgets.QPushButton()
self.PB_03_SaveImage.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton)))
self.PB_03_SaveImage.clicked.connect(self.on_PB_03_SaveImage)
self.PB_03B_Follow = QtWidgets.QPushButton()
self.PB_03B_Follow.setEnabled(False)
self.PB_03B_Follow.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_CommandLink)))
self.PB_03B_Follow.clicked.connect(self.on_PB_03B_Follow)
self.PB_03C_NewImage = QtWidgets.QPushButton()
self.PB_03C_NewImage.setIcon(QtGui.QIcon(QtGui.QPixmap(newImageIcon))) # miniWindowIcon icone dans une variable
self.PB_03C_NewImage.clicked.connect(self.on_PB_03C_New)
self.PB_03D_Mini = QtWidgets.QPushButton()
self.PB_03D_Mini.setIcon(QtGui.QIcon(QtGui.QPixmap(miniMaxiIcon))) # miniMaxiIcon icone dans une variable
self.PB_03D_Mini.setVisible(False)
self.PB_03D_Mini.clicked.connect(self.on_PB_03D_Mini)
self.PB_04_Quit = QtWidgets.QPushButton()
self.PB_04_Quit.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCloseButton)))
self.PB_04_Quit.clicked.connect(self.on_PB_04_Quit)
self.PB_05_Rotation = QtWidgets.QPushButton()
self.PB_05_Rotation.clicked.connect(self.on_PB_05_Rotation)
self.PB_05_Rotation.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogOkButton))) #
self.PB_06_Reduction = QtWidgets.QPushButton()
self.PB_06_Reduction.clicked.connect(self.on_PB_06_Reduction)
self.PB_06_Reduction.setIcon(QtGui.QIcon(QtGui.QPixmap(miniToolBarIcon))) # miniWindowIcon icone dans une variable
self.LAB_Date = QtWidgets.QLabel()
self.frame_Reduction = QtWidgets.QFrame()
self.frame_Reduction.setVisible(False)
self.frame_Reduction.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_Reduction.setFrameShadow(QtWidgets.QFrame.Plain) #.Raised) Sunken
################################
#### section rotation Debut ####
## position modifiee
self.PB_03_Create_Point = QtWidgets.QPushButton()
self.PB_03_Create_Point.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogYesButton))) #
self.PB_03_Create_Point.clicked.connect(self.on_PB_03_Create_Point)
self.PB_Save_Animation = QtWidgets.QPushButton()
self.PB_Save_Animation.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton)))
self.PB_Save_Animation.clicked.connect(self.on_PB_Photo_Rotation_Object_clicked)
## position modifiee
self.groupBox_00_01_00_Rotation = QtWidgets.QGroupBox()
# self.groupBox_00_01_00_Rotation.setVisible(False)
self.groupBox_rot_01_Rotation = QtWidgets.QGroupBox()
self.RB_01_3D_View = QtWidgets.QRadioButton()
self.RB_01_3D_View.setChecked(False)
self.RB_01_3D_View.clicked.connect(self.on_RB_01_3D_View)
self.RB_02_Object = QtWidgets.QRadioButton()
self.RB_02_Object.setChecked(True)
self.RB_02_Object.clicked.connect(self.on_RB_02_Object)
####
self.groupBox_rot_02_Axis = QtWidgets.QGroupBox()
self.RB_01_Rotation_X = QtWidgets.QRadioButton()
self.RB_01_Rotation_X.setChecked(True)
self.RB_01_Rotation_X.clicked.connect(self.on_RB_01_Rotation_X)
self.RB_01_Rotation_X.setStyleSheet("QRadioButton {color : #ff0000; font: bold}")
self.RB_02_Rotation_Y = QtWidgets.QRadioButton()
self.RB_02_Rotation_Y.clicked.connect(self.on_RB_02_Rotation_Y)
self.RB_02_Rotation_Y.setStyleSheet("QRadioButton {color : #008500; font: bold}")
self.RB_03_Rotation_Z = QtWidgets.QRadioButton()
self.RB_03_Rotation_Z.clicked.connect(self.on_RB_03_Rotation_Z)
self.RB_03_Rotation_Z.setStyleSheet("QRadioButton {color : #0000ff; font: bold}")
self.RB_04_Rotation_D = QtWidgets.QRadioButton()
self.RB_04_Rotation_D.clicked.connect(self.on_RB_04_Rotation_D)
self.RB_04_Rotation_D.setStyleSheet("QRadioButton {color : #995500; font: bold}")
####
self.groupBox_rot_03_Point = QtWidgets.QGroupBox()
self.RB_01_CenterObject = QtWidgets.QRadioButton()
self.RB_01_CenterObject.setChecked(True)
#self.RB_01_CenterObject.clicked.connect(self.on_RB_01_CenterObject)
self.RB_02_CenterSubObject = QtWidgets.QRadioButton()
#self.RB_02_CenterSubObject.clicked.connect(self.on_RB_02_CenterSubObject)
####
self.groupBox_rot_04_Angles = QtWidgets.QGroupBox()
self.LAB_01_AngRot = QtWidgets.QLabel()
self.PB_00_Decrement = QtWidgets.QPushButton()
self.PB_00_Decrement.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowDown))) #
self.PB_00_Decrement.clicked.connect(self.on_PB_00_Decrement)
self.SPB_01_Angle_Rotation = QtWidgets.QDoubleSpinBox ()
self.SPB_01_Angle_Rotation.setPrefix("")
self.SPB_01_Angle_Rotation.setDecimals(degreesNumberDecimal)
self.SPB_01_Angle_Rotation.setMaximum(360.0)
self.SPB_01_Angle_Rotation.setMinimum(0.000000001)
#self.SPB_01_Angle_Rotation.setSingleStep(1.0)
#self.SPB_01_Angle_Rotation.setValue(1.0)
self.SPB_01_Angle_Rotation.valueChanged.connect(self.on_SPB_01_Angle_Rotation)
self.PB_00_Increment = QtWidgets.QPushButton()
self.PB_00_Increment.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowUp))) #
self.PB_00_Increment.clicked.connect(self.on_PB_00_Increment)
self.LAB_00_Numb_Image = QtWidgets.QLabel()
self.PB_00_Decrement_Number_Images = QtWidgets.QPushButton()
self.PB_00_Decrement_Number_Images.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowDown))) #
self.PB_00_Decrement_Number_Images.clicked.connect(self.on_PB_00_Decrement_Number_Images)
self.SPB_02_Number_Images = QtWidgets.QSpinBox()
self.SPB_02_Number_Images.setMinimum(1) #1
self.SPB_02_Number_Images.setMaximum(9999999)
#self.SPB_02_Number_Images.setValue()
self.SPB_02_Number_Images.valueChanged.connect(self.on_SPB_02_Number_Images)
self.PB_00_Increment_Number_Images = QtWidgets.QPushButton()
self.PB_00_Increment_Number_Images.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowUp))) #
self.PB_00_Increment_Number_Images.clicked.connect(self.on_PB_00_Increment_Number_Images)
self.LAB_02_BegRot = QtWidgets.QLabel()
self.PB_01_Decrement_DegBeg = QtWidgets.QPushButton()
self.PB_01_Decrement_DegBeg.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowDown))) #
self.PB_01_Decrement_DegBeg.clicked.connect(self.on_PB_01_Decrement_DegBeg)
self.SPB_02_Angle_Begin_Rotation = QtWidgets.QDoubleSpinBox ()
self.SPB_02_Angle_Begin_Rotation.setDecimals(degreesNumberDecimal)
self.SPB_02_Angle_Begin_Rotation.setMaximum(360.0)
self.SPB_02_Angle_Begin_Rotation.setValue(beginRotation)
self.SPB_02_Angle_Begin_Rotation.valueChanged.connect(self.on_SPB_02_Angle_Begin_Rotation)
self.PB_01_Increment_DegBeg = QtWidgets.QPushButton()
self.PB_01_Increment_DegBeg.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowUp))) #
self.PB_01_Increment_DegBeg.clicked.connect(self.on_PB_01_Increment_DegBeg)
self.LAB_03_EndRot = QtWidgets.QLabel()
self.PB_02_Decrement_DegEnd = QtWidgets.QPushButton()
self.PB_02_Decrement_DegEnd.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowDown))) #
self.PB_02_Decrement_DegEnd.clicked.connect(self.on_PB_02_Decrement_DegEnd)
self.SPB_03_Angle_End_Rotation = QtWidgets.QDoubleSpinBox ()
self.SPB_03_Angle_End_Rotation.setDecimals(degreesNumberDecimal)
self.SPB_03_Angle_End_Rotation.setMaximum(360.0)
self.SPB_03_Angle_End_Rotation.setValue(endRotation)
self.SPB_03_Angle_End_Rotation.valueChanged.connect(self.on_SPB_03_Angle_End_Rotation)
self.PB_02_Increment_DegEnd = QtWidgets.QPushButton()
self.PB_02_Increment_DegEnd.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_ArrowUp))) #
self.PB_02_Increment_DegEnd.clicked.connect(self.on_PB_02_Increment_DegEnd)
####
self.groupBox_rot_05_Command_Rotation = QtWidgets.QGroupBox()
self.LAB_Delay = QtWidgets.QLabel(self.groupBox_rot_05_Command_Rotation)
self.DSPB_01_Delay_Time = QtWidgets.QDoubleSpinBox()
self.DSPB_01_Delay_Time.setDecimals(3)
self.DSPB_01_Delay_Time.setMaximum(10000.0)
self.DSPB_01_Delay_Time.setValue(delayTime)
self.DSPB_01_Delay_Time.valueChanged.connect(self.on_DSPB_01_Delay_Time)
self.CB_01_Reverse = QtWidgets.QCheckBox()
self.CB_01_Reverse.clicked.connect(self.on_CB_01_Reverse)
self.CB_02_Original_Position = QtWidgets.QCheckBox()
self.CB_02_Original_Position.setChecked(True)
#self.CB_02_Original_Position.clicked.connect(self.on_CB_02_Original_Position)
self.PB_00_Test_Rotation = QtWidgets.QPushButton()
self.PB_00_Test_Rotation.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_BrowserReload))) #
self.PB_00_Test_Rotation.clicked.connect(self.on_PB_00_Test_Rotation)
#placer plus haut test... self.PB_03_Create_Point = QtWidgets.QPushButton()
#placer plus haut test... self.PB_03_Create_Point.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogYesButton))) #
#placer plus haut test... self.PB_03_Create_Point.clicked.connect(self.on_PB_03_Create_Point)
#placer plus haut test... self.PB_Save_Animation = QtWidgets.QPushButton()
#placer plus haut test... self.PB_Save_Animation.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton)))
#placer plus haut test... self.PB_Save_Animation.clicked.connect(self.on_PB_Photo_Rotation_Object_clicked)
#### section rotation Fin ####
##############################
#### layout debut ##################
#### grid
self.gridLayoutWidget = QtWidgets.QWidget(MainWindow)
self.grid_principal = QtWidgets.QGridLayout(MainWindow)
self.groupBox_00_00_00_Image = QtWidgets.QGroupBox(self.gridLayoutWidget)
self.grid_00_01_00 = QtWidgets.QGridLayout(self.groupBox_00_00_00_Image)
#### Definition
self.grid_00_01_01 = QtWidgets.QGridLayout(self.groupBox_img_01_definition)
self.grid_00_01_01.addWidget(self.RD_04_320x240, 0, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_05_320x480, 0, 1, 1, 1)
self.grid_00_01_01.addWidget(self.RD_01_400x200, 1, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_06_400x300, 1, 1, 1, 1)
self.grid_00_01_01.addWidget(self.RD_07_480x360, 2, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_02_600x400, 2, 1, 1, 1)
self.grid_00_01_01.addWidget(self.RD_08_640x480, 3, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_09_768x576, 3, 1, 1, 1)
self.grid_00_01_01.addWidget(self.RD_10_800x600, 4, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_11_960x720, 4, 1, 1, 1)
self.grid_00_01_01.addWidget(self.RD_03_1024x768, 5, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_12_1024x768, 5, 1, 1, 1)
self.grid_00_01_01.addWidget(self.RD_13_1400x600, 6, 0, 1, 1)
self.grid_00_01_01.addWidget(self.RD_14_1600x800, 6, 1, 1, 1)
self.grid_00_01_00.addWidget(self.groupBox_img_01_definition, 1, 0, 1, 1)
#### Format image
self.grid_00_01_02 = QtWidgets.QGridLayout(self.groupBox_img_02_Format)#
self.grid_00_01_02.addWidget(self.LAB_01_Length, 0, 0, 1, 1)
self.grid_00_01_02.addWidget(self.LAB_02_Heigth, 0, 1, 1, 1)
self.grid_00_01_02.addWidget(self.SPB_01_Length, 1, 0, 1, 1)
self.grid_00_01_02.addWidget(self.SPB_02_Heigth, 1, 1, 1, 1)
self.grid_00_01_00.addWidget(self.groupBox_img_02_Format, 2, 0, 1, 1)
#### Window
self.grid_00_01_03 = QtWidgets.QGridLayout(self.groupBox_img_03_Window)#
self.grid_00_01_03.addWidget(self.RD_01_MWindow, 0, 0, 1, 1)
self.grid_00_01_03.addWidget(self.RD_02_Screen, 0, 1, 1, 1)
self.grid_00_01_00.addWidget(self.groupBox_img_03_Window, 3, 0, 1, 1)
#### BackGround color
self.grid_00_01_04 = QtWidgets.QGridLayout(self.groupBox_img_04_BackGround)#
self.grid_00_01_04.addWidget(self.RB_01_Actual, 0, 0, 1, 1)
self.grid_00_01_04.addWidget(self.RB_02_Color, 0, 1, 1, 1)
self.grid_00_01_04.addWidget(self.RB_03_Transparent, 1, 0, 1, 1)
self.grid_00_01_04.addWidget(self.PB_02_OriginalBaGr, 1, 1, 1, 1)
self.grid_00_01_00.addWidget(self.groupBox_img_04_BackGround, 4, 0, 1, 1)
#### Command
self.grid_00_01_05 = QtWidgets.QGridLayout(self.groupBox_img_05_Command)#
self.grid_00_01_05.addWidget(self.PB_01_SetScreen, 0, 0, 1, 1)
self.grid_00_01_05.addWidget(self.PB_02_SetScreenTile, 0, 1, 1, 1)
self.grid_00_01_05.addWidget(self.PB_03_SaveImage, 1, 0, 1, 1)
self.grid_00_01_05.addWidget(self.PB_03B_Follow, 1, 1, 1, 1)
self.grid_00_01_05.addWidget(self.PB_03C_NewImage, 2, 0, 1, 1)
self.grid_00_01_05.addWidget(self.PB_05_Rotation, 2, 1, 1, 1)
# self.grid_00_01_05.addWidget(self.LAB_Date, 3, 0, 1, 1)
self.grid_00_01_05.addWidget(self.PB_04_Quit, 3, 0, 1, 1)
self.grid_00_01_05.addWidget(self.PB_06_Reduction, 3, 1, 1, 1)
self.grid_00_01_00.addWidget(self.groupBox_img_05_Command, 5, 0, 1, 1)
####
#### Rotation
self.grid_principal.addWidget(self.groupBox_00_01_00_Rotation, 0, 1, 1, 1)
self.grid_principal.addWidget(self.groupBox_00_00_00_Image, 0, 0, 1, 1)
self.grid_00_02_00 = QtWidgets.QGridLayout(self.groupBox_00_01_00_Rotation)
#### Rotation on
self.grid_00_02_01 = QtWidgets.QGridLayout(self.groupBox_rot_01_Rotation)
self.grid_00_02_01.addWidget(self.RB_01_3D_View, 0, 0, 1, 1)
self.grid_00_02_01.addWidget(self.RB_02_Object, 0, 1, 1, 1)
self.grid_00_02_00.addWidget(self.groupBox_rot_01_Rotation, 0, 0, 1, 1)
#### Axis
self.grid_00_02_02 = QtWidgets.QGridLayout(self.groupBox_rot_02_Axis)
self.grid_00_02_02.addWidget(self.RB_01_Rotation_X, 0, 0, 1, 1)
self.grid_00_02_02.addWidget(self.RB_02_Rotation_Y, 0, 1, 1, 1)
self.grid_00_02_02.addWidget(self.RB_03_Rotation_Z, 0, 2, 1, 1)
self.grid_00_02_02.addWidget(self.RB_04_Rotation_D, 0, 3, 1, 1)
self.grid_00_02_00.addWidget(self.groupBox_rot_02_Axis, 1, 0, 1, 1)
#### Point Rotation BoundBox
self.grid_00_02_03 = QtWidgets.QGridLayout(self.groupBox_rot_03_Point)
self.grid_00_02_03.addWidget(self.RB_01_CenterObject, 0, 0, 1, 1)
self.grid_00_02_03.addWidget(self.RB_02_CenterSubObject, 0, 1, 1, 1)
self.grid_00_02_00.addWidget(self.groupBox_rot_03_Point, 2, 0, 1, 1)
#### Angles
self.grid_00_02_04 = QtWidgets.QGridLayout(self.groupBox_rot_04_Angles)
self.grid_00_02_04.addWidget(self.LAB_01_AngRot, 0, 0, 1, 3)
self.grid_00_02_04.addWidget(self.PB_00_Decrement, 1, 0, 1, 1)
self.grid_00_02_04.addWidget(self.SPB_01_Angle_Rotation, 1, 1, 1, 1)
self.grid_00_02_04.addWidget(self.PB_00_Increment, 1, 2, 1, 1)
self.grid_00_02_04.addWidget(self.LAB_00_Numb_Image, 2, 0, 1, 1)
self.grid_00_02_04.addWidget(self.PB_00_Decrement_Number_Images, 3, 0, 1, 1)
self.grid_00_02_04.addWidget(self.SPB_02_Number_Images, 3, 1, 1, 1)
self.grid_00_02_04.addWidget(self.PB_00_Increment_Number_Images, 3, 2, 1, 1)
self.grid_00_02_04.addWidget(self.LAB_02_BegRot, 4, 0, 1, 3)
self.grid_00_02_04.addWidget(self.PB_01_Decrement_DegBeg, 5, 0, 1, 1)
self.grid_00_02_04.addWidget(self.SPB_02_Angle_Begin_Rotation, 5, 1, 1, 1)
self.grid_00_02_04.addWidget(self.PB_01_Increment_DegBeg, 5, 2, 1, 1)
self.grid_00_02_04.addWidget(self.LAB_03_EndRot, 6, 0, 1, 3)
self.grid_00_02_04.addWidget(self.PB_02_Decrement_DegEnd, 7, 0, 1, 1)
self.grid_00_02_04.addWidget(self.SPB_03_Angle_End_Rotation, 7, 1, 1, 1)
self.grid_00_02_04.addWidget(self.PB_02_Increment_DegEnd, 7, 2, 1, 1)
self.grid_00_02_00.addWidget(self.groupBox_rot_04_Angles, 3, 0, 1, 1)
#### Command
self.grid_00_02_05 = QtWidgets.QGridLayout(self.groupBox_rot_05_Command_Rotation)
self.grid_00_02_05.addWidget(self.LAB_Delay, 0, 0, 1, 2)
self.grid_00_02_05.addWidget(self.DSPB_01_Delay_Time, 1, 0, 1, 2)
self.grid_00_02_05.addWidget(self.CB_01_Reverse, 2, 0, 1, 1)
self.grid_00_02_05.addWidget(self.PB_03_Create_Point, 2, 1, 1, 1)
self.grid_00_02_05.addWidget(self.CB_02_Original_Position, 3, 0, 1, 1)
self.grid_00_02_05.addWidget(self.PB_00_Test_Rotation, 3, 1, 1, 1)
self.grid_00_02_05.addWidget(self.PB_Save_Animation, 4, 0, 1, 2)
self.grid_00_02_00.addWidget(self.groupBox_rot_05_Command_Rotation, 4, 0, 1, 1)
####
#### layout fin ##################
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle( __title__) #+" ("+__version__+", "+__date__+")")
MainWindow.setWindowIcon(QtGui.QIcon(self.path+"Macro_Screen_Wiki.png")) # change l'icone de la fenetre principale
MainWindow.setWindowFlags(PySide2.QtCore.Qt.WindowStaysOnTopHint) # PySide2 cette fonction met la fenetre en avant
self.groupBox_00_00_00_Image.setTitle(u"Image options" + " (Ver rmu : " + __version__ + " : " + __date__ + ")")
self.groupBox_img_01_definition.setTitle(u"Definition :")
self.groupBox_img_01_definition.setToolTip(u"Other standard Definition" + "\n" +
u"_________________________" + "\n" +
u"Icon" + "\t" + "16 x 16" + "\n" +
u"Icon" + "\t" + "32 x 32" + "\n" +
u"Icon" + "\t" + "64 x 64" + "\n" +
u"Icon" + "\t" + "128 x 128" + "\n" +
u"CGA" + "\t" + "320 x 200" + "\n" +
u"XGA+" + "\t" + "1152 x 864" + "\n" +
u"SXGA" + "\t" + "1280 x 1024" + "\n" +
u"SXGA+" + "\t" + "1400 x 1050" + "\n" +
u"UXGA" + "\t" + "1600 x 1200" + "\n" +
u"QXGA" + "\t" + "2048 x 1536")
self.RD_01_400x200.setText(u"400 x 200")
self.RD_02_600x400.setText(u"600 x 400")
self.RD_03_1024x768.setText(u"1024 x 768")
self.RD_04_320x240.setText(u"320 x 240 (QVGA)")
self.RD_05_320x480.setText(u"320 x 480 (HVGA)")
self.RD_06_400x300.setText(u"400 x 300")
self.RD_07_480x360.setText(u"480 x 360")
self.RD_08_640x480.setText(u"640 x 480 (VGA)")
self.RD_09_768x576.setText(u"768 x 576 (PAL)")
self.RD_10_800x600.setText(u"800 x 600 (SVGA)")
self.RD_11_960x720.setText(u"960 x 720")
self.RD_12_1024x768.setText(u"1024 x 768 (XGA)")
self.RD_13_1400x600.setText(u"1400 x 600")
self.RD_14_1600x800.setText(u"1600 x 800")
self.groupBox_img_02_Format.setTitle(u"Format image :")
self.LAB_01_Length.setText(u"Length")
self.SPB_01_Length.setSuffix(u" Length px")
self.LAB_02_Heigth.setText(u"Height")
self.SPB_02_Heigth.setSuffix(u" Heigth px")
self.groupBox_img_03_Window.setTitle(u"Window :")
# self.groupBox_img_03_Window.setToolTip("Choice:" + "\n" +
# "_______" + "\n" +
# "Window FreeCAD" + "\n" +
# "Window Vieuw 3D")
self.RD_01_MWindow.setText(u"Window FC")
self.RD_01_MWindow.setToolTip(u"Window FreeCAD complete" + "\n" +
u"The dimension of small screen can be influenced" + "\n" +
u"by the presence of Python console, Report view")
self.RD_02_Screen.setText(u"Screen 3D")
self.RD_02_Screen.setToolTip(u"Window View 3D active" + "\n" +
u"or sub Window active")
self.groupBox_img_04_BackGround.setTitle(u"BackGround Color :")
self.RB_01_Actual.setText(u"Current")
self.RB_01_Actual.setToolTip(u"BackGround image color Current color")
self.RB_02_Color.setText(u"Color")
self.RB_02_Color.setToolTip(u"BackGround Color a choice." + "\n" +
u"Standard Color Tango")
self.RB_03_Transparent.setText(u"Transparent")
self.RB_03_Transparent.setToolTip(u"BackGround image color Transparent")
# self.PB_01_Color.setToolTip(u"Color a choice" + "\n" +
# u"Tango line")
self.PB_02_OriginalBaGr.setText(u"Restore")
self.PB_02_OriginalBaGr.setToolTip(u"Restore the original BackGround")
self.groupBox_img_05_Command.setTitle(u"Command :")
self.PB_01_SetScreen.setText(u"Set Screen")
self.PB_01_SetScreen.setToolTip(u"Set Screen" + "\n" + "This mode reflect the exact image that will be saved")
self.PB_02_SetScreenTile.setText(u"Tile Screen")
self.PB_02_SetScreenTile.setToolTip(u"Tile Screen" + "\n" +
u"If you work with this mode," + "\n" +
u"visualise the window with Set Screen" + "\n" +
u"for visualise the exact image saved" + "\n" + "\n" +
u"PS: If the screen is too small" + "\n" +
u"the definition can be modified if moving the window" + "\n" +
u"ex: (400 x 200 modified on 413 x 333)")
self.PB_03_SaveImage.setText(u"Save Image")
self.PB_03_SaveImage.setToolTip(u"Save Image with number begin to 0 in format _000." + "\n"
u"This button adding always the number." + "\n"
u"A follow-up can be done with the follow button")
self.PB_03B_Follow.setText(u"Follow")
self.PB_03B_Follow.setToolTip(u"If you desire create many view with the same name" + "\n"
u"the counter increment the saved image" + "\n"
u"and the number images saved hare displayed in the button")
self.PB_03C_NewImage.setText(u"New Image") # Single
self.PB_03C_NewImage.setToolTip(u"Save the image without number")
self.PB_03D_Mini.setText(u"Mini") # MiniToolBar
self.PB_03D_Mini.setToolTip(u"Minimize toolBar")
self.PB_04_Quit.setText(u"Quit")
self.PB_04_Quit.setToolTip(u"Quit ScreenWindowWiki Ciao")
self.PB_05_Rotation.setText(u"Rotation")
self.PB_05_Rotation.setToolTip(u"Go to rotation menu")
self.PB_06_Reduction.setText(u"ToolBar")
self.PB_06_Reduction.setToolTip(u"Go to minimise the macro window in a ToolBar" + "\n"
u"The rotation option is inaccessible in this mode")
#### section rotation
self.groupBox_00_01_00_Rotation.setTitle(u"Rotation ")
self.groupBox_00_01_00_Rotation.setVisible(False)
self.groupBox_rot_01_Rotation.setTitle(u"Rotation on : ")
self.RB_01_3D_View.setText(u"3D View")
self.RB_01_3D_View.setToolTip(u"The 3D view is rotate")
self.RB_02_Object.setText(u"Object")
self.RB_02_Object.setToolTip(u"Object to rotate")
self.groupBox_rot_02_Axis.setTitle(u"Axis :")
self.RB_01_Rotation_X.setText(u"X")
self.RB_01_Rotation_X.setToolTip(u"Rotation on X axis")
self.RB_02_Rotation_Y.setText(u"Y")
self.RB_02_Rotation_Y.setToolTip(u"Rotation on Y axis")
self.RB_03_Rotation_Z.setText(u"Z")
self.RB_03_Rotation_Z.setToolTip(u"Rotation on Z axis")
self.RB_04_Rotation_D.setText(u"Dir.")
self.RB_04_Rotation_D.setToolTip(u"\n" + "Rotation on Direction axis"
u"The direction is a wire, line, edge" + "\n"
u"For use this option 2 selections are request" + "\n"
u"first the object to rotate, second the direction axis" + "\n"
u"If not direction given, the direction is Vector(0, 0, 0)")
self.groupBox_rot_03_Point.setTitle(u"Point Rotation BoundBox :")
self.RB_01_CenterObject.setText(u"Object")
self.RB_01_CenterObject.setToolTip(u"The point rotation is the BoundBox center of the object")
self.RB_02_CenterSubObject.setText(u"Sub Object")
self.RB_02_CenterSubObject.setToolTip(u"The point rotation is the BoundBox center of the Subobject")
self.groupBox_rot_04_Angles.setTitle(u"Angles :")
self.LAB_01_AngRot.setText(u"Angle Rotation")
self.PB_00_Decrement.setText(u"-")
self.PB_00_Increment.setText(u"+")
self.SPB_01_Angle_Rotation.setSuffix(u" Degrees")
self.SPB_01_Angle_Rotation.setToolTip(u"Give the angle of rotation of the object" + "\n"
u"The - and + button increment the value by step 10 degrees")
self.LAB_00_Numb_Image.setText(u"Number images")
self.PB_00_Decrement_Number_Images.setText(u"-")
self.PB_00_Increment_Number_Images.setText(u"+")
self.SPB_02_Number_Images.setSuffix(u" Images (+1)")
self.SPB_02_Number_Images.setToolTip(u"Number of images + 1)")
self.LAB_02_BegRot.setText(u"Angle Begin Rotation")
self.PB_01_Decrement_DegBeg.setText(u"-")
self.PB_01_Increment_DegBeg.setText(u"+")
self.SPB_02_Angle_Begin_Rotation.setSuffix(u" Degrees")
self.SPB_02_Angle_Begin_Rotation.setToolTip(u"The begin angle rotation" + "\n"
u"The - and + button increment the value by step 10 degrees")
self.LAB_03_EndRot.setText(u"Angle End Rotation")
self.PB_02_Decrement_DegEnd.setText(u"-")
self.PB_02_Increment_DegEnd.setText(u"+")
self.SPB_03_Angle_End_Rotation.setSuffix(u" Degrees")
self.SPB_03_Angle_End_Rotation.setToolTip(u"The end angle rotation" + "\n"
u"The - and + button increment the value by step 10 degrees")
self.groupBox_rot_05_Command_Rotation.setTitle(u"Command :")
self.LAB_Delay.setText(u"Delay betwen 2 images")
self.DSPB_01_Delay_Time.setSuffix(u" Delay second")
self.DSPB_01_Delay_Time.setToolTip(u"If you have a problem for save your rotation (too fast)" + "\n"
u"give a delay for write the images")
self.CB_01_Reverse.setText(u"Reverse")
self.CB_01_Reverse.setToolTip(u"Check this checkBox for reverse the rotation")
self.PB_03_Create_Point.setText(u"Point center")
self.PB_03_Create_Point.setToolTip(u"Visualize the point center of rotation" + "\n"
u"If the point is visible the point is include in the image" + "\n"
u"Actual : x:" + str("0") + ", y:" + str("0") + ", z:" + str("0") + "\n" + "\n"
u"PS: the point can be hidden by an object")
self.CB_02_Original_Position.setText(u"Original position")
self.CB_02_Original_Position.setToolTip(u"The object or the screen return in original position" + "\n"
u"case the rotation is not complete")
self.PB_00_Test_Rotation.setText(u"Test Rot.")
self.PB_00_Test_Rotation.setToolTip(u"Testing the rotation without saving images")
self.PB_Save_Animation.setText(u"Save the animation")
self.PB_Save_Animation.setToolTip(u"Launch the animation" + "\n"
u"The name is saved as is : MyName_Animate_035_Z_340-0200_Current.png" + "\n"
u"MyName_\t: file name" + "\n"
u"Animate_\t: serial images for animation" + "\n"
u"035_\t\t: number of image" + "\n"
u"Z_\t\t: axis of rotation" + "\n"
u"340-\t\t: angle of rotation of the image" + "\n"
u"0200_\t\t: angle decimal degrees" + "\n"
u"Current\t\t: screen backGround, (Current, Color, Transparent)" + "\n"
u".png\t\t: extension request")
########
def on_RB_01_Rotation_X(self): #
global axis
axis = "X"
def on_RB_02_Rotation_Y(self): #
global axis
axis = "Y"
def on_RB_03_Rotation_Z(self): #
global axis
axis = "Z"
def on_RB_04_Rotation_D(self): #
global axis
axis = "D"
def formuleNumberPhoto(self):
global beginRotation
global endRotation
global valeurAngle
global numberPhoto
global parcours
global switchValue
self.SPB_01_Angle_Rotation.setValue(valeurAngle)
if (valeurAngle != 0) or (switchValue == True):
self.PB_00_Decrement.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
self.PB_00_Increment.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
if switchValue == True:
parcours = (endRotation - beginRotation)
valeurAngle = parcours / numberPhoto
self.SPB_01_Angle_Rotation.setValue(valeurAngle)
else:
parcours = (endRotation - beginRotation)
numberPhoto = int((parcours / valeurAngle) + 1)
switchValue = False
self.SPB_02_Number_Images.setValue(numberPhoto)
else:
self.PB_00_Decrement.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white; border:2px solid rgb(10, 215, 22)};")# bord white and green
self.PB_00_Increment.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and red
if endRotation == beginRotation:
# self.groupBox_rot_04_Angles.setStyleSheet("QGroupBox {color : #ffff00; background-color: #F66961 ; font: bold 10px};")
if endRotation == 0:
self.PB_01_Decrement_DegBeg.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.SPB_02_Angle_Begin_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and green
self.SPB_02_Angle_Begin_Rotation.setEnabled(False)
self.PB_01_Increment_DegBeg.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.PB_02_Decrement_DegEnd.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.SPB_03_Angle_End_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and green
self.PB_02_Increment_DegEnd.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and green
else:
self.PB_01_Decrement_DegBeg.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and green
self.SPB_02_Angle_Begin_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and green
self.SPB_02_Angle_Begin_Rotation.setEnabled(True)
self.PB_01_Increment_DegBeg.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.PB_02_Decrement_DegEnd.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.SPB_03_Angle_End_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and green
self.PB_02_Increment_DegEnd.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(10, 215, 22)};") # bord white and green
if endRotation == 360:
self.PB_02_Increment_DegEnd.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
self.PB_Save_Animation.setEnabled(False)
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
#print("endRotation 1")
else:
# self.groupBox_rot_04_Angles.setStyleSheet("QGroupBox {background-color: QPalette.Base}")
if beginRotation == 0:
self.PB_01_Decrement_DegBeg.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and green
# self.PB_01_Increment_DegBeg.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and red
else:
self.PB_01_Decrement_DegBeg.setStyleSheet("QPushButton {background-color: QPalette.Base}")
# self.PB_01_Increment_DegBeg.setStyleSheet("QPushButton {background-color: QPalette.Base}")
self.SPB_02_Angle_Begin_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}")
self.SPB_02_Angle_Begin_Rotation.setEnabled(True)
self.PB_01_Increment_DegBeg.setStyleSheet("QPushButton {background-color: QPalette.Base}")
self.PB_02_Decrement_DegEnd.setStyleSheet("QPushButton {background-color: QPalette.Base}")
self.SPB_03_Angle_End_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}")
if endRotation == 360:
self.PB_02_Increment_DegEnd.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and green
else:
self.PB_02_Increment_DegEnd.setStyleSheet("QPushButton {background-color: QPalette.Base}")
self.PB_Save_Animation.setEnabled(True)
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}")
self.groupBox_rot_04_Angles.setGeometry(QtCore.QRect(10, 185, 161, 196))
#### rotation
def on_SPB_01_Angle_Rotation(self, value): #
global valeurAngle
global ui
valeurAngle = value
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.PB_03_Create_Point.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
ui.formuleNumberPhoto()
def on_PB_00_Decrement(self): #
global valeurAngle
global ui
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.PB_03_Create_Point.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
valeurAngle -= 10
if valeurAngle < 0:
valeurAngle = 0
self.SPB_01_Angle_Rotation.setValue(valeurAngle)
ui.formuleNumberPhoto()
def on_PB_00_Increment(self): # angle rotation
global valeurAngle
global ui
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.PB_03_Create_Point.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
valeurAngle += 10
if valeurAngle > 360:
valeurAngle = 360
self.SPB_01_Angle_Rotation.setValue(valeurAngle)
ui.formuleNumberPhoto()
def on_SPB_02_Number_Images(self, value): # nombre d'images
global ui
global valeurAngle
global endRotation
global beginRotation
global parcours
global numberPhoto
global switchValue
numberPhoto = value
switchValue = True
ui.formuleNumberPhoto()
def on_PB_00_Decrement_Number_Images(self): # nombre d'images
global numberPhoto
numberPhoto -= 10+1
if numberPhoto < 1:
numberPhoto = 1
self.SPB_02_Number_Images.setValue(numberPhoto)
ui.formuleNumberPhoto()
def on_PB_00_Increment_Number_Images(self): # nombre d'images
global numberPhoto
numberPhoto += 10-1
self.SPB_02_Number_Images.setValue(numberPhoto)
ui.formuleNumberPhoto()
def on_PB_00_Test_Rotation(self): #
global switchTestRotation
switchTestRotation = True
self.on_PB_Photo_Rotation_Object_clicked()
def on_SPB_02_Angle_Begin_Rotation(self,value): #
global valeurAngle
global beginRotation
global endRotation
beginRotation = value
if beginRotation > endRotation:
beginRotation = value = endRotation
self.SPB_02_Angle_Begin_Rotation.setValue(beginRotation)
ui.formuleNumberPhoto()
def on_PB_01_Decrement_DegBeg(self): #
global valeurAngle
global beginRotation
global endRotation
beginRotation -= 10
if beginRotation > endRotation:
beginRotation = endRotation
if beginRotation < 0:
beginRotation = 0
self.SPB_02_Angle_Begin_Rotation.setValue(beginRotation)
ui.formuleNumberPhoto()
def on_PB_01_Increment_DegBeg(self): #
global valeurAngle
global beginRotation
global endRotation
beginRotation += 10
if beginRotation > endRotation:
beginRotation = endRotation
self.SPB_02_Angle_Begin_Rotation.setValue(beginRotation)
ui.formuleNumberPhoto()
####
def on_SPB_03_Angle_End_Rotation(self,value): #
global valeurAngle
global beginRotation
global endRotation
endRotation = value
if endRotation < beginRotation:
endRotation = value = beginRotation
self.SPB_03_Angle_End_Rotation.setValue(endRotation)
ui.formuleNumberPhoto()
def on_PB_02_Decrement_DegEnd(self): #
global valeurAngle
global beginRotation
global endRotation
endRotation -= 10
if endRotation < beginRotation:
endRotation = beginRotation
if endRotation < 0:
endRotation = 0
self.SPB_03_Angle_End_Rotation.setValue(endRotation)
ui.formuleNumberPhoto()
def on_PB_02_Increment_DegEnd(self): #
global valeurAngle
global beginRotation
global endRotation
endRotation += 10
if endRotation < beginRotation:
endRotation = beginRotation
if endRotation >= 360:
endRotation = 360
# self.SPB_03_Angle_End_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white; border:2px solid rgb(215, 10, 22)};") # bord white and green
# else:
# self.SPB_03_Angle_End_Rotation.setStyleSheet("QDoubleSpinBox {background-color: QPalette.Base}") # origin system
self.SPB_03_Angle_End_Rotation.setValue(endRotation)
ui.formuleNumberPhoto()
####
def on_DSPB_01_Delay_Time(self,value): #
global delayTime
delayTime = value
def on_CB_01_Reverse(self):
if self.CB_01_Reverse.isChecked():
self.CB_01_Reverse.setText(u"Reverse")
else:
self.CB_01_Reverse.setText(u"ClockWise")
def on_PB_03_Create_Point(self): # Create Point for visualize the point XYZ rotation
global ctPoint
global itemctPoint
global switch_Create_Point
pointRotation = ""
self.PB_03_Create_Point.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
if self.RB_01_3D_View.isChecked(): #3DView
cam = ""
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
activeView = FreeCADGui.activeDocument().activeView()
try:
sel = FreeCADGui.Selection.getSelection()
if hasattr(sel[0], "Shape"):
s = sel[0].Shape
elif hasattr(sel[0], "Mesh"): # upgrade with wmayer thanks #http://forum.freecadweb.org/viewtopic.php?f=13&t=22331
s = sel[0].Mesh
elif hasattr(sel[0], "Points"):
s = sel[0].Points
pointRotation = pointRotation2 = s.BoundBox.Center # boundbox center of the object
cam.position.setValue(pointRotation) # boundBox edge selected
except Exception:
#### pas de selection
#https://forum.freecadweb.org/viewtopic.php?f=22&t=10157
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
position = cam.position.getValue()
orient = cam.orientation.getValue()
focalDistance = cam.focalDistance.getValue()
viewdir = coin.SbVec3f(0, 0, -1)
viewdir = orient.multVec(viewdir)
pointRotation = position + viewdir * focalDistance
pointRotation = pointRotation2 = App.Vector(pointRotation.getValue()[0], pointRotation.getValue()[1], pointRotation.getValue()[2])
if (valeurAngle != 0):
try:
sel = FreeCADGui.Selection.getSelection()
if hasattr(sel[0], "Shape"):
objectRotation = Gui.Selection.getSelection()[0] # object of rotation
objectPlacementOrigine = objectRotation.Placement # object Placement Origine
objectPlacementBase = objectRotation.Placement.Base # object Placement Base
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[1] # select one element and axis same object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # select one element and axis same object (1 selection)
except Exception:
None
#### section point rotation
if self.RB_01_CenterObject.isChecked():# and (axis != "D"):
pointRotation = objectRotation.Shape.BoundBox.Center # point rotation single object BoundBox.Center
else:
pointRotation = selectedEdge.BoundBox.Center # point rotation sub object BoundBox.Center
except Exception:
pointRotation = pointRotation2
elif self.RB_02_Object.isChecked(): # Object selected
sel = FreeCADGui.Selection.getSelection()
if len(sel) != 0:
if hasattr(sel[0], "Shape"):
s = sel[0].Shape
elif hasattr(sel[0], "Mesh"): # upgrade with wmayer thanks #http://forum.freecadweb.org/viewtopic.php?f=13&t=22331
s = sel[0].Mesh
elif hasattr(sel[0], "Points"):
s = sel[0].Points
pointRotation = s.BoundBox.Center # boundbox center of the object
if (valeurAngle != 0):
sel = FreeCADGui.Selection.getSelection()
if hasattr(sel[0], "Shape"):
objectRotation = Gui.Selection.getSelection()[0] # object of rotation
objectPlacementOrigine = objectRotation.Placement # object Placement Origine
objectPlacementBase = objectRotation.Placement.Base # object Placement Base
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[1] # select one element and axis same object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # select one element and axis same object (1 selection)
except Exception:
None
#### section point rotation
if self.RB_01_CenterObject.isChecked():# and (axis != "D"):
pointRotation = objectRotation.Shape.BoundBox.Center # point rotation single object BoundBox.Center
else:
pointRotation = selectedEdge.BoundBox.Center # point rotation sub object BoundBox.Center
elif (hasattr(sel[0], "Mesh")) or (hasattr(sel[0], "Points")): # upgrade with wmayer thanks #http://forum.freecadweb.org/viewtopic.php?f=13&t=22331
if hasattr(sel[0], "Mesh"):
s = sel[0].Mesh
else:
s = sel[0].Points
pointRotation = s.BoundBox.Center # boundbox center of the object
#### section point rotation
if self.RB_01_CenterObject.isChecked():
pointRotation = s.BoundBox.Center # point rotation single object BoundBox.Center
else:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
pointRotation = selectedEdge.BoundBox.Center # point rotation sub object BoundBox.Center
except Exception:
pointRotation = App.Vector(0.0,0.0,0.0)
if (pointRotation != "") and (valeurAngle != 0):
if switch_Create_Point == True:
##https://forum.freecadweb.org/viewtopic.php?f=22&t=69130
ctPoint = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
itemctPoint = coin.SoSeparator()
sphere = coin.SoSphere()
sphere.radius = 0.5
color = coin.SoBaseColor()
color.rgb = (1.0, 1.0, 0.0)
move = coin.SoTranslation()
move.translation.setValue(pointRotation)
itemctPoint.addChild(color)
itemctPoint.addChild(move)
itemctPoint.addChild(sphere)
ctPoint.addChild(itemctPoint)
switch_Create_Point = False
AppConsolePrintMessage(u"Point of rotation : " + str(pointRotation) + "\n")
self.PB_03_Create_Point.setText(u"Del Point center")
self.PB_03_Create_Point.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogNoButton))) #
self.PB_03_Create_Point.setToolTip(u"Visualize the point center rotation" + "\n"
u"If the point is visible the point is include in the image" + "\n"
u"Actual : x:" + str(round(pointRotation[0], 2)) + ", y:" + str(round(pointRotation[1], 2)) + ", z:" + str(round(pointRotation[2], 2)) + "\n" + "\n"
u"PS: the point can be hidden by an object")
else:
switch_Create_Point = True
ctPoint.removeChild(itemctPoint)
self.PB_03_Create_Point.setText(u"Point center")
self.PB_03_Create_Point.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogYesButton))) #
self.PB_03_Create_Point.setToolTip(u"Visualize the point center rotation" + "\n"
u"If the point is visible the point is include in the image" + "\n"
u"Actual : x:" + str(u"0") + ", y:" + str(u"0") + ", z:" + str(u"0") + "\n" + "\n"
u"PS: the point can be hidden by an object")
else:
AppConsolePrintError(u"Point not availlable in this mode" + "\n"
u"select an object or give an angle or revise your configuration" + "\n")
self.PB_03_Create_Point.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogYesButton))) #
self.PB_03_Create_Point.setStyleSheet("QPushButton {background-color: white;\n"
"border:4px solid rgb(215, 10, 22)};") # bord white and green
self.PB_03_Create_Point.setToolTip(u"Point not availlable in this mode" + "\n"
u"Select an object or give an angle or revise your configuration" + "\n"
u"If the point is visible the point is include in the image" + "\n"
u"Actual : x:" + str(u"0") + ", y:" + str(u"0") + ", z:" + str(u"0"))
try:
switch_Create_Point = True
ctPoint.removeChild(itemctPoint)
except Exception:
None
def on_SPB_01_Length(self,value): #
self.Length = value
def on_SPB_02_Heigth(self,value): #
self.Heigth = value
def on_radioButton_Config(self):
if self.RD_01_400x200.isChecked():#"400 x 200"
self.Length = 400
self.Heigth = 200
elif self.RD_02_600x400.isChecked():#"600 x 400"
self.Length = 600
self.Heigth = 400
elif self.RD_03_1024x768.isChecked():#"1024 x 768"
self.Length = 1024
self.Heigth = 768
elif self.RD_04_320x240.isChecked():#"320 x 240 (QVGA)"
self.Length = 320
self.Heigth = 240
elif self.RD_05_320x480.isChecked():#"320 x 480 (HVGA)"
self.Length = 320
self.Heigth = 480
elif self.RD_06_400x300.isChecked():#"400 x 300"
self.Length = 400
self.Heigth = 300
elif self.RD_07_480x360.isChecked():#"480 x 360"
self.Length = 480
self.Heigth = 360
elif self.RD_08_640x480.isChecked():#"640 x 480 (VGA)"
self.Length = 640
self.Heigth = 480
elif self.RD_09_768x576.isChecked():#"768 x 576 (PAL)"
self.Length = 768
self.Heigth = 576
elif self.RD_10_800x600.isChecked():#"800 x 600 (SVGA)"
self.Length = 800
self.Heigth = 600
elif self.RD_11_960x720.isChecked():#"960 x 720"
self.Length = 960
self.Heigth = 720
elif self.RD_12_1024x768.isChecked():#"1024 x 768 (XGA)"
self.Length = 1024
self.Heigth = 768
elif self.RD_13_1400x600.isChecked():#"1400x600 (???)"
self.Length = 1400
self.Heigth = 600
elif self.RD_14_1600x800.isChecked():#"1600x800 (???)"
self.Length = 1600
self.Heigth = 800
self.SPB_01_Length.setValue(self.Length)
self.SPB_02_Heigth.setValue(self.Heigth)
AppConsolePrintMessage(u"Definition : " + str(self.Length) + " X " + str(self.Heigth) + "\n")
def on_radioButton_FreeCAD(self):
global ui
self.RB_02_Color.setText(u"Color")
self.PB_02_OriginalBaGr.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.PB_02_OriginalBaGr.setVisible(False)
# self.RB_02_Color.setVisible(True)
ui.refreshBackGround()
def on_radioButton_Color(self):
global ui
self.PB_02_OriginalBaGr.setVisible(True)
# self.RB_02_Color.setVisible(False)
ui.on_PB_01_Color()
def on_PB_01_Color(self):
global parameterBackground
global switchToolBarActived
##https://doc.qt.io/qtforpython/PySide2/QtGui/QColor.html#PySide2.QtGui.PySide2.QtGui.QColor.colorNames
self.PB_02_OriginalBaGr.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.window.hide() # hide the window open color
# dummy = self.Color
color_Dialog = QtWidgets.QColorDialog() # PySide2
# FreeCAD-Tango
#### Dialog line 1
color_Dialog.setStandardColor( 0, QtGui.QColor(252, 233, 79 , 0).rgba()) # Butte 1
color_Dialog.setStandardColor( 6, QtGui.QColor(237, 212, 0 , 0).rgba()) # Butte 2
color_Dialog.setStandardColor(12, QtGui.QColor(196, 160, 0 , 0).rgba()) # Butte 3
color_Dialog.setStandardColor(18, QtGui.QColor( 48, 43, 0 , 0).rgba()) # Butte 4
color_Dialog.setStandardColor(24, QtGui.QColor(138, 226, 52 , 0).rgba()) # Chameleo 1
color_Dialog.setStandardColor(30, QtGui.QColor(115, 210, 22 , 0).rgba()) # Chameleo 2
color_Dialog.setStandardColor(36, QtGui.QColor( 78, 154, 6 , 0).rgba()) # Chameleo 3
color_Dialog.setStandardColor(42, QtGui.QColor( 23, 42, 4 , 0).rgba()) # Chameleo 4
#### Dialog line 2
color_Dialog.setStandardColor( 1, QtGui.QColor(252, 175, 62 , 0).rgba()) # Orang 1
color_Dialog.setStandardColor( 7, QtGui.QColor(245, 121, 0 , 0).rgba()) # Orang 2
color_Dialog.setStandardColor(13, QtGui.QColor(206, 92, 0 , 0).rgba()) # Orang 3
color_Dialog.setStandardColor(19, QtGui.QColor( 50, 25, 0 , 0).rgba()) # Orang 4
color_Dialog.setStandardColor(25, QtGui.QColor(114, 159, 207 , 0).rgba()) # Sky Blu 1
color_Dialog.setStandardColor(31, QtGui.QColor( 52, 101, 164 , 0).rgba()) # Sky Blu 2
color_Dialog.setStandardColor(37, QtGui.QColor( 32, 74, 135 , 0).rgba()) # Sky Blu 3
color_Dialog.setStandardColor(43, QtGui.QColor( 11, 21, 33 , 0).rgba()) # Sky Blu 4
#### Dialog line 3
color_Dialog.setStandardColor( 2, QtGui.QColor(173, 127, 168 , 0).rgba()) # Plu 1
color_Dialog.setStandardColor( 8, QtGui.QColor(117, 80, 123 , 0).rgba()) # Plu 2
color_Dialog.setStandardColor(14, QtGui.QColor( 92, 53, 102 , 0).rgba()) # Plu 3
color_Dialog.setStandardColor(20, QtGui.QColor( 23, 16, 24 , 0).rgba()) # Plu 4
color_Dialog.setStandardColor(26, QtGui.QColor(233, 185, 110 , 0).rgba()) # Chocolat 1
color_Dialog.setStandardColor(32, QtGui.QColor(193, 125, 17 , 0).rgba()) # Chocolat 2
color_Dialog.setStandardColor(38, QtGui.QColor(143, 89, 2 , 0).rgba()) # Chocolat 3
color_Dialog.setStandardColor(44, QtGui.QColor( 39, 25, 3 , 0).rgba()) # Chocolat 4
#### Dialog line 4
color_Dialog.setStandardColor( 3, QtGui.QColor(239, 41, 41 , 0).rgba()) # Scarle Re 1
color_Dialog.setStandardColor( 9, QtGui.QColor(204, 0, 0 , 0).rgba()) # Scarle Re 2
color_Dialog.setStandardColor(15, QtGui.QColor(164, 0, 0 , 0).rgba()) # Scarle Re 3
color_Dialog.setStandardColor(21, QtGui.QColor( 40, 0, 0 , 0).rgba()) # Scarle Re 4
color_Dialog.setStandardColor(27, QtGui.QColor( 52, 224, 226 , 0).rgba()) # FreeTea 1
color_Dialog.setStandardColor(33, QtGui.QColor( 22, 208, 210 , 0).rgba()) # FreeTea 2
color_Dialog.setStandardColor(39, QtGui.QColor( 6, 152, 154 , 0).rgba()) # FreeTea 3
color_Dialog.setStandardColor(45, QtGui.QColor( 4, 42, 42 , 0).rgba()) # FreeTea 4
#### Dialog line 5
color_Dialog.setStandardColor( 4, QtGui.QColor(255, 255, 255 , 0).rgba()) # Snow White
color_Dialog.setStandardColor(10, QtGui.QColor(238, 238, 236 , 0).rgba()) # Aluminiu 1
color_Dialog.setStandardColor(16, QtGui.QColor(211, 215, 207 , 0).rgba()) # Aluminiu 2
color_Dialog.setStandardColor(22, QtGui.QColor(186, 189, 182 , 0).rgba()) # Aluminiu 3
color_Dialog.setStandardColor(28, QtGui.QColor(136, 138, 133 , 0).rgba()) # Aluminiu 4
color_Dialog.setStandardColor(34, QtGui.QColor( 85, 87, 83 , 0).rgba()) # Aluminiu 5
color_Dialog.setStandardColor(40, QtGui.QColor( 46, 52, 54 , 0).rgba()) # Aluminiu 6
color_Dialog.setStandardColor(46, QtGui.QColor( 0, 0, 0 , 0).rgba()) # Je Black
#### Dialog line 6
color_Dialog.setStandardColor( 5, QtGui.QColor(255, 255, 255 , 0).rgba()) # Snow White
color_Dialog.setStandardColor(11, QtGui.QColor(255, 0, 0 , 0).rgba()) # Aluminiu 1
color_Dialog.setStandardColor(17, QtGui.QColor( 0, 255, 0 , 0).rgba()) # Aluminiu 2
color_Dialog.setStandardColor(23, QtGui.QColor( 0, 0, 255 , 0).rgba()) # Aluminiu 3
color_Dialog.setStandardColor(29, QtGui.QColor(255, 255, 0 , 0).rgba()) # Aluminiu 4
color_Dialog.setStandardColor(35, QtGui.QColor(255, 0, 255 , 0).rgba()) # Aluminiu 5
color_Dialog.setStandardColor(41, QtGui.QColor( 0, 255, 255 , 0).rgba()) # Aluminiu 6
color_Dialog.setStandardColor(47, QtGui.QColor( 0, 0, 0 , 0).rgba()) # Je Black
#### Dialog CustomColor
# #|Use the Yellow tones for tools that create objects.
# color_Dialog.setCustomColor(0, QtGui.QColor( int("fc",16),int("e9",16),int("4f",16) , 0).rgba())
# color_Dialog.setCustomColor(2, QtGui.QColor( int("ed",16),int("d4",16),int("00",16) , 0).rgba())
# color_Dialog.setCustomColor(4, QtGui.QColor( int("c4",16),int("a0",16),int("00",16) , 0).rgba())
# color_Dialog.setCustomColor(6, QtGui.QColor( int("30",16),int("2b",16),int("00",16) , 0).rgba())
#
# #|Use the Blue tones for tools that modify objects
# color_Dialog.setCustomColor(8, QtGui.QColor( int("72",16),int("9f",16),int("cf",16) , 0).rgba())
# color_Dialog.setCustomColor(10,QtGui.QColor( int("34",16),int("65",16),int("a4",16) , 0).rgba())
# color_Dialog.setCustomColor(12,QtGui.QColor( int("20",16),int("4a",16),int("87",16) , 0).rgba())
# color_Dialog.setCustomColor(14,QtGui.QColor( int("0b",16),int("15",16),int("21",16) , 0).rgba())
#
# #|Use the Teal tones for view-related tools
# color_Dialog.setCustomColor(1, QtGui.QColor( int("34",16),int("e0",16),int("e2",16) , 0).rgba())
# color_Dialog.setCustomColor(3, QtGui.QColor( int("16",16),int("d0",16),int("d2",16) , 0).rgba())
# color_Dialog.setCustomColor(5, QtGui.QColor( int("06",16),int("98",16),int("9a",16) , 0).rgba())
# color_Dialog.setCustomColor(7, QtGui.QColor( int("04",16),int("2a",16),int("2a",16) , 0).rgba())
#
# #|Use the Red tones for Constraint related tools
# color_Dialog.setCustomColor(9, QtGui.QColor( int("ef",16),int("29",16),int("29",16) , 0).rgba())
# color_Dialog.setCustomColor(11,QtGui.QColor( int("cc",16),int("00",16),int("00",16) , 0).rgba())
# color_Dialog.setCustomColor(13,QtGui.QColor( int("a4",16),int("00",16),int("00",16) , 0).rgba())
# color_Dialog.setCustomColor(15,QtGui.QColor( int("28",16),int("00",16),int("00",16) , 0).rgba())
self.Color = color_Dialog.getColor() # Color.name() extract the color in Hexadecimal (#ad7fa8)
if self.Color.isValid():
FreeCAD.Console.PrintMessage(u"Ok Color : " + str(self.Color.name())+"\n")
self.PB_02_OriginalBaGr.setStyleSheet("QPushButton {background-color : }" + str(self.Color.name()))
## colored the backGround
parameterBackground.SetBool("Gradient",False)
sorendermanager=Gui.ActiveDocument.ActiveView.getViewer().getSoRenderManager()
sorendermanager.setBackgroundColor(coin.SbColor4f(self.Color.redF(), self.Color.greenF(), self.Color.blueF(), self.Color.alphaF()))
sorendermanager.activate()
sorendermanager.render(True, True)
# ## colored the backGround
self.Color = self.Color.name() # self.Color change state to hex #ffffff
self.RB_02_Color.setText(u"Color " + self.Color)
else:
## #### for conserve the color but little problem
## parameterBackground.SetBool("Gradient",True)
## self.Color = dummy
## self.PB_02_OriginalBaGr.setStyleSheet("QPushButton {background-color : }" + str(self.Color))
## #self.RB_02_Color.setText(u"Color " + self.Color)
## dummy = ""
#### for reset the color
parameterBackground.SetBool("Gradient",True)
self.Color = ""
self.RB_02_Color.setText(u"Color ")
self.PB_02_OriginalBaGr.setVisible(False)
self.RB_01_Actual.setChecked(True)
if switchToolBarActived == 0:
self.window.show() # show the window and close color
# FreeCAD.Console.PrintMessage(str(u"on_PB_01_Color ")+"\n")
def refreshBackGround(self):
global parameterBackground
parameterBackground.SetBool("Gradient",True)
mainWindow = FreeCADGui.getMainWindow()
mdi = mainWindow.findChild(QtWidgets.QMdiArea) #PySide2
mwActive = mdi.activeSubWindow()
mwActive.hide()
#mwActive.showMaximized()
mwActive.show()
# FreeCAD.Console.PrintMessage(str(u"on_PB_02_OriginalBaGr ")+"\n")
def on_PB_02_OriginalBaGr(self):
global ui
self.Color = ""
self.RB_02_Color.setText(u"Color")
self.PB_02_OriginalBaGr.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.PB_02_OriginalBaGr.setVisible(False)
self.RB_02_Color.setVisible(True)
self.RB_01_Actual.setChecked(True)
ui.refreshBackGround()
# FreeCAD.Console.PrintMessage(str(u"on_PB_02_OriginalBaGr ")+"\n")
def on_PB_05_Rotation(self):
global ctPoint
global itemctPoint
try:
ctPoint.removeChild(itemctPoint)
except Exception:
None
if self.groupBox_00_01_00_Rotation.isVisible():
self.groupBox_00_00_00_Image.setTitle(u"Image options" + " (Ver rmu : " + __version__ + " : " + __date__ + ")")
self.PB_05_Rotation.setText(u"Rotation")
self.PB_05_Rotation.setToolTip(u"Go to rotation menu")
self.PB_05_Rotation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
self.PB_05_Rotation.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogOkButton))) #
MainWindow.setMinimumSize(QtCore.QSize(295, 600)) # sans rotation
MainWindow.resize(295, 600) # sans rotation
self.groupBox_00_01_00_Rotation.setVisible(False)
self.PB_03_SaveImage.setEnabled(True)
self.PB_03B_Follow.setEnabled(True)
self.PB_06_Reduction.setEnabled(True)
else:
self.groupBox_00_00_00_Image.setTitle(u"Rotation options" + " (Ver rmu : " + __version__ + " : " + __date__ + ")")
self.PB_05_Rotation.setText(u"Quit Rotation")
self.PB_05_Rotation.setToolTip(u"Go to image menu")
self.PB_05_Rotation.setStyleSheet("QPushButton {background-color: white; border:2px solid rgb(10, 215, 22)};")# bord white and green
self.PB_05_Rotation.setIcon(QIcon(QApplication.style().standardIcon(QStyle.SP_DialogCloseButton))) #
self.groupBox_00_01_00_Rotation.setVisible(True)
self.PB_03_SaveImage.setEnabled(False)
self.PB_03B_Follow.setEnabled(False)
self.PB_06_Reduction.setEnabled(False)
MainWindow.resize(590, 600) # avec Rotation
#MainWindow.move(1150, 100) # move the window macro
# FreeCAD.Console.PrintMessage(str(u"on_PB_05_Rotation ")+"\n")
def on_PB_06_Reduction(self): ##https://doc.qt.io/qtforpython/PySide2/QtWidgets/QToolBar.html
global ui
global switchToolBarActived
global switchTitleBoxToolBar
switchtbar = 0
switchToolBarActived = 0
mw = FreeCADGui.getMainWindow()
tbar = mw.findChildren(QtWidgets.QToolBar)
for i in tbar: # Test if duplicate
if i.objectName() == "ScreenWikiToolBar":
switchtbar = 1
i.setVisible(True)
AppConsolePrintError(u"ScreenWikiToolBar is already installed" + "\n")
break
if switchtbar == 0:
switchToolBarActived = 1
self.toolbarScreen = QtWidgets.QToolBar()
self.toolbarScreen.setObjectName(u"ScreenWikiToolBar")
self.toolbarScreen.setWindowTitle(u"ScreenWikiToolBar")
mw.addToolBar(self.toolbarScreen)
if switchTitleBoxToolBar == 0:
self.groupBox_img_02_Format.setTitle("")
self.groupBox_img_03_Window.setTitle("")
self.groupBox_img_04_BackGround.setTitle("")
self.groupBox_img_05_Command.setTitle("")
#### Command minimise
#### Format image D_SpinBox
self.toolbarScreen.addWidget(self.groupBox_img_02_Format)
self.LAB_01_Length.setVisible(False)
self.LAB_02_Heigth.setVisible(False)
#### Window
self.toolbarScreen.addWidget(self.groupBox_img_03_Window)
#### Color
self.grid_00_01_04.addWidget(self.RB_01_Actual, 0, 0, 1, 1)
self.grid_00_01_04.addWidget(self.RB_03_Transparent, 0, 1, 1, 1)
self.grid_00_01_04.addWidget(self.RB_02_Color, 0, 2, 1, 1)
self.grid_00_01_04.addWidget(self.PB_02_OriginalBaGr, 0, 3, 1, 1)
self.toolbarScreen.addWidget(self.groupBox_img_04_BackGround)
#### Command
self.grid_00_01_05.addWidget(self.PB_01_SetScreen, 0, 0, 1, 1)
self.grid_00_01_05.addWidget(self.PB_02_SetScreenTile, 0, 1, 1, 1)
self.grid_00_01_05.addWidget(self.PB_03_SaveImage, 0, 2, 1, 1)
self.grid_00_01_05.addWidget(self.PB_03B_Follow, 0, 3, 1, 1)
self.PB_03D_Mini.setVisible(True)
self.grid_00_01_05.addWidget(self.PB_03C_NewImage, 0, 4, 1, 1)
self.grid_00_01_05.addWidget(self.PB_03D_Mini, 0, 5, 1, 1)
self.grid_00_01_05.addWidget(self.PB_04_Quit, 0, 6, 1, 1)
self.PB_06_Reduction.setVisible(False)
self.PB_05_Rotation.setVisible(False)
self.toolbarScreen.addWidget(self.groupBox_img_05_Command)
####
self.window.hide() # hide the window and close the macro
def on_PB_03D_Mini(self):
global switchMini
if switchMini == 0:
self.PB_03_SaveImage.setText(u"")
self.PB_03B_Follow.setText(u"")
self.PB_03C_NewImage.setText(u"")
self.PB_03D_Mini.setIcon(QtGui.QIcon(QtGui.QPixmap(miniMaxiIcon))) # miniToolBarIcon icone dans une variable
self.PB_03D_Mini.setText(u"")
self.PB_03D_Mini.setToolTip(u"Maximize the toolBar")
self.PB_04_Quit.setText(u"")
#### Format image
self.SPB_01_Length.setVisible(False)
self.SPB_02_Heigth.setVisible(False)
#### Window
self.RD_01_MWindow.setVisible(False)
self.RD_02_Screen.setVisible(False)
#### Color
self.RB_01_Actual.setVisible(False)
self.RB_03_Transparent.setVisible(False)
self.RB_02_Color.setVisible(False)
self.PB_02_OriginalBaGr.setVisible(False)
#### Command
self.PB_01_SetScreen.setVisible(False)
self.PB_02_SetScreenTile.setVisible(False)
switchMini = 1
else:
self.PB_03_SaveImage.setText(u"Save Image")
self.PB_03B_Follow.setText(u"Follow")
self.PB_03C_NewImage.setText(u"New Image")
self.PB_03D_Mini.setIcon(QtGui.QIcon(QtGui.QPixmap(miniMaxiIcon))) # miniToolBarIcon icone dans une variable
self.PB_03D_Mini.setText(u"Mini")
self.PB_03D_Mini.setToolTip(u"Minimize the toolBar")
self.PB_04_Quit.setText(u"Quit")
#### Format image
self.SPB_01_Length.setVisible(True)
self.SPB_02_Heigth.setVisible(True)
#### Window
self.RD_01_MWindow.setVisible(True)
self.RD_02_Screen.setVisible(True)
#### Color
self.RB_01_Actual.setVisible(True)
self.RB_03_Transparent.setVisible(True)
self.RB_02_Color.setVisible(True)
self.PB_02_OriginalBaGr.setVisible(True)
#### Command
self.PB_01_SetScreen.setVisible(True)
self.PB_02_SetScreenTile.setVisible(True)
switchMini = 0
####Rotation begin#################################################################################
def on_RB_02_Object(self):
self.groupBox_rot_03_Point.setEnabled(True)
def on_RB_01_3D_View(self):
self.groupBox_rot_03_Point.setEnabled(False)
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
def on_PB_Photo_Rotation_Object_clicked(self):
global sel
global pathFile
global ori_Horizont
global ori_Vertical
global dim_Horizont
global dim_Vertical
global originalState
global parameterBackground
global formatFichier
global valeurAngle
global axis
global delayTime
global pathFile
global beginRotation
global endRotation
global switchQFileDialogMint
global switchTestRotation
#3DView
if self.RB_01_3D_View.isChecked(): #3DView
if (valeurAngle != 0):
# self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
dim_Horizont = self.Length
dim_Vertical = self.Heigth
# try:
# 0 = sauve fichier Gui.runCommand('Std_FreezeViews',0)
# 1 = charge fichier
# 2 = ?
# 3 = sauve
# 4 = effacer
# 5 = ?
# autre restitue la x vue
# Gui.runCommand('Std_FreezeViews',3) # sauve la vue
# except Exception:
#### original Camera
originalcamera = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()
originalPosition = FreeCADGui.ActiveDocument.ActiveView.getCameraNode().position.getValue().getValue()
originalorientation = originalcamera.Q
#### original Camera
direction = pointRotation = App.Vector(0.0,0.0,0.0)
cam = SaveName = Filter = ""
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
try:
sel = FreeCADGui.Selection.getSelection()
if hasattr(sel[0], "Shape"):
s = sel[0].Shape
elif hasattr(sel[0], "Mesh"): # upgrade with wmayer thanks #http://forum.freecadweb.org/viewtopic.php?f=13&t=22331
s = sel[0].Mesh
elif hasattr(sel[0], "Points"):
s = sel[0].Points
pointRotation = s.BoundBox.Center # boundbox center of the object
cam.position.setValue(pointRotation) # boundBox edge selected
except Exception:
#### pas de selection
#https://forum.freecadweb.org/viewtopic.php?f=22&t=10157
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
position = cam.position.getValue()
orient = cam.orientation.getValue()
focalDistance = cam.focalDistance.getValue()
viewdir = coin.SbVec3f(0, 0, -1)
viewdir = orient.multVec(viewdir)
pointRotation = position + viewdir * focalDistance
pointRotation = pointRotation2 = App.Vector(pointRotation.getValue()[0], pointRotation.getValue()[1], pointRotation.getValue()[2])
####
None
if switchTestRotation == False:
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Export a file", pathFile, "Image PNG Portable Network Graphics (*.png);;"
"Image BMP Windows Bitmap (*.bmp);;"
"Icone ICO (*.ico);;"
"Image JPEG Joint Photographic Experts Group (*.jpeg);;"
"Image JPG Joint Photographic Experts Group (*.jpg);;"
"Image PPM Portable Pixmap (*.ppm);;"
"Image TIF Tagged Image File Format (*.tif);;"
"Image TIFF Tagged Image File Format (*.tiff);;"
"Image XBM X11 Pixmap (*.xbm);;"
"Image XPM X11 Pixmap (*.xpm);;"
"All files (*.*);;")
#### mint
if switchQFileDialogMint == True: #
Filter = Filter[Filter.find("."):Filter.find(")")]
SaveName = SaveName + Filter
#### mint
if SaveName == "":
AppConsolePrintMessage(u"Process aborted" + "\n")
else:
####new2
pathFile = os.path.dirname(SaveName) + "/" #= C:/Provisoire400/
formatFichier = os.path.splitext(SaveName)[1] #= .png
SaveName = os.path.splitext(SaveName)[0] #= /home/kubuntu/.FreeCAD/Macro/Texture_007_H #= C:/Provisoire400/image3D
SaveNameformatFichier = SaveName + formatFichier #= C:/Provisoire400/image3D.png
####new2
AppConsolePrintMessage(u"Axis : " + axis + "\n")
AppConsolePrintMessage(u"Registration of : " + pathFile + "\n")
AppConsolePrintMessage(u"Registration of : " + formatFichier + "\n")
AppConsolePrintMessage(u"Registration of : " + SaveName + "_Animate_..." + "\n")
AppConsolePrintMessage(u"BackgroundColor : " + str(self.Color) + "\n")
fondEcran = "Current"
if self.RB_01_Actual.isChecked():
fondEcran = "Current"
elif self.RB_02_Color.isChecked():
fondEcran = str(self.Color)
elif self.RB_03_Transparent.isChecked():
fondEcran = "Transparent"
AppConsolePrintMessage(u"BackGround : " + fondEcran + "\n")
AppConsolePrintMessage(u"Image : " + str(dim_Horizont) + "px x " + str(dim_Vertical) + "px" + "\n")
AppConsolePrintMessage(u"_________________________________________" + "\n")
if (valeurAngle != 0):
activeView = FreeCADGui.activeDocument().activeView()
fileCount = 0
compensation = 0
if ((beginRotation - endRotation) / valeurAngle) % valeurAngle != 0:
compensation = valeurAngle
if beginRotation > endRotation:
beginRotation, endRotation = endRotation, beginRotation
try:
sel = FreeCADGui.Selection.getSelection()
if hasattr(sel[0], "Shape"):
objectRotation = Gui.Selection.getSelection()[0] # object of rotation
objectPlacementOrigine = objectRotation.Placement # object Placement Origine
objectPlacementBase = objectRotation.Placement.Base # object Placement Base
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[1] # select one element and axis same object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # select one element and axis same object (1 selection)
except Exception:
None
#### section point rotation
if self.RB_01_CenterObject.isChecked():# and (axis != "D"):
pointRotation = objectRotation.Shape.BoundBox.Center # point rotation single object BoundBox.Center
else:
pointRotation = selectedEdge.BoundBox.Center # point rotation sub object BoundBox.Center
except Exception:
pointRotation = pointRotation2
## section choice axis or Direction
if axis == "X":
direction = App.Vector(1.0,0.0,0.0)
elif axis == "Y":
direction = App.Vector(0.0,1.0,0.0)
elif axis == "Z":
direction = App.Vector(0.0,0.0,1.0)
elif axis == "D": # Direction
try:
direction = selectedEdge.Vertexes[1].Point.sub(selectedEdge.Vertexes[0].Point)# search the direction line or sub
except Exception:
try:
direction = objectRotation.Vertexes[0].Point
except Exception:
direction = App.Vector(0.0,0.0,0.0)
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
#### new
beginRotationTr = beginRotation * float("1e" + str(degreesNumberDecimal))
endRotationTr = endRotation * float("1e" + str(degreesNumberDecimal))
compensationTr = compensation * float("1e" + str(degreesNumberDecimal))
valeurAngleTr = valeurAngle * float("1e" + str(degreesNumberDecimal))
#### new
if self.CB_01_Reverse.isChecked():
angleRotation = (- valeurAngle)
else:
angleRotation = valeurAngle
for i in range(int(beginRotationTr), int(endRotationTr) + int(compensationTr), int(valeurAngleTr)):
fileCount += 1
####
if (switchTestRotation == False) and (SaveName != ""):
deg = (u"000000" + str(i))[:-degreesNumberDecimal][-3:] + "-" + (u"0000000000" + str(i))[-degreesNumberDecimal:] #i = 2694000 to deg = 269-4000
strfileCount = (u"0000000000" + str(fileCount))[-len(str(numberPhoto)):]
fileName = SaveName + "_Animate_" + strfileCount + "_" + axis + "_" + deg + "_" + fondEcran + formatFichier # create complete name
activeView.saveImage(fileName, dim_Horizont, dim_Vertical, fondEcran)
####
cam.position.setValue(FreeCAD.Vector(pointRotation)) # centre rotation
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
rot = coin.SbRotation()
rot.setValue(coin.SbVec3f(direction[0],direction[1],direction[2]),math.radians(angleRotation))
nrot = cam.orientation.getValue() * rot
cam.orientation = nrot
####
Gui.updateGui() # rafraichi l'ecran
####
try:
self.DSPB_01_Delay_Time.setSuffix(u" Delay second (image " + str(fileCount) + "/" + str(numberPhoto) + ") (" + str(i / float("1e" + str(degreesNumberDecimal))) + " deg.)")
time.sleep(delayTime)
except Exception: None
####
if self.CB_02_Original_Position.isChecked():
#### restore Camera
originalcamera = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
originalcamera.position.setValue(originalPosition)
originalcamera.orientation.setValue(float(originalorientation[0]), float(originalorientation[1]), float(originalorientation[2]), float(originalorientation[3]))
#### restore Camera
else:
AppConsolePrintError(u"Give one angle value" + "\n")
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white;\n"
"border:2px solid rgb(215, 10, 22)};") # bord white and green
self.DSPB_01_Delay_Time.setSuffix(u" Delay second")
switchTestRotation = False
# Object selected
elif self.RB_02_Object.isChecked(): # Object selected
try:
sel = FreeCADGui.Selection.getSelection()
if len(sel) != 0:
dim_Horizont = self.Length
dim_Vertical = self.Heigth
if hasattr(sel[0], "Shape"):
s = sel[0].Shape
elif hasattr(sel[0], "Mesh"): # upgrade with wmayer thanks #http://forum.freecadweb.org/viewtopic.php?f=13&t=22331
s = sel[0].Mesh
elif hasattr(sel[0], "Points"):
s = sel[0].Points
centreRotation = s.BoundBox.Center # boundbox center of the object
if (valeurAngle != 0):
if switchTestRotation == False:
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Export a file", pathFile, "Image PNG Portable Network Graphics (*.png);;"
"Image BMP Windows Bitmap (*.bmp);;"
"Icone ICO (*.ico);;"
"Image JPEG Joint Photographic Experts Group (*.jpeg);;"
"Image JPG Joint Photographic Experts Group (*.jpg);;"
"Image PPM Portable Pixmap (*.ppm);;"
"Image TIF Tagged Image File Format (*.tif);;"
"Image TIFF Tagged Image File Format (*.tiff);;"
"Image XBM X11 Pixmap (*.xbm);;"
"Image XPM X11 Pixmap (*.xpm);;"
"All files (*.*);;")
#### mint
if switchQFileDialogMint == True: #
Filter = Filter[Filter.find(u"."):Filter.find(")")]
SaveName = SaveName + Filter
#### mint
if SaveName == "":
AppConsolePrintMessage(u"Process aborted" + "\n")
else:
originlPlacement = sel[0].Placement
####new2
pathFile = os.path.dirname(SaveName) + "/" #= C:/Provisoire400/
formatFichier = os.path.splitext(SaveName)[1] #= .png
SaveName = os.path.splitext(SaveName)[0] #= /home/kubuntu/.FreeCAD/Macro/Texture_007_H #= C:/Provisoire400/image3D
SaveNameformatFichier = SaveName + formatFichier #= C:/Provisoire400/image3D.png
####new2
AppConsolePrintMessage(u"Axis : " + axis + "\n")
AppConsolePrintMessage(u"Registration of : " + pathFile + "\n")
AppConsolePrintMessage(u"Registration of : " + formatFichier + "\n")
AppConsolePrintMessage(u"Registration of : " + SaveName + "_Animate_..." + "\n")
AppConsolePrintMessage(u"Image : " + str(dim_Horizont) + "px x " + str(dim_Vertical) + "px" + "\n")
fondEcran = "Current"
if self.RB_01_Actual.isChecked():
fondEcran = "Current"
elif self.RB_02_Color.isChecked():
fondEcran = str(self.Color)
elif self.RB_03_Transparent.isChecked():
fondEcran = "Transparent"
AppConsolePrintMessage(u"BackGround : " + fondEcran + "\n")
AppConsolePrintMessage(u"_________________________________________" + "\n")
if (valeurAngle != 0):
activeView = FreeCADGui.activeDocument().activeView()
fileCount = 0
compensation = 0
if ((beginRotation - endRotation) / valeurAngle) % abs(valeurAngle) != 0:
compensation = valeurAngle
if beginRotation > endRotation:
beginRotation, endRotation = endRotation, beginRotation
sel = FreeCADGui.Selection.getSelection()
if hasattr(sel[0], "Shape"):
objectRotation = Gui.Selection.getSelection()[0] # object of rotation
objectPlacementOrigine = objectRotation.Placement # object Placement Origine
objectPlacementBase = objectRotation.Placement.Base # object Placement Base
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[1] # select one element and axis same object (2 selections)
except Exception:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0] # select one element and axis same object (1 selection)
except Exception:
None
#### section point rotation
if self.RB_01_CenterObject.isChecked():# and (axis != "D"):
pointRotation = objectRotation.Shape.BoundBox.Center # point rotation single object BoundBox.Center
else:
pointRotation = selectedEdge.BoundBox.Center # point rotation sub object BoundBox.Center
## section choice axis or Direction
if axis == "X":
direction = App.Vector(1.0,0.0,0.0)
elif axis == "Y":
direction = App.Vector(0.0,1.0,0.0)
elif axis == "Z":
direction = App.Vector(0.0,0.0,1.0)
elif axis == "D": # Direction
try:
direction = selectedEdge.Vertexes[1].Point.sub(selectedEdge.Vertexes[0].Point)# search the direction line or sub
except Exception:
try:
direction = objectRotation.Vertexes[0].Point
except Exception:
direction = App.Vector(0.0,0.0,0.0)
#### new
beginRotationTr = beginRotation * float("1e" + str(degreesNumberDecimal))
endRotationTr = endRotation * float("1e" + str(degreesNumberDecimal))
compensationTr = compensation * float("1e" + str(degreesNumberDecimal))
valeurAngleTr = valeurAngle * float("1e" + str(degreesNumberDecimal))
#### new
for i in range(int(beginRotationTr), int(endRotationTr) + int(compensationTr), int(valeurAngleTr)):
angleRotation = 0.0
angleRotation = i / float("1e" + str(degreesNumberDecimal))
if self.CB_01_Reverse.isChecked():
angleRotation = -angleRotation
objectRotation.Placement = App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(direction, angleRotation), App.Vector(pointRotation)).multiply(objectPlacementOrigine) # other method
Gui.updateGui() # rafraichi l'ecran
fileCount += 1
if switchTestRotation == False:
####
deg = (u"000000" + str(i))[:-degreesNumberDecimal][-3:] + "-" + (u"0000000000" + str(i))[-degreesNumberDecimal:] #i = 2694000 to deg = 269-4000
strfileCount = (u"0000000000" + str(fileCount))[-len(str(numberPhoto)):]
fileName = SaveName + "_Animate_" + strfileCount + "_" + axis + "_" + deg + "_" + fondEcran + formatFichier # create complete name
activeView.saveImage(fileName, dim_Horizont, dim_Vertical, fondEcran)
####
try:
#self.DSPB_01_Delay_Time.setSuffix(u" Delay second (image " + str(fileCount) + "/" + str(numberPhoto) + ")")
self.DSPB_01_Delay_Time.setSuffix(u" Delay second (image " + str(fileCount) + "/" + str(numberPhoto) + ") (" + str(i / float("1e" + str(degreesNumberDecimal))) + " deg.)")
time.sleep(delayTime)
except Exception: None
switchTestRotation = False
if self.CB_02_Original_Position.isChecked():
objectRotation.Placement = objectPlacementOrigine # return in original position
elif (hasattr(sel[0], "Mesh")) or (hasattr(sel[0], "Points")): # upgrade with wmayer thanks #http://forum.freecadweb.org/viewtopic.php?f=13&t=22331
if hasattr(sel[0], "Mesh"):
s = sel[0].Mesh
#print("Mesh")
else:
s = sel[0].Points
#print("Points")
objectRotation = sel[0]
pointRotation = s.BoundBox.Center # boundbox center of the object
objectPlacementOrigine = s.Placement # object Placement Origine
fileCount = 0
activeView = FreeCADGui.activeDocument().activeView()
compensation = 1
#### section point rotation
if self.RB_01_CenterObject.isChecked():# and (axis != "D"):
pointRotation = s.BoundBox.Center # point rotation single object BoundBox.Center
else:
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
pointRotation = selectedEdge.BoundBox.Center # point rotation sub object BoundBox.Center
except Exception:
pointRotation = App.Vector(0.0,0.0,0.0)
## section choice axis or Direction
if axis == "X":
direction = App.Vector(1.0,0.0,0.0)
elif axis == "Y":
direction = App.Vector(0.0,1.0,0.0)
elif axis == "Z":
direction = App.Vector(0.0,0.0,1.0)
elif axis == "D": # Direction
try:
selectedEdge = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] # select one element and axis second object (2 selections)
direction = selectedEdge.Vertexes[1].Point.sub(selectedEdge.Vertexes[0].Point)# search the direction line or sub
except Exception:
try:
direction = objectRotation.Vertexes[0].Point
except Exception:
direction = App.Vector(0.0,0.0,0.0)
#### new
beginRotationTr = beginRotation * float("1e" + str(degreesNumberDecimal))
endRotationTr = endRotation * float("1e" + str(degreesNumberDecimal))
compensationTr = compensation * float("1e" + str(degreesNumberDecimal))
valeurAngleTr = valeurAngle * float("1e" + str(degreesNumberDecimal))
#### new
for i in range(int(beginRotationTr), int(endRotationTr) + int(compensationTr), int(valeurAngleTr)):
angleRotation = 0.0
angleRotation = i / float("1e" + str(degreesNumberDecimal))
if self.CB_01_Reverse.isChecked():
angleRotation = -angleRotation
objectRotation.Placement = App.Placement(App.Vector(0,0,0), App.Rotation(direction, angleRotation), App.Vector(pointRotation)).multiply(objectPlacementOrigine)
Gui.updateGui()
fileCount += 1
if switchTestRotation == False:
####
deg = (u"000000" + str(i))[:-degreesNumberDecimal][-3:] + "-" + (u"0000000000" + str(i))[-degreesNumberDecimal:] #i = 2694000 to deg = 269-4000
strfileCount = (u"0000000000" + str(fileCount))[-len(str(numberPhoto)):]
fileName = SaveName + "_Animate_" + strfileCount + "_" + Axis + "_" + deg + "_" + fondEcran + formatFichier # create complete name
activeView.saveImage(fileName, dim_Horizont, dim_Vertical, fondEcran)
####
try:
#self.DSPB_01_Delay_Time.setSuffix(u" Delay second (image " + str(fileCount) + "/" + str(numberPhoto) + ")")
self.DSPB_01_Delay_Time.setSuffix(u" Delay second (image " + str(fileCount) + "/" + str(numberPhoto) + ") (" + str(i / float("1e" + str(degreesNumberDecimal))) + " deg.)")
time.sleep(delayTime)
except Exception: None
switchTestRotation = False
if self.CB_02_Original_Position.isChecked():
objectRotation.Placement = objectPlacementOrigine # return in original position
App.activeDocument().recompute()
self.DSPB_01_Delay_Time.setSuffix(u" Delay second")
else:
AppConsolePrintError(u"Give one angle value" + "\n")
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white;\n"
"border:2px solid rgb(215, 10, 22)};") # bord white and green
else:
self.PB_Save_Animation.setStyleSheet("QPushButton {background-color: white;\n"
"border:2px solid rgb(215, 10, 22)};") # bord white and green
if len(sel) == 0:
self.PB_Save_Animation.setText(u"Save the animation (select on object)")
if (valeurAngle == 0):
self.PB_Save_Animation.setText(u"Save the animation (select on angle value)")
AppConsolePrintError(u"\n" + " Select one object : " + "\n"
u" Select the axis rotaion, X, Y, Z or D " + "\n"
u" Give the angle rotation " + "\n"
u" Mode (D)irection, Select First the object to rotate, second the axis " + "\n"
u" (or check the '3D View' button) " + "\n" + "\n")
except Exception:
AppConsolePrintError(u"Give one angle value !" + "\n" + "\n")
self.SPB_01_Angle_Rotation.setStyleSheet("QDoubleSpinBox {background-color: white;\n"
"border:2px solid rgb(215, 10, 22)};") # bord white and green
####Rotation end#######################################################################################
def on_PB_03_SaveImage(self):
global pathFile
global pos_X_Window # Position begin X window
global pos_Y_Window # Position begin Y window
global counterName
global switchFollow
global SaveName
global SaveNameMemo
global neutralImage
global switchQFileDialogMint
#SaveName, Filter = PySide.QtGui.QFileDialog.getSaveFileName(None, "Export a file", pathFile, "All files (*.*);;")
if switchFollow == 0:
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Export a file", pathFile, "Image PNG Portable Network Graphics (*.png);;"
"Image BMP Windows Bitmap (*.bmp);;"
"Icone ICO (*.ico);;"
"Image JPEG Joint Photographic Experts Group (*.jpeg);;"
"Image JPG Joint Photographic Experts Group (*.jpg);;"
"Image PPM Portable Pixmap (*.ppm);;"
"Image TIF Tagged Image File Format (*.tif);;"
"Image TIFF Tagged Image File Format (*.tiff);;"
"Image XBM X11 Pixmap (*.xbm);;"
"Image XPM X11 Pixmap (*.xpm);;"
"All files (*.*);;")
#### mint
if switchQFileDialogMint == True: #
Filter = Filter[Filter.find(u"."):Filter.find(")")]
SaveName = SaveName + Filter
#### mint
if neutralImage == 0:
counterName = 0
self.PB_03B_Follow.setEnabled(False)
self.PB_03B_Follow.setText(u"Follow")
SaveNameMemo = SaveName
switchFollow = 0
if SaveName == "":
AppConsolePrintMessage(u"Process aborted"+"\n")
else:
if neutralImage == 1:
SaveNamefileCount = SaveName
neutralImage = 0
else:
#### insert the numer image betwen name and extension
fileCount = "_" + '%03d' % (counterName)
SaveName = SaveNameMemo
dummy = SaveName.split('.')
SaveNamefileCount = dummy[0] + fileCount + "." + dummy[1]
self.PB_03B_Follow.setEnabled(True)
self.PB_03B_Follow.setText(u"Follow (" + str(counterName + 1) + ")") # WL
####
AppConsolePrintMessage(u"Registration of ( " + SaveNamefileCount + " )" + "\n")
if self.RD_02_Screen.isChecked():
try:
#file = open(SaveNamefileCount, 'w')
try:
if (self.RB_01_Actual.isChecked()):
Gui.activeDocument().activeView().saveImage(SaveNamefileCount, self.Length, self.Heigth,"Current")
AppConsolePrintMessage(u"BackGround Current" + "\n")
elif self.RB_02_Color.isChecked():
Gui.activeDocument().activeView().saveImage(SaveNamefileCount, self.Length, self.Heigth, str(self.Color))
AppConsolePrintMessage(u"BackGround " + self.Color + "\n")
elif (self.RB_03_Transparent.isChecked()):
Gui.activeDocument().activeView().saveImage(SaveNamefileCount, self.Length, self.Heigth, "Transparent")
AppConsolePrintMessage(u"BackGround Transparent" + "\n")
AppConsolePrintMessage(u"Saved definition : " + str(self.Length) + " " + str(self.Heigth) + "\n")
AppConsolePrintMessage(u"File Name : " + SaveNamefileCount + "\n")
except Exception:
AppConsolePrintError(u"Error write file "+"\n")
#finally:
# file.close()
#self.PB_03B_Follow.setEnabled(True)
AppConsolePrintMessage(u"__________________________"+"\n")
pathFile = str(os.path.dirname(SaveNamefileCount))
except Exception:
AppConsolePrintError(u"Error Open file " + SaveNamefileCount + "\n")
else:
try:
#################### fonctionne mais l'ecran 3D est noir ( screenShot window ) ########
## mainWindow = FreeCADGui.getMainWindow()
## screenShot = QtGui.QPixmap(mainWindow.size())
## mainWindow.render(screenShot)
## pix.save(SaveName)
#######################################################################################
mainWindow = FreeCADGui.getMainWindow()
AppConsolePrintMessage(u"Real window saved " + str(mainWindow.geometry()) + "\n")
mainWindowCoinSupX = mainWindow.geometry().x()
mainWindowCoinSupY = mainWindow.geometry().y()
mainWindowWidth = mainWindow.geometry().width()
mainWindowHeight = mainWindow.geometry().height()
QPixmap.grabWindow(QApplication.desktop().winId(), mainWindowCoinSupX + pos_X_Window, mainWindowCoinSupY + pos_Y_Window, mainWindowWidth, mainWindowHeight).save(SaveNamefileCount, "")
except Exception:
try:
AppConsolePrintError(u"Error Open file " + SaveName + fileCount + "\n")
except Exception:
None
def on_PB_03B_Follow(self):
global ui
global counterName
global switchFollow
switchFollow = 1
counterName += 1
ui.on_PB_03_SaveImage()
def on_PB_03C_New(self):
global neutralImage
neutralImage = 1
ui.on_PB_03_SaveImage()
def on_PB_01_SetScreen(self):
global pos_X_Window
global pos_Y_Window
global switchMainWindow
global pos_X_Tile_Window
global pos_Y_Tile_Window
global ecranCompletX
global ecranCompletY
mainWindow = FreeCADGui.getMainWindow()
mdi = mainWindow.findChild(QtWidgets.QMdiArea)
mwActive = mdi.activeSubWindow()
pos_X_Tile_Window = mwActive.frameGeometry().x()
pos_Y_Tile_Window = mwActive.frameGeometry().y()
mwActive.hide()
mwActive.showMaximized()
mwActive.show()
if self.RD_02_Screen.isChecked():
if (switchMainWindow == 1):
switchMainWindow = 0
mainWindow.restoreGeometry(originalState.value("geometry"))
mainWindow.restoreState(originalState.value("state"))
mainWindow.showNormal()
mwActive.setGeometry(pos_X_Tile_Window + pos_X_Window, pos_Y_Tile_Window + pos_Y_Window, self.Length, self.Heigth) # sur fenetre de travail 3D
else:
mainWindow.setGeometry(((ecranCompletX - self.Length) / 2) + pos_X_Window, ((ecranCompletY - self.Heigth) / 2) + pos_Y_Window, self.Length, self.Heigth) # sur fenetre FreeCAD
switchMainWindow = 1
def on_PB_02_SetScreenTile(self):
global pos_X_Window
global pos_Y_Window
global switchMainWindow
global pos_X_Tile_Window
global pos_Y_Tile_Window
global ecranCompletX
global ecranCompletY
global originalState
global pathFile
mainWindow = FreeCADGui.getMainWindow()
mdi = mainWindow.findChild(QtWidgets.QMdiArea)
mwActive = mdi.activeSubWindow()
mdi.tileSubWindows() #### encadre la fenetre
if self.RD_02_Screen.isChecked():
if (switchMainWindow == 1):
switchMainWindow = 0
mainWindow.restoreGeometry(originalState.value("geometry"))
mainWindow.restoreState(originalState.value("state"))
mainWindow.showNormal()
mwActive.setGeometry(pos_X_Tile_Window + pos_X_Window, pos_Y_Tile_Window + pos_Y_Window, self.Length, self.Heigth) # sur fenetre de travail 3D
else:
mainWindow.setGeometry(((ecranCompletX - self.Length) / 2) + pos_X_Window, ((ecranCompletY - self.Heigth) / 2) + pos_Y_Window, self.Length, self.Heigth) # sur fenetre FreeCAD
switchMainWindow = 1
def on_PB_04_Quit(self):
global originalState
global parameterBackground
global so
global pathFile
global switchToolBarActived
global switchTitleBoxToolBar
global switchQFileDialogMint
global ctPoint
global itemctPoint
#### Config ####
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchTitleBoxToolBar", switchTitleBoxToolBar)# True or False
if self.RD_01_MWindow.isChecked():
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RD_01_MWindow", True) # True or False
else:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RD_01_MWindow", False) # True or False
if self.RD_02_Screen.isChecked():
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RD_02_Screen", True) # True or False
else:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RD_02_Screen", False) # True or False
if self.RB_01_Actual.isChecked():
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RB_01_Actual", True) # True or False
else:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RB_01_Actual", False) # True or False
if self.RB_03_Transparent.isChecked():
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RB_03_Transparent", True) # True or False
else:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RB_03_Transparent", False)# True or False
if self.RB_02_Color.isChecked():
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RB_02_Color", True) # True or False
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("setColorUser", self.Color) #
else:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switch_RB_02_Color", False) # True or False
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("setLastPath", pathFile) # pathFile
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetInt("setLengthImage", self.Length) # Length X
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetInt("setHeigthImage", self.Heigth) # Heigth Y
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetBool("switchQFileDialogMint", switchQFileDialogMint) # True or False
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetInt("degreesNumberDecimal", degreesNumberDecimal) # degreesNumberDecimal
#### Config ####
try:
ctPoint.removeChild(itemctPoint)
except Exception:
None
try:
FreeCADGui.Selection.removeObserver(so) # Uninstalls resident function (desactivated for read after LeftDock RightDock)
parameterBackground.SetBool("Gradient",True)
mainWindow = FreeCADGui.getMainWindow()
mainWindow.restoreGeometry(originalState.value("geometry"))
#mainWindow.restoreState(originalState.value("state"))
mainWindow.restoreState(originalState.value("windowState"))
mainWindow.showNormal()
mdi = mainWindow.findChild(QtWidgets.QMdiArea)
mwActive = mdi.activeSubWindow()
mwActive.showNormal()
mwActive.showMaximized()
self.window.hide() # hide the window and close the macro
#self.window.close()
except Exception:
None
if switchToolBarActived == 1:
try:
self.toolbarScreen.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # destroy
self.toolbarScreen.deleteLater() # destroy
self.toolbarScreen.destroy() # destroy
except Exception:
None
AppConsolePrintMessage("___Screen_Wiki end__________ " + "\n\n")
class SelObserver:
def addSelection(self,document, object, element, position): # Selection
global sel
global ui
sel = FreeCADGui.Selection.getSelection()
ui.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
ui.PB_Save_Animation.setText(u"Save the animation")
ui.PB_03_Create_Point.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
if len(sel)!= 0:
ui.groupBox_rot_03_Point.setEnabled(True)
else:
ui.groupBox_rot_03_Point.setEnabled(False)
# ui.PB_Save_Animation.setStyleSheet("QPushButton {background-color: QPalette.Base}") # origin system
# else:
# ui.on_pushButton_Raf_clicked()
#####################################################################################
### debut test QWidget, QDockWidget, QToolBar ##################################################
mw = FreeCADGui.getMainWindow()
switchRunning = 0
ww = mw.findChildren(QtWidgets.QWidget) # pour QWidget
for i in ww:
if (str(i.objectName()) == __title__):
switchRunning = 1
i.setVisible(True) # visible True
break
####
dw = mw.findChildren(QtWidgets.QDockWidget) # pour QtWidgets Docked et pas les Flotants
for i in dw:
if (str(i.objectName()) == __title__):
switchRunning = 1
i.setVisible(True) # visible True
AppConsolePrintError(__title__ + " is already open" + "\n")
break
####
switchtbar = 0
tb = mw.findChildren(QtWidgets.QToolBar)
for i in tb:
if (str(i.objectName()) == "ScreenWikiToolBar"):
switchRunning = 1
switchtbar = 1
i.setVisible(True) # visible True
AppConsolePrintError(u"ScreenWikiToolBar is already open" + "\n")
i.setStyleSheet("background-color: #ff0000;") # white red bold
Gui.updateGui() # rafraichi l'ecran
try:
time.sleep(0.05)
except Exception: None
i.setStyleSheet("background-color: QPalette.Base") # origin system
break
### fin test QWidget, QDockWidget, QToolBar ####################################################
if (switchRunning == 1) or (switchtbar == 1):
None
else:
sel = FreeCADGui.Selection.getSelection()
so=SelObserver()
FreeCADGui.Selection.addObserver(so) # installe la fonction en mode resident
mainWindowOverture = FreeCADGui.getMainWindow() # fenetre FreeCAD
mainWindow = FreeCADGui.getMainWindow()
#https://srinikom.github.io/pyside-docs/PySide/QtGui/QMainWindow.html
#PySide.QtGui.PySide.QtGui.QMainWindow.restoreState
originalState = QSettings(u"Mario52", __title__)
originalState.setValue("geometry", mainWindow.saveGeometry())
originalState.setValue("state", mainWindow.saveState())
##################
if QtCore.__version_info__ [0] >= 5:
ecranComplet = QtWidgets.QApplication.screens()[0].availableGeometry() #https://github.com/enthought/traitsui/pull/1311
else:
ecranComplet = QtWidgets.QDesktopWidget().availableGeometry() # disponible (PySide2) .center()
# ecranComplet = QtWidgets.QDesktopWidget().screenGeometry() # complet (PySide2)
# ecranComplet = QtWidgets.QDesktopWidget().availableGeometry() # disponible (PySide2)
ecranCompletX = ecranComplet.width()
ecranCompletY = ecranComplet.height()
doc = FreeCAD.ActiveDocument
if doc == None:
doc = FreeCAD.newDocument(u"Screen_Window")
MainWindow = QtWidgets.QWidget() #(PySide2)
MainWindow.setObjectName(__title__) # macro internal Name
ui = Ui_MainWindow(MainWindow)
ui.setupUi(MainWindow)
####Configuration##############
#
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).SetString("Version",__version__ + " (" + __date__ + ")")#
parameterBackground = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
#parameterBackground = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("BackgroundColor")
#parameterBackgroundColor2 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("BackgroundColor2")
#parameterBackgroundColor3 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("BackgroundColor3")
#parameterBackgroundColor4 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("BackgroundColor4")
####
switchTitleBoxToolBar = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switchTitleBoxToolBar")
pathFile = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetString("setLastPath")
if pathFile == "":
pathFile = path
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switch_RD_01_MWindow"):
ui.RD_01_MWindow.setChecked(True)
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switch_RD_02_Screen"):
ui.RD_02_Screen.setChecked(True)
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switch_RB_01_Actual"):
ui.RB_01_Actual.setChecked(True)
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switch_RB_03_Transparent"):
ui.RB_03_Transparent.setChecked(True)
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetBool("switch_RB_02_Color"):
ui.Color = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/" + __title__).GetString("setColorUser")
if ui.Color == "": ui.Color = "4289331455"
ui.RB_02_Color.setChecked(True)
ui.RB_02_Color.setText(u"Color " + ui.Color)
ui.PB_02_OriginalBaGr.setVisible(True)
ui.PB_02_OriginalBaGr.setStyleSheet("QPushButton {background-color : }" + str(ui.Color))
parameterBackground.SetBool("Gradient",False)
sorendermanager=Gui.ActiveDocument.ActiveView.getViewer().getSoRenderManager()
redX = (1.0/256.0) * int(ui.Color[1:3],16)
greenX = (1.0/256.0) * int(ui.Color[3:5],16)
blueX = (1.0/256.0) * int(ui.Color[5:7],16)
sorendermanager.setBackgroundColor(coin.SbColor4f(redX, greenX, blueX, 00))
sorendermanager.activate()
sorendermanager.render(True, True)
#
####Configuration##############
MainWindow.show()
@mario52a
Copy link
Author

This macro utility is intended for the use of the program FreeCAD http://www.freecadweb.org/
The icon for your toolbar, it is to place in your macros directory (all in the same location of the macro)

The wiki page https://wiki.freecadweb.org/Macro_Screen_Wiki

Macro_Screen_Wiki The icon for the toolbar Rename in Macro_Screen_Wiki.png

@berhoel
Copy link

berhoel commented May 31, 2020

I tried to use FCCircularText and got:

Error
  File "/home/hoel/.FreeCAD/FCCircularText.FCMacro", line 1412, in on_PU_Benchmarks
    ff.on_PU_Execute()
-->    File "/home/hoel/.FreeCAD/FCCircularText.FCMacro", line 1509, in on_PU_Execute
    depart = time.clock()     # chrono begin
-->  AttributeError: module 'time' has no attribute 'clock'

with Python 3.8.

time.clock is depricated since Python 3.3. I replaced it with time.process_time and the macro runs fine.

@mario52a
Copy link
Author

mario52a commented Jun 1, 2020

Hi
many thanks for report this error in my macro, but you signal in the bad page (here Macro_Screen_Wiki)

i have now upgrade my macro FCCircularTex version 0.15 (installable with AddonManager)

i delete the chrono and modify the gui (GridLayout) and the font display (comboBox) and i use the MatPlotLib font god for Windows and Linux see the new options available for this comboBox, but only for FC 0.18 and more

enjoy
mario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment