Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 <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
## http://forum.freecadweb.org/viewtopic.php?f=22&t=10488
## http://forum.freecadweb.org/viewtopic.php?f=22&t=19620 # microelly2 code
#
#Macro_Screen_Wiki 10/03/2019, 2020/03/21, 2020/05/04, 2020/10/29
#
#OS: Windows 10 (10.0)
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.19.22846 (Git)
#Build type: Release
#Branch: master
#Hash: 1f46b72491a0008384a6db4f2615a656249f6f08
#Python version: 3.6.8
#Qt version: 5.12.1
#Coin version: 4.0.0a
#OCC version: 7.3.0
#Locale: French/Mars (fr_MA)
#
__title__ = "Screen_Wiki"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_Screen_Wiki" #Macro_Screen_Wiki
__version__ = "00.03"
__date__ = "2020/10/30" #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.path
##############################################
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
#### section Rotation
global dim_Horizont ; dim_Horizont = 0
global dim_Vertical ; dim_Vertical = 0
global formatFichier ; formatFichier = 0
global axis ; axis = "X"
global valeur ; valeur = 0
global delayTime ; delayTime = 0.0
global beginRotation ; beginRotation = 0
global endRotation ; endRotation = 360
global angleRotation ; angleRotation = 0
###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##############################################
miniWindowIcon = [
"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",
" ",
" ...................... ",
" . $ $ . ",
" .$$$ $ $ . ",
" .$ $$ $ . ",
" . $ $ . ",
" .$$$ $ . ",
" . $ $ @@ @@ @@ . ",
" . $ $ @&%&&%&@ . ",
" . @&&%&&%&&@ . ",
" . @&&&&&&&&@ . ",
" . @&&&&&&&&@ . ",
" . #&&&&&&% . ",
" . + @#&&&&#@ ++ . ",
" . @& +@&+ @@ . ",
" . @%& @& &&@ . ",
" . @%%& @& &%&@ . ",
" . @%%%& @& &%%&@ . ",
" . @&%%& @&&%%&@@ . ",
" . @&&& @@&&&@@ . ",
" . @@@ @@@@@ . ",
" . . ",
" ...................... ",
" "]
#### 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" + "\n")
#### Detect version macro ###########################################
import WebGui
#WebGui.openBrowser("http://www.freecadweb.org/")
#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("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")
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_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(miniWindowIcon))) # 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 ####
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("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("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("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("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.QSpinBox()
self.SPB_01_Angle_Rotation.setPrefix("")
self.SPB_01_Angle_Rotation.setMaximum(360)
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.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.QSpinBox()
self.SPB_02_Angle_Begin_Rotation.setMaximum(360)
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.QSpinBox()
self.SPB_03_Angle_End_Rotation.setMaximum(360)
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_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)
#### 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, 3)
self.grid_00_02_04.addWidget(self.LAB_02_BegRot, 3, 0, 1, 3)
self.grid_00_02_04.addWidget(self.PB_01_Decrement_DegBeg, 4, 0, 1, 1)
self.grid_00_02_04.addWidget(self.SPB_02_Angle_Begin_Rotation, 4, 1, 1, 1)
self.grid_00_02_04.addWidget(self.PB_01_Increment_DegBeg, 4, 2, 1, 1)
self.grid_00_02_04.addWidget(self.LAB_03_EndRot, 5, 0, 1, 3)
self.grid_00_02_04.addWidget(self.PB_02_Decrement_DegEnd, 6, 0, 1, 1)
self.grid_00_02_04.addWidget(self.SPB_03_Angle_End_Rotation, 6, 1, 1, 1)
self.grid_00_02_04.addWidget(self.PB_02_Increment_DegEnd, 6, 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, 1)
self.grid_00_02_05.addWidget(self.DSPB_01_Delay_Time, 1, 0, 1, 1)
self.grid_00_02_05.addWidget(self.CB_01_Reverse, 2, 0, 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_Save_Animation, 4, 0, 1, 1)
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("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(" Length px")
self.LAB_02_Heigth.setText(u"Height")
self.SPB_02_Heigth.setSuffix(" 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_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.LAB_00_Numb_Image.setToolTip(u"The number images calculated is approximate" + "\n"
u"the number image must be + 1" + "\n")
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.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_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_004_450_Current.png" + "\n"
u"MyName_\t: file name" + "\n"
u"Animate_\t: serial images for animation" + "\n"
u"004_\t\t: number of image" + "\n"
u"450_\t\t: angle rotation of the image" + "\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, value):
def formuleNumberPhoto(self):
global beginRotation
global endRotation
global valeur
self.SPB_01_Angle_Rotation.setValue(valeur)
if valeur != 0:
self.PB_00_Decrement.setStyleSheet("background-color: QPalette.Base") # origin system
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_00_Increment.setStyleSheet("background-color: QPalette.Base") # origin system
self.LAB_00_Numb_Image.setStyleSheet("background-color: QPalette.Base") # origin system
parcours = (endRotation - beginRotation)
numberPhoto = int((parcours / valeur) + 1)
self.LAB_00_Numb_Image.setText("Number images : " + str(numberPhoto))
else:
self.PB_00_Decrement.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);")# bord white and green
self.PB_00_Increment.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);") # bord white and red
self.LAB_00_Numb_Image.setStyleSheet("color : #ffffff; background-color: red; font: bold 10px;") # white red bold
self.LAB_00_Numb_Image.setText("xx : Give angle value")
if endRotation == beginRotation:
# self.groupBox_rot_04_Angles.setStyleSheet("color : #ffff00; background-color: #F66961 ; font: bold 10px;")
if endRotation == 0:
self.PB_01_Decrement_DegBeg.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
self.SPB_02_Angle_Begin_Rotation.setStyleSheet("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("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
self.PB_02_Decrement_DegEnd.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
self.SPB_03_Angle_End_Rotation.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);") # bord white and green
self.PB_02_Increment_DegEnd.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);") # bord white and green
else:
self.PB_01_Decrement_DegBeg.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);") # bord white and green
self.SPB_02_Angle_Begin_Rotation.setStyleSheet("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("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
self.PB_02_Decrement_DegEnd.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
self.SPB_03_Angle_End_Rotation.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);") # bord white and green
self.PB_02_Increment_DegEnd.setStyleSheet("background-color: white; border:2px solid rgb(10, 215, 22);") # bord white and green
if endRotation == 360:
self.PB_02_Increment_DegEnd.setStyleSheet("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("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
#print("endRotation 1")
else:
# self.groupBox_rot_04_Angles.setStyleSheet("background-color: QPalette.Base")
if beginRotation == 0:
self.PB_01_Decrement_DegBeg.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and green
# self.PB_01_Increment_DegBeg.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and red
else:
self.PB_01_Decrement_DegBeg.setStyleSheet("background-color: QPalette.Base")
# self.PB_01_Increment_DegBeg.setStyleSheet("background-color: QPalette.Base")
self.SPB_02_Angle_Begin_Rotation.setStyleSheet("background-color: QPalette.Base")
self.SPB_02_Angle_Begin_Rotation.setEnabled(True)
self.PB_01_Increment_DegBeg.setStyleSheet("background-color: QPalette.Base")
self.PB_02_Decrement_DegEnd.setStyleSheet("background-color: QPalette.Base")
self.SPB_03_Angle_End_Rotation.setStyleSheet("background-color: QPalette.Base")
if endRotation == 360:
self.PB_02_Increment_DegEnd.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and green
else:
self.PB_02_Increment_DegEnd.setStyleSheet("background-color: QPalette.Base")
#print("endRotation 2")
self.PB_Save_Animation.setEnabled(True)
self.PB_Save_Animation.setStyleSheet("background-color: QPalette.Base")
self.groupBox_rot_04_Angles.setGeometry(QtCore.QRect(10, 185, 161, 196))
# App.Console.PrintMessage(str("formuleNumberPhoto ") + "\n")
#### rotation
def on_SPB_01_Angle_Rotation(self,value): #
global valeur
global ui
valeur = value
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_Save_Animation.setStyleSheet("background-color: QPalette.Base") # origin system
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_SPB_01_Angle_Rotation ") + str(valeur) + "\n")
def on_PB_00_Decrement(self): #
global valeur
global ui
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_Save_Animation.setStyleSheet("background-color: QPalette.Base") # origin system
valeur -= 10
if valeur < 0:
valeur = 0
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_PB_00_Decrement ") + str(valeur) + "\n")
def on_PB_00_Increment(self): #
global valeur
global ui
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: QPalette.Base") # origin system
self.PB_Save_Animation.setStyleSheet("background-color: QPalette.Base") # origin system
valeur += 10
if valeur > 360:
valeur = 360
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_PB_00_Increment ") + str(valeur) + "\n")
####
def on_SPB_02_Angle_Begin_Rotation(self,value): #
global valeur
global beginRotation
global endRotation
beginRotation = value
if beginRotation > endRotation:
beginRotation = value = endRotation
self.SPB_02_Angle_Begin_Rotation.setValue(beginRotation)
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_SPB_02_Angle_Begin_Rotation ") + str(value) + "\n")
def on_PB_01_Decrement_DegBeg(self): #
global valeur
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()
# App.Console.PrintMessage(str("on_PB_01_Decrement_DegBeg ") + str(beginRotation) + "\n")
def on_PB_01_Increment_DegBeg(self): #
global valeur
global beginRotation
global endRotation
beginRotation += 10
if beginRotation > endRotation:
beginRotation = endRotation
self.SPB_02_Angle_Begin_Rotation.setValue(beginRotation)
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_PB_01_Increment_DegBeg ") + str(beginRotation) + "\n")
####
def on_SPB_03_Angle_End_Rotation(self,value): #
global valeur
global beginRotation
global endRotation
endRotation = value
if endRotation < beginRotation:
endRotation = value = beginRotation
self.SPB_03_Angle_End_Rotation.setValue(endRotation)
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_SPB_03_Angle_End_Rotation ") + str(endRotation) + "\n")
def on_PB_02_Decrement_DegEnd(self): #
global valeur
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()
# App.Console.PrintMessage(str("on_PB_02_Decrement_DegEnd ") + str(endRotation) + "\n")
def on_PB_02_Increment_DegEnd(self): #
global valeur
global beginRotation
global endRotation
endRotation += 10
if endRotation < beginRotation:
endRotation = beginRotation
if endRotation >= 360:
endRotation = 360
# self.SPB_03_Angle_End_Rotation.setStyleSheet("background-color: white; border:2px solid rgb(215, 10, 22);") # bord white and green
# else:
# self.SPB_03_Angle_End_Rotation.setStyleSheet("background-color: QPalette.Base") # origin system
self.SPB_03_Angle_End_Rotation.setValue(endRotation)
ui.formuleNumberPhoto()
# App.Console.PrintMessage(str("on_PB_02_Increment_DegEnd ") + str(endRotation) + "\n")
####
def on_DSPB_01_Delay_Time(self,value): #
global delayTime
delayTime = value
# App.Console.PrintMessage(str("on_DSPB_01_Delay_Time ") + str(value) + "\n")
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")
# App.Console.PrintMessage(str("on_CB_01_Reverse ") + "\n")
####
def on_SPB_01_Length(self,value): #
self.Length = value
# App.Console.PrintMessage(str("on_SPB_01_Length ") + str(self.Length) + "\n")
def on_SPB_02_Heigth(self,value): #
self.Heigth = value
# App.Console.PrintMessage(str("on_SPB_02_Heigth ") + str(self.Heigth) + "\n")
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)
App.Console.PrintMessage("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("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("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("Ok Color : " + str(self.Color.name())+"\n")
self.PB_02_OriginalBaGr.setStyleSheet("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("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("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("on_PB_02_OriginalBaGr ")+"\n")
def on_PB_02_OriginalBaGr(self):
global ui
self.RB_02_Color.setText(u"Color")
self.PB_02_OriginalBaGr.setStyleSheet("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("on_PB_02_OriginalBaGr ")+"\n")
def on_PB_05_Rotation(self):
if self.groupBox_00_01_00_Rotation.isVisible():
self.groupBox_00_00_00_Image.setTitle("Image options")
self.PB_05_Rotation.setText("Rotation")
self.PB_05_Rotation.setToolTip(u"Go to rotation menu")
self.PB_05_Rotation.setStyleSheet("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("Rotation options")
self.PB_05_Rotation.setText("Quit Rotation")
self.PB_05_Rotation.setToolTip(u"Go to image menu")
self.PB_05_Rotation.setStyleSheet("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("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)
FreeCAD.Console.PrintError("ScreenWikiToolBar is already installed" + "\n")
break
if switchtbar == 0:
switchToolBarActived = 1
self.toolbarScreen = QtWidgets.QToolBar()
self.toolbarScreen.setObjectName("ScreenWikiToolBar")
self.toolbarScreen.setWindowTitle("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.grid_00_01_05.addWidget(self.PB_03C_NewImage, 0, 4, 1, 1)
self.grid_00_01_05.addWidget(self.PB_04_Quit, 0, 5, 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
####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("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 valeur
global axis
global delayTime
global pathFile
global beginRotation
global endRotation
if self.RB_01_3D_View.isChecked(): #3DView
if (valeur != 0):
# self.PB_Save_Animation.setStyleSheet("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
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
centreRotation = s.BoundBox.Center # boundbox center of the object
cam.position.setValue(centreRotation) # boundBox edge selected
except Exception:
#cam.position.setValue(FreeCAD.Vector(0.0,0.0,0.0))
None
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Save 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 GIF Graphic Interchange Format (*.gif);;"
"Image XBM X11 Pixmap (*.xbm);;"
"Image XPM X11 Pixmap (*.xpm);;"
"All files (*.*);;")
if SaveName == "":
App.Console.PrintMessage("Process aborted" + "\n")
else:
####new
pathFile = SaveName[:SaveName.rfind("/") + 1] #= C:/Provisoire400/
dummy = SaveName.split('.') #= ['C:/Provisoire400/image3D', 'png']
formatFichier = "." + dummy[1] #= .png
SaveName = dummy[0] #= C:/Provisoire400/image3D
####new
App.Console.PrintMessage("Axis : " + axis + "\n")
App.Console.PrintMessage("Registration of : " + pathFile + "\n")
App.Console.PrintMessage("Registration of : " + formatFichier + "\n")
App.Console.PrintMessage("Registration of : " + SaveName + "_Animate_..." + "\n")
App.Console.PrintMessage("BackgroundColor : " + str(self.Color) + "\n")
App.Console.PrintMessage("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"
App.Console.PrintMessage("BackGround : " + fondEcran + "\n")
App.Console.PrintMessage("_________________________________________" + "\n")
activeView = FreeCADGui.activeDocument().activeView()
fileCount = 0
compensation = 0
if abs((beginRotation - endRotation) / abs(valeur)) % abs(valeur) != 0:
compensation = abs(valeur)
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 = App.Vector(0.0,0.0,0.0)
None
## 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)
angleRotation = math.radians(valeur)
activeView = FreeCADGui.activeDocument().activeView()
cam = Gui.ActiveDocument.ActiveView.getCameraNode()
for i in range(int(beginRotation), int(endRotation + compensation), int(abs(valeur))):
Gui.updateGui() # rafraichi l'ecran
if self.CB_01_Reverse.isChecked():
angleRotation = -angleRotation
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]),angleRotation)
nrot = cam.orientation.getValue() * rot
cam.orientation = nrot
####
fileCount += 1
fileName = SaveName + "_Animate_" + '%03d_%03d' % (fileCount, (i) ) + "_" + fondEcran + formatFichier
activeView.saveImage(fileName, dim_Horizont, dim_Vertical, fondEcran)
####
time.sleep(delayTime)
if self.CB_02_Original_Position.isChecked():
# try:
# Gui.runCommand('Std_FreezeViews',6) # restitue la vue num x 0.19
# except Exception:
#### 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
App.Console.PrintMessage("_________________________________________" + "\n")
#Draft.makePoint(pointRotation)
else:
App.Console.PrintError("Give one angle value" + "\n")
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(215, 10, 22);") # bord white and green
elif self.RB_02_Object.isChecked(): # Object
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 (valeur != 0):
SaveName, Filter = PySide2.QtWidgets.QFileDialog.getSaveFileName(None, "Save 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 GIF Graphic Interchange Format (*.gif);;"
"Image XBM X11 Pixmap (*.xbm);;"
"Image XPM X11 Pixmap (*.xpm);;"
"All files (*.*);;")
if SaveName == "":
App.Console.PrintMessage("Process aborted" + "\n")
else:
originlPlacement = sel[0].Placement
####new
pathFile = SaveName[:SaveName.rfind("/") + 1] #= C:/Provisoire400/
dummy = SaveName.split('.') #= ['C:/Provisoire400/image3D', 'png']
formatFichier = "." + dummy[1] #= .png
SaveName = dummy[0] #= C:/Provisoire400/image3D
####new
App.Console.PrintMessage("Axis : " + axis + "\n")
App.Console.PrintMessage("Registration of : " + pathFile + "\n")
App.Console.PrintMessage("Registration of : " + formatFichier + "\n")
App.Console.PrintMessage("Registration of : " + SaveName + "_Animate_..." + "\n")
App.Console.PrintMessage("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"
App.Console.PrintMessage("BackGround : " + fondEcran + "\n")
App.Console.PrintMessage("_________________________________________" + "\n")
activeView = FreeCADGui.activeDocument().activeView()
fileCount = 0
compensation = 0
if abs((beginRotation - endRotation) / abs(valeur)) % abs(valeur) != 0:
compensation = abs(valeur)
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)
for i in range(int(beginRotation), int(endRotation + compensation), int(abs(valeur))):
angleRotation = i
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
fileName = SaveName + "_Animate_" + '%03d_%03d' % (fileCount, (angleRotation) ) + "_" + fondEcran + formatFichier
activeView.saveImage(fileName, dim_Horizont, dim_Vertical, fondEcran)
####
time.sleep(delayTime)
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)
for i in range(int(beginRotation), int(endRotation + compensation), int(abs(valeur))):
angleRotation = i
#print(angleRotation)
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
fileName = SaveName + "_Animate_" + '%03d_%03d' % (fileCount, (angleRotation) ) + "_" + fondEcran + formatFichier
activeView.saveImage(fileName, dim_Horizont, dim_Vertical, fondEcran)
####
time.sleep(delayTime)
if self.CB_02_Original_Position.isChecked():
objectRotation.Placement = objectPlacementOrigine # return in original position
App.activeDocument().recompute()
App.Console.PrintMessage("_________________________________________" + "\n")
#Draft.makePoint(pointRotation)
else:
App.Console.PrintError("Give one angle value" + "\n")
self.SPB_01_Angle_Rotation.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(215, 10, 22);") # bord white and green
else:
self.PB_Save_Animation.setStyleSheet("background-color: white;\n"
"border:2px solid rgb(215, 10, 22);") # bord white and green
App.Console.PrintError("\n" + " Select one object : " + "\n"
" Select the axis rotaion, X, Y, Z or D " + "\n"
" Give the angle rotation " + "\n"
" Mode (D)irection, Select First the object to rotate, second the axis " + "\n"
" (or check the '3D View' button) " + "\n" + "\n")
except Exception:
App.Console.PrintError("Give one angle value !" + "\n" + "\n")
self.SPB_01_Angle_Rotation.setStyleSheet("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
# 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);;"
"Image GIF Graphic Interchange Format (*.gif);;"
"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 (*.*);;")
if neutralImage == 0:
counterName = 0
SaveNameMemo = SaveName
switchFollow = 0
if SaveName == "":
App.Console.PrintMessage("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
####
App.Console.PrintMessage("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")
App.Console.PrintMessage("BackGround Current" + "\n")
elif self.RB_02_Color.isChecked():
Gui.activeDocument().activeView().saveImage(SaveNamefileCount, self.Length, self.Heigth, str(self.Color))
App.Console.PrintMessage("BackGround " + self.Color + "\n")
elif (self.RB_03_Transparent.isChecked()):
Gui.activeDocument().activeView().saveImage(SaveNamefileCount, self.Length, self.Heigth, "Transparent")
App.Console.PrintMessage("BackGround Transparent" + "\n")
App.Console.PrintMessage("Saved definition : " + str(self.Length) + " " + str(self.Heigth) + "\n")
App.Console.PrintMessage("File Name : " + SaveNamefileCount + "\n")
except Exception:
App.Console.PrintError("Error write file "+"\n")
#finally:
# file.close()
#self.PB_03B_Follow.setEnabled(True)
App.Console.PrintMessage("__________________________"+"\n")
pathFile = str(os.path.dirname(SaveNamefileCount))
except Exception:
App.Console.PrintError("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()
App.Console.PrintMessage("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(SaveName, "")
except Exception:
try:
App.Console.PrintError("Error Open file " + SaveName + fileCount + "\n")
except Exception:
None
# App.Console.PrintMessage("Image" + "\n")
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
# App.Console.PrintMessage("on_PB_01_SetScreen" + "\n")
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
# App.Console.PrintMessage("on_PB_02_SetScreenTile" + "\n")
def on_PB_04_Quit(self):
global originalState
global parameterBackground
global so
global pathFile
global switchToolBarActived
global switchTitleBoxToolBar
#### 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
#### Config ####
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.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
App.Console.PrintMessage("___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("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("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
FreeCAD.Console.PrintError(__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
FreeCAD.Console.PrintError("ScreenWikiToolBar is already open" + "\n")
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("Mario52", "Screen_Window_Wiki")
originalState.setValue("geometry", mainWindow.saveGeometry())
originalState.setValue("state", mainWindow.saveState())
##################
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("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("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

This comment has been minimized.

Copy link
Owner Author

@mario52a mario52a commented Mar 21, 2020

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

This comment has been minimized.

Copy link

@berhoel 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

This comment has been minimized.

Copy link
Owner Author

@mario52a 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
You can’t perform that action at this time.