Macro FCTreeView: Difference between revisions
m (date) |
(Marked this version for translation) |
||
(27 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
|||
{{Macro|Icon=Macro FCTreeView|Name=Macro FCTreeView|Description=This macro display all object of the project in one list with options sort search by name label...|Author=Mario52|Version=00.03|Date=23/09/2017}} |
|||
|Name=Macro FCTreeView |
|||
</translate> |
|||
|Icon=Macro_FCTreeView.png |
|||
<translate> |
|||
|Description={{ColoredText|#ff0000|#ffffff|New version GUI modifyed for the HD dpi (QGridLayout) run only FC version 0.18 and more (PySide2 Qt5)}} <br/> <br/>Macro for list all objects in the project in one list without hierarchy, options sort by name, label, visibility, group, by length option search by name, label .... without case sensitive or with case sensitive and select all objects displayed in the macro window. <br/> <br/>For the precedent version see [https://gist.githubusercontent.com/mario52a/67517ef758ff20005d0a6adcfd8c9190/raw/0a92d7f591a0a179f84b2fc417046723b4d7b0e6/Macro_FCTreeView.FCMacro Macro_FCTreeView.FCMacro] and install it manually. |
|||
|Author=Mario52 |
|||
|Version=00.09 |
|||
|Date=2020-09-24 |
|||
|FCVersion=0.18 and below |
|||
|Download=[https://forum.freecadweb.org/download/file.php?id=70498 Macro FCTreeView Icon package] unzip the .zip file and copy the icon in your macro directory. |
|||
}} |
|||
==Description== <!--T:2--> |
==Description== <!--T:2--> |
||
</translate> |
|||
<translate> |
|||
<!--T:3--> |
<!--T:3--> |
||
Macro for list all objects in the project in one list without hierarchy, options sort by name, label, visibility, group, by length option search by name, label .... without case sensitive or with case sensitive and select all objects displayed in the macro window. |
Macro for list all objects in the project in one list without hierarchy, options sort by name, label, visibility, group, by length option search by name, label .... without case sensitive or with case sensitive and select all objects displayed in the macro window. |
||
</translate> |
</translate> |
||
{{Codeextralink|https://gist.githubusercontent.com/mario52a/67517ef758ff20005d0a6adcfd8c9190/raw/59bc2028978c82744c83c6b138ab3ef30e0bf6f3/Macro_FCTreeView.FCMacro}} |
|||
<translate> |
<translate> |
||
==How To Use== <!--T:4--> |
==How To Use== <!--T:4--> |
||
</translate> |
|||
<!--T:73--> |
|||
[[File:FCTreeView.gif |Macro FCTreeView]] |
[[File:FCTreeView.gif |Macro FCTreeView]] |
||
{{clear}} |
{{clear}} |
||
<translate> |
|||
===Section '''Window'''=== <!--T:5--> |
===Section '''Window'''=== <!--T:5--> |
||
</translate> |
|||
<translate> |
|||
<!--T:6--> |
<!--T:6--> |
||
The title display the option, number and type object(s) displayed |
The title display the option, number and type object(s) displayed |
||
Line 135: | Line 143: | ||
<!--T:39--> |
<!--T:39--> |
||
*'''("NLwsc")''' : Search by Name and Label in Word and respecting the '''S'''ensitive '''C'''ase (same panel selection of FreeCAD) |
*'''("NLwsc")''' : Search by Name and Label in Word and respecting the '''S'''ensitive '''C'''ase (same panel selection of FreeCAD) |
||
<!--T:53--> |
|||
*'''(Nu)''' : Search by numeric value (radius, length, angle .....) see version section |
|||
<!--T:40--> |
<!--T:40--> |
||
Line 141: | Line 152: | ||
<!--T:41--> |
<!--T:41--> |
||
{{KEY|[[File:Macro FCTreeView 24.png|18px]] Unselected}} flip/flop Unselected all object(s) |
{{KEY|[[File:Macro FCTreeView 24.png|18px]] Unselected}} flip/flop Unselected all object(s) |
||
<!--T:56--> |
|||
{{KEY|[[File:Macro FCTreeView 25.png|18px]] S Sheet}} access in Spreadsheet options |
|||
</translate> |
|||
<translate> |
|||
===The SpreadSheet options:=== <!--T:57--> |
|||
</translate> |
|||
[[File:TreeView_SpeadSheet.gif |Macro FCTreeView]] |
|||
{{clear}} |
|||
<translate> |
|||
<!--T:58--> |
|||
[[File:Macro FCTreeView 001.png]] |
|||
<!--T:59--> |
|||
[[File:Macro FCTreeView 002.png]] |
|||
* CheckBox options for select the data to save in spreadsheet |
|||
<!--T:70--> |
|||
{{KEY|[[File:Macro FCTreeView 28.png|18px]] Select}} : Select all checkBox option to save |
|||
<!--T:71--> |
|||
{{KEY|[[File:Macro FCTreeView 29.png|18px]] Select}} : unSelect all checkBox option to save |
|||
<!--T:60--> |
|||
[[File:Macro FCTreeView 003.png]] |
|||
* '''Value''' : alone the value is saved in the cell |
|||
** Ex : 10.00 [[File:Macro FCTreeView 30.png]] |
|||
* '''Val Gr''' : the value and the unit are saved in unique cell |
|||
** Ex : 10.00 mm [[File:Macro FCTreeView 31.png]] |
|||
* '''Val Gr Ph''' : the value, the unit and the physic data is saved in unique cell |
|||
** Ex : 10.00 mm Length [[File:Macro FCTreeView 32.png]] |
|||
* '''Split''' : if the Split checkBox is checked, the data is cut saved in separate cell |
|||
** Ex : 10.00 | mm | length [[File:Macro FCTreeView 33.png]] |
|||
<!--T:61--> |
|||
[[File:Macro FCTreeView 004.png]] |
|||
* Combobox '''mm''' : select the unit length desired. The value is convert in the selected unit. The units length available are: |
|||
** km, hm, dam, m, dm, cm, '''mm''', um, nm, pm, fm, in, lk, ft, yd, rd, ch, fur, mi, lea, nmi |
|||
* Combobox '''gram''' : select the unit weight desired. The value is convert in the selected unit. The units weight available are: |
|||
** t, q, kg, hg, dag, '''g''', dg, cg, mg, µg, ng, pg, fg, gr, dr, oz, oz t, lb, t lb, st, qtr, cwt, tonneau fr, ct |
|||
* Spinbox '''Densite''' : give the density by dm3 of the material used (Default : 1.0000) |
|||
* Spinbox '''Round''' : give the round value desired (Default : 3) |
|||
<!--T:62--> |
|||
[[File:Macro FCTreeView 005.png]] |
|||
* Combobox '''Name spreadSheet''' : List the spreadsheet in the document |
|||
* Line edit '''Name spreadSheet''' : Display the actual spreadsheet or give the name for the new spreadsheet |
|||
<!--T:63--> |
|||
[[File:Macro FCTreeView 006.png]] |
|||
<!--T:64--> |
|||
{{KEY|[[File:Macro FCTreeView 28.png|18px]] Select}} select all checkbox options |
|||
<!--T:65--> |
|||
{{KEY|[[File:Macro FCTreeView 29.png|18px]] Unselect}} unselected all checkbox options |
|||
<!--T:66--> |
|||
{{KEY|[[File:Macro FCTreeView 27.png|18px]] Save}} save the data in Spreadsheet displayed. if no spreadsheet is active the spreadsheet named '''FCSpreadSheet''' is created |
|||
<!--T:67--> |
|||
{{KEY|[[File:Macro FCTreeView 26.png|18px]] Quit}} quit the Spreadsheet options |
|||
</translate> |
</translate> |
||
<translate> |
<translate> |
||
Line 149: | Line 226: | ||
The icon must be copied into the same directory as the macro |
The icon must be copied into the same directory as the macro |
||
</translate> |
</translate> |
||
[https://forum.freecadweb.org/download/file.php?id=70498 Macro_FCTreeView_Icon] |
|||
[[File:Macro FCTreeView 00.png|Icon used for the Name of object]] [[File:Macro FCTreeView 01.png|Icon used for visualise if the object is status Visible (mouse click for Hidden)]] |
[[File:Macro FCTreeView 00.png|Icon used for the Name of object]] [[File:Macro FCTreeView 01.png|Icon used for visualise if the object is status Visible (mouse click for Hidden)]] |
||
Line 174: | Line 252: | ||
[[File:Macro FCTreeView 23.png|Icon used for Selected all object(s) displayed in the window]] |
[[File:Macro FCTreeView 23.png|Icon used for Selected all object(s) displayed in the window]] |
||
[[File:Macro FCTreeView 24.png|Icon used for Unselected all object(s)]] |
[[File:Macro FCTreeView 24.png|Icon used for Unselected all object(s)]] |
||
[[File:Macro FCTreeView 25.png|Icon used for access in Spreadsheet options]] |
|||
[[File:Macro FCTreeView 26.png|Icon used for quit the Spreadsheet options]] |
|||
[[File:Macro FCTreeView 27.png|Icon used for save the data in Spreadsheet]] |
|||
[[File:Macro FCTreeView 28.png|Icon used for select all checkbox options]] |
|||
[[File:Macro FCTreeView 29.png|Icon used for unselected all checkbox options]] |
|||
[[File:Macro FCTreeView 30.png|Icon used for save the value data in Spreadsheet]] |
|||
[[File:Macro FCTreeView 31.png|Icon used for save the value and Unit data in Spreadsheet]] |
|||
[[File:Macro FCTreeView 32.png|Icon used for save the value, Unit and type data in Spreadsheet]] |
|||
[[File:Macro FCTreeView 33.png|Icon used for split the value, Unit and type in cell separate in Spreadsheet]] |
|||
<translate> |
<translate> |
||
Line 182: | Line 269: | ||
<!--T:50--> |
<!--T:50--> |
||
The macro is located in right dock for change it modify the value line |
The macro is located in right dock for change it modify the value line number 133 '''testing = 0''' (or change it with the mouse as a widget normal) |
||
</translate> |
</translate> |
||
The icon ToolBar [[File:Macro FCTreeView.png|Macro FCTreeView]] |
The icon ToolBar [[File:Macro FCTreeView.png|Macro FCTreeView]] |
||
''' |
'''Macro_FCTreeView.FCMacro''' |
||
{{Code|code= |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
# |
|||
""" |
|||
*************************************************************************** |
|||
* Copyright (c) 2017 <mario52> * |
|||
* * |
|||
* This file is a supplement to the FreeCAD CAx development system. * |
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU Lesser General Public License (LGPL) * |
|||
* as published by the Free Software Foundation; either version 2 of * |
|||
* the License, or (at your option) any later version. * |
|||
* for detail see the LICENCE text file. * |
|||
* * |
|||
* This software is distributed in the hope that it will be useful, * |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|||
* GNU Library General Public License for more details. * |
|||
* * |
|||
* You should have received a copy of the GNU Library General Public * |
|||
* License along with this macro; if not, write to the Free Software * |
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
|||
* USA * |
|||
*************************************************************************** |
|||
* WARNING! All changes in this file will be lost and * |
|||
* may cause malfunction of the program * |
|||
*************************************************************************** |
|||
""" |
|||
#Macro_ 29/08/2017 /_00 |
|||
# |
|||
#OS: Windows 10 |
|||
#Word size of OS: 64-bit |
|||
#Word size of FreeCAD: 64-bit |
|||
#Version: 0.16.6712 (Git) |
|||
#Build type: Release |
|||
#Branch: releases/FreeCAD-0-16 |
|||
#Hash: da2d364457257a7a8c6fb2137cea12c45becd71a |
|||
#Python version: 2.7.8 |
|||
#Qt version: 4.8.7 |
|||
#Coin version: 4.0.0a |
|||
#OCC version: 6.8.0.oce-0.17 |
|||
# |
|||
__title__ = "Macro_FCTreeView" |
|||
__author__ = "Mario52" |
|||
__url__ = "http://www.freecadweb.org/index-fr.html" |
|||
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_FCTreeView" |
|||
__version__ = "00.03" |
|||
__date__ = "23/09/2017" |
|||
# |
|||
import PySide |
|||
from PySide import QtGui ,QtCore |
|||
from PySide.QtGui import * |
|||
from PySide.QtCore import * |
|||
import time |
|||
from pivy import coin |
|||
{{CodeDownload|https://gist.github.com/mario52a/67517ef758ff20005d0a6adcfd8c9190|Macro_FCTreeView.FCMacro}} |
|||
from PySide import QtSvg, QtXml |
|||
import copy # pour copier 2 tableaux |
|||
import operator |
|||
from operator import itemgetter, attrgetter, methodcaller # pour sort |
|||
<translate> |
|||
#### |
|||
==To do== <!--T:45--> |
|||
#from PySide import QtCore |
|||
</translate> |
|||
#global langue |
|||
<translate> |
|||
#s=QtCore.QLocale() |
|||
<!--T:46--> |
|||
#s.countryToString(s.country()) |
|||
<strike>Docked the macro</strike> |
|||
#s.name() |
|||
</translate> |
|||
#langue = s.languageToString(s.language()) |
|||
<translate> |
|||
#print s.name() # fr |
|||
==Version== <!--T:47--> |
|||
#print langue # French |
|||
#### |
|||
<!--T:76--> |
|||
import time |
|||
ver 00.09 (2020-09-24) : correct the "'''freeze'''" macro after call the '''assembly4 workbench''' i try activate "'''Class SelObserver'''" and it work ??? |
|||
</translate> |
|||
Gui = FreeCADGui |
|||
{{Code|code= |
|||
App = FreeCAD |
|||
class SelObserver: |
|||
def addSelection(self, document, object, element, position): # Selection |
|||
global ui ; ui = "" |
|||
global sourisPass |
|||
global doc ; doc = "" |
|||
global sourisPass ; sourisPass = 0 |
|||
global listeObjetsOriginal ; listeObjetsOriginal = [[]] # objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
global listeSorted ; listeSorted = [[]] # objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
global listeByStringSear ; listeByStringSear = [] # object searched |
|||
global titre ; titre = " Original" |
|||
global derouler ; derouler = 0 |
|||
global visibilite ; visibilite = 0 |
|||
global group ; group = 0 |
|||
global searchString ; searchString = "" |
|||
global SplitNameLabel ; SplitNameLabel = 0 |
|||
global selections ; selections = 0 |
|||
global reverse_00 ; reverse_00 = 0 |
|||
global reverse_01 ; reverse_01 = 0 |
|||
global reverse_02 ; reverse_02 = 0 |
|||
global reverse_03 ; reverse_03 = 0 |
|||
global testing ; testing = 2 # if testing == 1 MainWindow separate |
|||
# if testing == 2 RightDock |
|||
# else == other LeftDock |
|||
try: |
|||
_fromUtf8 = QtCore.QString.fromUtf8 |
|||
except AttributeError: |
|||
def _fromUtf8(s): |
|||
return s |
|||
try: |
|||
_encoding = QtGui.QApplication.UnicodeUTF8 |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|||
except AttributeError: |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig) |
|||
class Ui_MainWindow(object): |
|||
def __init__(self, MainWindow): |
|||
self.window = MainWindow |
|||
############# |
|||
#self.path = FreeCAD.ConfigGet("AppHomePath") |
|||
#self.path = FreeCAD.ConfigGet("UserAppData") |
|||
#self.path = "your path" |
|||
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro") # macro path |
|||
self.path = param.GetString("MacroPath","") + "/" # macro path |
|||
self.path = self.path.replace("\\","/") |
|||
# print "Path for the icons : " , self.path |
|||
############# |
|||
self.iconName = QtGui.QIcon(self.path + "Macro_FCTreeView_00.png") |
|||
self.iconTrue = QtGui.QIcon(self.path + "Macro_FCTreeView_01.png") |
|||
self.iconFalse = QtGui.QIcon(self.path + "Macro_FCTreeView_02.png") |
|||
self.iconChain = QtGui.QIcon(self.path + "Macro_FCTreeView_03.png") |
|||
self.iconChainCut = QtGui.QIcon(self.path + "Macro_FCTreeView_04.png") |
|||
self.iconLabel = QtGui.QIcon(self.path + "Macro_FCTreeView_05.png") |
|||
self.iconVisible = QtGui.QIcon(self.path + "Macro_FCTreeView_06.png") |
|||
self.iconPaChain = QtGui.QIcon(self.path + "Macro_FCTreeView_07.png") |
|||
self.iconFolder = QtGui.QIcon(self.path + "Macro_FCTreeView_17.png") |
|||
# self.vueActive = FreeCADGui.ActiveDocument.ActiveView |
|||
# self.click = self.vueActive.addEventCallback("SoMouseButtonEvent",self.souris) |
|||
# def souris(self,info): |
|||
# global sourisPass |
|||
# #print "ok2" |
|||
# ##{'ShiftDown': False, 'Button': 'BUTTON1', 'CtrlDown': False, 'State': 'UP', 'Time': 'Sunday, July 23, 2017 21:43:39', 'Position': (479, 354), 'AltDown': False, 'Type': 'SoMouseButtonEvent'} |
|||
# if (info["Button"] == "BUTTON1") and (info["State"] == "DOWN"): |
|||
# sourisPass = 0 |
|||
# #print "ok3" |
|||
# |
|||
def setupUi(self, MainWindow): |
|||
global testing |
|||
self.window = MainWindow |
|||
if testing == 1: |
|||
MainWindow.setObjectName(_fromUtf8("MainWindow")) # volant |
|||
MainWindow.resize(341, 619) |
|||
MainWindow.setMinimumSize(QtCore.QSize(341,619)) |
|||
MainWindow.setMaximumSize(QtCore.QSize(341,619)) |
|||
MainWindow.move(950, 120) # deplace la fenetre |
|||
self.centralwidget = QtGui.QWidget(MainWindow) |
|||
self.centralwidget.resize(341, 665) |
|||
# self.centralwidget.setMinimumSize(QtCore.QSize(341,665)) |
|||
# self.centralwidget.setMaximumSize(QtCore.QSize(341,665)) |
|||
# self.centralwidget.setBaseSize(QtCore.QSize(20, 20)) |
|||
self.centralwidget.setObjectName(_fromUtf8("centralWidget")) |
|||
########## |
|||
self.fontGlobal_08 = QtGui.QFont() # pour compatibilite Windows Linux pour tous les textes |
|||
self.fontGlobal_08.setFamily("Arial") # pour compatibilite Windows Linux pour tous les textes |
|||
self.fontGlobal_08.setPointSize(8.0) # pour compatibilite Windows Linux pour tous les textes |
|||
#self.xxxxx.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
########## |
|||
self.treeWidget = QtGui.QTreeWidget(self.centralwidget) |
|||
#self.treeWidget.setGeometry(QtCore.QRect(10, 10, 321, 400)) # volant |
|||
self.treeWidget.setGeometry(QtCore.QRect(10, 25, 321, 361)) |
|||
#self.treeWidget.setSortingEnabled(True) #sort by clicked title |
|||
#__sortingEnabled = self.treeWidget.isSortingEnabled() #sort by clicked title |
|||
#self.treeWidget.setSortingEnabled(__sortingEnabled) #sort by clicked title |
|||
#self.treeWidget.header().setSortIndicatorShown(True) #sort by clicked title |
|||
# self.treeWidget.setMaximumSize(QtCore.QSize(600, 600)) |
|||
self.treeWidget.setObjectName(_fromUtf8("treeWidget")) |
|||
self.treeWidget.setLineWidth(6) |
|||
self.treeWidget.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.treeWidget.setDefaultDropAction(QtCore.Qt.CopyAction) |
|||
self.treeWidget.setAlternatingRowColors(True) |
|||
self.treeWidget.setIconSize(QtCore.QSize(12, 12)) # icon dimensions |
|||
self.treeWidget.setAnimated(True) |
|||
self.treeWidget.header().sectionSize(1200) |
|||
self.treeWidget.header().setDefaultSectionSize(1200) |
|||
self.treeWidget.header().setMinimumSectionSize(1200) # dimension fenetre interne |
|||
self.treeWidget.header().setCascadingSectionResizes(True) |
|||
self.treeWidget.header().setHighlightSections(True) |
|||
self.treeWidget.header().setStretchLastSection(True) |
|||
self.treeWidget.header().setMovable(True) |
|||
self.treeWidget.clicked.connect(self.on_treeWidget_clicked) # connect on_treeWidget_clicked |
|||
self.groupBox_Sort = QtGui.QGroupBox(self.centralwidget) |
|||
self.groupBox_Sort.setGeometry(QtCore.QRect(10, 391, 321, 46)) |
|||
self.groupBox_Sort.setObjectName(_fromUtf8("groupBox_Sort")) |
|||
self.PB_Sort_00 = QtGui.QPushButton(self.groupBox_Sort) |
|||
self.PB_Sort_00.setGeometry(QtCore.QRect(5, 15, 58, 23)) |
|||
self.PB_Sort_00.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_10.png")) |
|||
self.PB_Sort_00.setFont(self.fontGlobal_08) |
|||
self.PB_Sort_00.setObjectName(_fromUtf8("PB_Sort_00")) |
|||
self.PB_Sort_00.clicked.connect(self.on_PB_Sort_00_clicked) |
|||
self.PB_Sort_01 = QtGui.QPushButton(self.groupBox_Sort) |
|||
self.PB_Sort_01.setGeometry(QtCore.QRect(66, 15, 58, 23)) |
|||
self.PB_Sort_01.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_11.png")) |
|||
self.PB_Sort_01.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Sort_01.setObjectName(_fromUtf8("PB_Quit")) |
|||
self.PB_Sort_01.clicked.connect(self.on_PB_Sort_01_clicked) |
|||
self.PB_Sort_02 = QtGui.QPushButton(self.groupBox_Sort) |
|||
self.PB_Sort_02.setGeometry(QtCore.QRect(126, 15, 58, 23)) |
|||
self.PB_Sort_02.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_12.png")) |
|||
self.PB_Sort_02.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Sort_02.setObjectName(_fromUtf8("PB_Sort_02")) |
|||
self.PB_Sort_02.clicked.connect(self.on_PB_Sort_02_clicked) |
|||
self.PB_Sort_03 = QtGui.QPushButton(self.groupBox_Sort) |
|||
self.PB_Sort_03.setGeometry(QtCore.QRect(187, 15, 58, 23)) |
|||
self.PB_Sort_03.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_13.png")) |
|||
self.PB_Sort_03.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Sort_03.setObjectName(_fromUtf8("PB_Sort_03")) |
|||
self.PB_Sort_03.clicked.connect(self.on_PB_Sort_03_clicked) |
|||
self.CB_Length = QtGui.QCheckBox(self.groupBox_Sort) |
|||
self.CB_Length.setGeometry(QtCore.QRect(248, 19, 110, 20)) |
|||
self.CB_Length.setObjectName(_fromUtf8("CB_Length")) |
|||
self.CB_Length.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.CB_Length.setChecked(False) |
|||
self.CB_Length.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_19.png")) |
|||
self.groupBox_Global = QtGui.QGroupBox(self.centralwidget) |
|||
self.groupBox_Global.setGeometry(QtCore.QRect(10, 440, 321, 71)) |
|||
self.groupBox_Global.setObjectName(_fromUtf8("groupBox_Global")) |
|||
# self.PB_Reverse = QtGui.QPushButton(self.groupBox_Global) |
|||
# self.PB_Reverse.setGeometry(QtCore.QRect(5, 15, 75, 23)) |
|||
# self.PB_Reverse.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_08.png")) |
|||
# self.PB_Reverse.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
# self.PB_Reverse.setObjectName(_fromUtf8("PB_Reverse")) |
|||
# self.PB_Reverse.clicked.connect(self.on_PB_Reverse_clicked) |
|||
self.PB_SplitName = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_SplitName.setGeometry(QtCore.QRect(5, 15, 75, 23)) |
|||
self.PB_SplitName.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_22.png")) |
|||
self.PB_SplitName.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_SplitName.setObjectName(_fromUtf8("PB_SplitName")) |
|||
self.PB_SplitName.clicked.connect(self.on_PB_SplitName_clicked) |
|||
self.PB_Expend = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_Expend.setGeometry(QtCore.QRect(84, 15, 75, 23)) |
|||
self.PB_Expend.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_15.png")) |
|||
self.PB_Expend.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Expend.setObjectName(_fromUtf8("PB_Expend")) |
|||
self.PB_Expend.clicked.connect(self.on_PB_Expend_clicked) |
|||
self.PB_Visibility = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_Visibility.setGeometry(QtCore.QRect(162, 15, 75, 23)) |
|||
self.PB_Visibility.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_06.png")) |
|||
self.PB_Visibility.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Visibility.setObjectName(_fromUtf8("PB_Visibility")) |
|||
self.PB_Visibility.clicked.connect(self.on_PB_Visibility_clicked) |
|||
self.PB_Group = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_Group.setGeometry(QtCore.QRect(241, 15, 75, 23)) |
|||
self.PB_Group.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_07.png")) |
|||
self.PB_Group.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Group.setObjectName(_fromUtf8("PB_Group")) |
|||
self.PB_Group.clicked.connect(self.on_PB_Group_clicked) |
|||
self.PB_Reload = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_Reload.setGeometry(QtCore.QRect(5, 40, 75, 23)) |
|||
self.PB_Reload.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_16.png")) |
|||
self.PB_Reload.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Reload.setObjectName(_fromUtf8("PB_Reload")) |
|||
self.PB_Reload.clicked.connect(self.on_PB_Reload_clicked) |
|||
self.PB_Original = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_Original.setGeometry(QtCore.QRect(84, 40, 75, 23)) |
|||
self.PB_Original.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_18.png")) |
|||
self.PB_Original.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Original.setObjectName(_fromUtf8("PB_Original")) |
|||
self.PB_Original.clicked.connect(self.on_PB_Original_clicked) |
|||
self.PB_All_Visible = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_All_Visible.setGeometry(QtCore.QRect(162, 40, 75, 23)) |
|||
self.PB_All_Visible.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_01.png")) |
|||
self.PB_All_Visible.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_All_Visible.setObjectName(_fromUtf8("PB_All_Visible")) |
|||
self.PB_All_Visible.clicked.connect(self.on_PB_All_Visible_clicked) |
|||
self.PB_All_Hidden = QtGui.QPushButton(self.groupBox_Global) |
|||
self.PB_All_Hidden.setGeometry(QtCore.QRect(241, 40, 75, 23)) |
|||
self.PB_All_Hidden.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_02.png")) |
|||
self.PB_All_Hidden.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_All_Hidden.setObjectName(_fromUtf8("PB_Original")) |
|||
self.PB_All_Hidden.clicked.connect(self.on_PB_All_Hidden_clicked) |
|||
self.groupBox_Search = QtGui.QGroupBox(self.centralwidget) |
|||
self.groupBox_Search.setGeometry(QtCore.QRect(10, 514, 321, 101)) |
|||
self.groupBox_Search.setObjectName(_fromUtf8("groupBox_Search")) |
|||
self.lineEdit_Search = QtGui.QLineEdit(self.groupBox_Search) |
|||
self.lineEdit_Search.setGeometry(QtCore.QRect(5, 15, 231, 21)) |
|||
self.lineEdit_Search.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.lineEdit_Search.setObjectName(_fromUtf8("lineEdit_Search")) |
|||
# self.lineEdit_Search.returnPressed.connect(self.on_lineEdit_Search_Pressed) # for validate the data with press on return touch |
|||
self.lineEdit_Search.textChanged.connect(self.on_lineEdit_Search_Pressed) # with tips key char by char |
|||
self.PB_ClearLEdit = QtGui.QPushButton(self.groupBox_Search) |
|||
self.PB_ClearLEdit.setGeometry(QtCore.QRect(240, 14, 75, 23)) |
|||
self.PB_ClearLEdit.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_ClearLEdit.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_20.png")) |
|||
self.PB_ClearLEdit.setObjectName(_fromUtf8("PB_ClearLEdit")) |
|||
self.PB_ClearLEdit.clicked.connect(self.on_PB_ClearLEdit_clicked) |
|||
self.frame_Options = QtGui.QFrame(self.groupBox_Search) |
|||
self.frame_Options.setGeometry(QtCore.QRect(5, 40, 231, 23)) |
|||
self.frame_Options.setFrameShape(QtGui.QFrame.StyledPanel) |
|||
self.frame_Options.setFrameShadow(QtGui.QFrame.Plain) |
|||
self.frame_Options.setObjectName(_fromUtf8("frame_Options")) |
|||
self.RB_01_NameLabel = QtGui.QRadioButton(self.frame_Options) |
|||
self.RB_01_NameLabel.setGeometry(QtCore.QRect(5, 4, 43, 17)) |
|||
self.RB_01_NameLabel.setObjectName(_fromUtf8("RB_01_NameLabel")) |
|||
self.RB_01_NameLabel.setChecked(True) |
|||
self.RB_01_NameLabel.clicked.connect(self.on_RB_Pressed) |
|||
self.RB_02_Name_CS = QtGui.QRadioButton(self.frame_Options) |
|||
self.RB_02_Name_CS.setGeometry(QtCore.QRect(49, 4, 43, 17)) |
|||
self.RB_02_Name_CS.setObjectName(_fromUtf8("RB_02_Name_CS")) |
|||
self.RB_02_Name_CS.clicked.connect(self.on_RB_Pressed) |
|||
self.RB_03_Label_NC = QtGui.QRadioButton(self.frame_Options) |
|||
self.RB_03_Label_NC.setGeometry(QtCore.QRect(94, 4, 43, 17)) |
|||
self.RB_03_Label_NC.setObjectName(_fromUtf8("RB_03_Label_NC")) |
|||
self.RB_03_Label_NC.clicked.connect(self.on_RB_Pressed) |
|||
self.RB_04_NamLabel_CS = QtGui.QRadioButton(self.frame_Options) |
|||
self.RB_04_NamLabel_CS.setGeometry(QtCore.QRect(139, 4, 43, 17)) |
|||
self.RB_04_NamLabel_CS.setObjectName(_fromUtf8("RB_04_NamLabel_CS")) |
|||
self.RB_04_NamLabel_CS.clicked.connect(self.on_RB_Pressed) |
|||
self.RB_05_NameLabel_AL = QtGui.QRadioButton(self.frame_Options) |
|||
self.RB_05_NameLabel_AL.setGeometry(QtCore.QRect(184, 4, 43, 17)) |
|||
self.RB_05_NameLabel_AL.setObjectName(_fromUtf8("RB_05_NameLabel_AL")) |
|||
self.RB_05_NameLabel_AL.clicked.connect(self.on_RB_Pressed) |
|||
self.PB_Select = QtGui.QPushButton(self.groupBox_Search) |
|||
self.PB_Select.setGeometry(QtCore.QRect(240, 40, 75, 23)) |
|||
self.PB_Select.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Select.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_23.png")) |
|||
self.PB_Select.setObjectName(_fromUtf8("PB_Select")) |
|||
self.PB_Select.clicked.connect(self.on_PB_Select_clicked) |
|||
self.comboBox = QtGui.QComboBox(self.groupBox_Search) |
|||
# self.comboBox.setGeometry(QtCore.QRect(5, 70, 231, 23)) |
|||
self.comboBox.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.comboBox.setObjectName(_fromUtf8("comboBox")) |
|||
self.comboBox.addItem(_fromUtf8("")) |
|||
self.comboBox.currentIndexChanged.connect(self.SIGNAL_comboType_Changed) |
|||
self.label_Ver = QtGui.QLabel(self.centralwidget) |
|||
self.label_Ver.setObjectName(_fromUtf8("label_Ver")) |
|||
if testing == 1: |
|||
self.comboBox.setGeometry(QtCore.QRect(5, 70, 231, 23)) |
|||
self.label_Ver.setGeometry(QtCore.QRect(10, 5, 250, 16)) |
|||
self.PB_Quit = QtGui.QPushButton(self.groupBox_Search) |
|||
self.PB_Quit.setGeometry(QtCore.QRect(240, 70, 75, 23)) |
|||
self.PB_Quit.setFont(self.fontGlobal_08) # pour compatibilite W L |
|||
self.PB_Quit.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_09.png")) |
|||
self.PB_Quit.setObjectName(_fromUtf8("PB_Quit")) |
|||
self.PB_Quit.setText("Quit") |
|||
self.PB_Quit.setToolTip("Quit FCTreeView <img src=" + self.path + "Macro_FCTreeView_09.png" + " />") |
|||
self.PB_Quit.clicked.connect(self.on_PB_Quit_clicked) |
|||
else: |
|||
self.comboBox.setGeometry(QtCore.QRect(5, 70, 310, 23)) |
|||
self.label_Ver.setGeometry(QtCore.QRect(10, 615, 250, 16)) |
|||
self.retranslateUi(MainWindow) |
|||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|||
if testing == 1: |
|||
MainWindow.setCentralWidget(self.centralwidget) |
|||
# self.retranslateUi(MainWindow) |
|||
# QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|||
def retranslateUi(self, MainWindow): |
|||
# MainWindow.setWindowTitle("FCTreeView (" + __version__ + " (" + __date__ + "))") |
|||
MainWindow.setWindowTitle("FCTreeView") |
|||
MainWindow.setWindowIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_18.png")) # change l'icone de la fenetre principale |
|||
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenetre en avant |
|||
self.treeWidget.setToolTip("The title display the option, number and type object(s) displayed" + "\n" + "\n" |
|||
"O = Objects" + "\n" |
|||
"N = Name" + "\n" |
|||
"L = Label" + "\n" |
|||
"T = Total" + "\n" |
|||
"G = Group" + "\n" |
|||
"S = Single" + "\n" |
|||
"V = Visible" + "\n" |
|||
"H = Hidden" + "\n\n" |
|||
"If one object are selected :" + "\n" |
|||
"the Placement Base, Rotation and Center of mass is displayed" + "\n" |
|||
"if available !") |
|||
self.groupBox_Sort.setTitle("Sort by:") |
|||
self.PB_Sort_00.setText("Name") |
|||
self.PB_Sort_00.setToolTip("<img src=" + self.path + "Macro_FCTreeView_10.png" + " />" + "\n" |
|||
"Sort by <b>Name</b>") |
|||
self.PB_Sort_01.setText("Label") |
|||
self.PB_Sort_01.setToolTip("<img src=" + self.path + "Macro_FCTreeView_11.png" + " />" + "\n" |
|||
"Sort by <b>Label</b>") |
|||
self.PB_Sort_02.setText("Visible") |
|||
self.PB_Sort_02.setToolTip("<img src=" + self.path + "Macro_FCTreeView_12.png" + " />" + "\n" |
|||
"Sort by <b>Visibility</b>") |
|||
self.PB_Sort_03.setText("Group") |
|||
self.PB_Sort_03.setToolTip("<img src=" + self.path + "Macro_FCTreeView_13.png" + " />" + "\n" |
|||
"Sort by <b>Group</b>") |
|||
self.CB_Length.setText("Length") |
|||
self.CB_Length.setToolTip("<img src=" + self.path + "Macro_FCTreeView_19.png" + " />" + "\n" |
|||
"If Checked sort by string length") |
|||
self.groupBox_Global.setTitle("Global") |
|||
# self.PB_Reverse.setText("Reverse") |
|||
# self.PB_Reverse.setToolTip("<img src=" + self.path + "Macro_FCTreeView_08.png" + " />" + "\n" |
|||
# "Reverse the data listing") |
|||
self.PB_SplitName.setText("Split") |
|||
self.PB_SplitName.setToolTip("<img src=" + self.path + "Macro_FCTreeView_21.png" + " />" + "\n" |
|||
"Split name and label") |
|||
self.PB_Expend.setText("Expend") |
|||
self.PB_Expend.setToolTip("<img src=" + self.path + "Macro_FCTreeView_15.png" + " />" + "\n" |
|||
"Expend the listing objects") |
|||
self.PB_Visibility.setText("Visibility") |
|||
self.PB_Visibility.setToolTip("<img src=" + self.path + "Macro_FCTreeView_06.png" + " />" + "\n" |
|||
"The first icon display the visibility or not") |
|||
self.PB_Group.setText("Group") |
|||
self.PB_Group.setToolTip("<img src=" + self.path + "Macro_FCTreeView_07.png" + " />" + "\n" |
|||
"The first icon display the group or not") |
|||
self.PB_Reload.setText("Reload") |
|||
self.PB_Reload.setToolTip("<img src=" + self.path + "Macro_FCTreeView_16.png" + " />" + "\n" |
|||
"Reload the <b>ACTUAL VIEW</b> on 3D Screen") |
|||
self.PB_Original.setText("Original") |
|||
self.PB_Original.setToolTip("<img src=" + self.path + "Macro_FCTreeView_18.png" + " />" + "\n" |
|||
"Return to original objects organisation and visibility") |
|||
self.PB_All_Visible.setText("All Visible") |
|||
self.PB_All_Visible.setToolTip("<img src=" + self.path + "Macro_FCTreeView_01.png" + " />" + "\n" |
|||
"All objects Visible" + "\n" |
|||
"For restitute the original organisation click to <b>Original</b> button" + "\n" |
|||
" <img src=" + self.path + "Macro_FCTreeView_18.png" + " />") |
|||
self.PB_All_Hidden.setText("All Hidden") |
|||
self.PB_All_Hidden.setToolTip("<img src=" + self.path + "Macro_FCTreeView_02.png" + " />" + "\n" |
|||
"All objects Hidden" + "\n" |
|||
"For restitute the original organisation click to <b>Original</b> button" + "\n" |
|||
"<img src=" + self.path + "Macro_FCTreeView_18.png" + " />") |
|||
self.groupBox_Search.setTitle("Search") |
|||
self.PB_ClearLEdit.setText("Clear") |
|||
self.PB_ClearLEdit.setToolTip("Clear the Line Search same lineEdit emptied <img src=" + self.path + "Macro_FCTreeView_20.png" + " />") |
|||
self.RB_01_NameLabel.setText("NLwc") |
|||
self.RB_01_NameLabel.setToolTip("Search by Name and Label Without respecting the sensitive Case") |
|||
self.RB_02_Name_CS.setText("Nsc") |
|||
self.RB_02_Name_CS.setToolTip("Search by Name and respecting the Sensitive Case") |
|||
self.RB_03_Label_NC.setText("Lwc") |
|||
self.RB_03_Label_NC.setToolTip("Search by Label Without respecting the sensitive Case") |
|||
self.RB_04_NamLabel_CS.setText("NLsc") |
|||
self.RB_04_NamLabel_CS.setToolTip("Search by Name and Label and respecting the Sensitive Case") |
|||
self.RB_05_NameLabel_AL.setText("NLwsc") |
|||
self.RB_05_NameLabel_AL.setToolTip("Search by Name and Label in Word and respecting the Sensitive Case" + "\n" |
|||
"(same panel selection of FreeCAD)") |
|||
self.comboBox.setToolTip("Search the object by type") |
|||
if testing == 1: |
|||
self.PB_Quit.setText("Quit") |
|||
self.PB_Quit.setToolTip("Quit FCTreeView <img src=" + self.path + "Macro_FCTreeView_09.png" + " />") |
|||
self.PB_Select.setText("Select") |
|||
self.PB_Select.setToolTip("Select all object(s) displayed <img src=" + self.path + "Macro_FCTreeView_23.png" + " />") |
|||
self.label_Ver.setText("FCTreeView (" + __version__ + " (" + __date__ + "))") |
|||
self.comboBox.setItemText(0, "") |
|||
def details(self, type, name ): #details object |
|||
if type == 0: |
|||
Fdoc = FreeCAD.ActiveDocument.getObject(name) |
|||
else: |
|||
Fdoc = FreeCAD.ActiveDocument.getObjectsByLabel(name)[0] |
|||
try: |
|||
Bx = ("Base\nX : "+str(round(Fdoc.Placement.Base[0],3))+"\n") |
|||
By = ("Y : "+str(round(Fdoc.Placement.Base[1],3))+"\n") |
|||
Bz = ("Z : "+str(round(Fdoc.Placement.Base[2],3))+"\n\n") |
|||
base = Bx + By + Bz |
|||
except Exception: |
|||
base = "" |
|||
try: |
|||
Rx = ("Rotation\nX : "+str(round(Fdoc.Placement.Rotation.toEuler()[0],3))+"\n") |
|||
Ry = ("Y : "+str(round(Fdoc.Placement.Rotation.toEuler()[1],3))+"\n") |
|||
Rz = ("Z : "+str(round(Fdoc.Placement.Rotation.toEuler()[2],3))+"\n\n") |
|||
rotation = Rx + Ry + Rz |
|||
except Exception: |
|||
rotation = "" |
|||
try: |
|||
Cx = ("CenterOfMass\nX : "+str(round(Fdoc.Shape.CenterOfMass[0],3))+"\n") |
|||
Cy = ("Y : "+str(round(Fdoc.Shape.CenterOfMass[1],3))+"\n") |
|||
Cz = ("Z : "+str(round(Fdoc.Shape.CenterOfMass[2],3))+"\n\n") |
|||
centerOfMass = Cx + Cy + Cz |
|||
except Exception: |
|||
centerOfMass = "" |
|||
return name[:20] + "\n\n" + base + rotation + centerOfMass |
|||
def on_treeWidget_clicked(self, item): |
|||
global listeObjetsOriginal |
|||
global titre |
|||
global ui |
|||
global doc |
|||
global searchString |
|||
ligne = item.row() # index dans la liste |
|||
colonne = item.column() # index dans la liste |
|||
nomObjetListe = item.data() # donne le nom clique |
|||
nomParentBase = item.parent().data()# donne le nom du maitre |
|||
# print "ligne ",ligne |
|||
# print "colonne ",colonne |
|||
# print "nomObjetListe ",nomObjetListe |
|||
# print "nomParentBase ",nomParentBase |
|||
try: |
|||
if (nomObjetListe == "False") or (nomObjetListe == "True"): |
|||
if nomObjetListe == "False": |
|||
try: |
|||
FreeCAD.ActiveDocument.getObject(nomParentBase.encode('utf-8')).ViewObject.Visibility = True |
|||
except Exception: |
|||
App.ActiveDocument.getObjectsByLabel(nomParentBase.encode('utf-8'))[0].ViewObject.Visibility = True |
|||
else: |
|||
try: |
|||
FreeCAD.ActiveDocument.getObject(nomParentBase.encode('utf-8')).ViewObject.Visibility = False |
|||
except Exception: |
|||
App.ActiveDocument.getObjectsByLabel(nomParentBase.encode('utf-8'))[0].ViewObject.Visibility = False |
|||
if searchString == " Searched": |
|||
ui.loadObjects() |
|||
ui.on_lineEdit_Search_Pressed() |
|||
else: |
|||
ui.on_PB_Reload_clicked() |
|||
FreeCADGui.Selection.clearSelection() |
|||
if nomParentBase == doc: |
|||
try: |
|||
FreeCADGui.Selection.addSelection(App.ActiveDocument.getObject(nomObjetListe.encode('utf-8'))) |
|||
self.treeWidget.setToolTip( ui.details(0, nomObjetListe.encode('utf-8'))) |
|||
except Exception: |
|||
FreeCADGui.Selection.addSelection(App.ActiveDocument.getObjectsByLabel(nomObjetListe.encode('utf-8'))[0]) |
|||
self.treeWidget.setToolTip( ui.details(1, nomObjetListe.encode('utf-8'))) |
|||
else: |
|||
try: |
|||
FreeCADGui.Selection.addSelection(App.ActiveDocument.getObject(nomParentBase.encode('utf-8'))) |
|||
self.treeWidget.setToolTip( ui.details(0, nomParentBase.encode('utf-8'))) |
|||
except Exception: |
|||
FreeCADGui.Selection.addSelection(App.ActiveDocument.getObjectsByLabel(nomParentBase.encode('utf-8'))[0]) |
|||
self.treeWidget.setToolTip( ui.details(1, nomParentBase.encode('utf-8'))) |
|||
#zoom_selection # https://forum.freecadweb.org/viewtopic.php?f=8&t=15132 |
|||
Gui.SendMsgToActiveView("ViewSelection") |
|||
Gui.runCommand("Std_TreeSelection") |
|||
except Exception: |
|||
self.treeWidget.setToolTip("The title display the option, number and type object(s) displayed" + "\n" + "\n" |
|||
"O = Objects" + "\n" |
|||
"N = Name" + "\n" |
|||
"L = Label" + "\n" |
|||
"T = Total" + "\n" |
|||
"G = Group" + "\n" |
|||
"S = Single" + "\n" |
|||
"V = Visible" + "\n" |
|||
"H = Hidden" + "\n\n" |
|||
"If one object are selected :" + "\n" |
|||
"the Placement Base, Rotation and Center of mass is displayed" + "\n" |
|||
"if available !") |
|||
FreeCAD.Console.PrintError("Error clicked" + "\n") |
|||
def sorted_List(self, option): # listing after sorted |
|||
global doc |
|||
global listeSorted |
|||
global titre |
|||
global derouler |
|||
global visibilite |
|||
global group |
|||
global SplitNameLabel |
|||
enteteTitres = QtGui.QTreeWidgetItem([" Sorted" + option,]) # titres entete des colonnes |
|||
self.treeWidget.setHeaderItem(enteteTitres) # affichage des titres #Another alternative is setHeaderLabels(["Tree","First",...]) |
|||
documentActif = QtGui.QTreeWidgetItem(self.treeWidget, [str(doc)]) # titre du document |
|||
documentActif.setExpanded(True) # expent tous les enfants |
|||
# #[objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
for obj in listeSorted: |
|||
A = QtGui.QTreeWidgetItem(documentActif, [obj[0]]) # premier objet dans l'arbre du document |
|||
if obj[3] == "-": |
|||
A.setIcon(0,self.iconName) # premiere rangee titre |
|||
else: |
|||
A.setIcon(0,self.iconFolder) # premiere rangee titre |
|||
if derouler == 1: |
|||
A.setExpanded(True) # expent tous les enfants |
|||
etat = QtGui.QTreeWidgetItem(A) |
|||
if obj[-1] == 1: # convert firt char lower original |
|||
objL = obj[1][0].lower() + obj[1][1:] |
|||
etat.setText(0,objL) # label |
|||
else: |
|||
etat.setText(0,obj[1]) # label |
|||
etat.setIcon(0,self.iconLabel) |
|||
etat2 = QtGui.QTreeWidgetItem(A) |
|||
if obj[2] == "True": |
|||
etat2.setText(0,"True") # premiere rangee |
|||
etat2.setIcon(0,self.iconTrue) # premiere rangee |
|||
if visibilite == 1: |
|||
A.setIcon(0,self.iconTrue) # premiere rangee titre |
|||
else: |
|||
etat2.setText(0,"False") # premiere rangee |
|||
etat2.setIcon(0,self.iconFalse) # premiere rangee |
|||
if visibilite == 1: |
|||
A.setIcon(0,self.iconFalse) # premiere rangee titre |
|||
etat3 = QtGui.QTreeWidgetItem(A) |
|||
if obj[3] == "-": |
|||
if group == 1: |
|||
A.setIcon(0,self.iconChainCut) # premiere rangee titre |
|||
None |
|||
else: |
|||
etat3.setText(0,obj[3]) |
|||
etat3.setIcon(0,self.iconChain) # premiere rangee |
|||
if group == 1: |
|||
A.setIcon(0,self.iconChain) # premiere rangee titre |
|||
if SplitNameLabel == 1: |
|||
A = QtGui.QTreeWidgetItem(documentActif, [obj[1]]) # premier objet dans l'arbre du document |
|||
if obj[-1] == 1: # convert firt char lower original |
|||
objL = obj[1][0].lower() + obj[1][1:] |
|||
A.setText(0,objL) # label |
|||
else: |
|||
A.setText(0,obj[1]) # label |
|||
A.setIcon(0,self.iconLabel) # premiere rangee titre |
|||
if derouler == 1: |
|||
A.setExpanded(True) # expent tous les enfants |
|||
B = QtGui.QTreeWidgetItem(A) |
|||
if obj[3] == "-": |
|||
B.setIcon(0,self.iconName) # premiere rangee titre |
|||
else: |
|||
B.setIcon(0,self.iconFolder) # premiere rangee titre |
|||
B.setText(0,obj[0]) # name |
|||
C = QtGui.QTreeWidgetItem(A) |
|||
if obj[2] == "True": |
|||
C.setText(0,"True") # premiere rangee |
|||
C.setIcon(0,self.iconTrue) # premiere rangee |
|||
if visibilite == 1: |
|||
A.setIcon(0,self.iconTrue) # premiere rangee titre |
|||
else: |
|||
C.setText(0,"False") # premiere rangee |
|||
C.setIcon(0,self.iconFalse) # premiere rangee |
|||
if visibilite == 1: |
|||
A.setIcon(0,self.iconFalse) # premiere rangee titre |
|||
D = QtGui.QTreeWidgetItem(A) |
|||
if obj[3] == "-": |
|||
if group == 1: |
|||
A.setIcon(0,self.iconChainCut) # premiere rangee titre |
|||
None |
|||
else: |
|||
D.setText(0,obj[3]) |
|||
D.setIcon(0,self.iconChain) # premiere rangee |
|||
if group == 1: |
|||
A.setIcon(0,self.iconChain) # premiere rangee titre |
|||
def on_PB_Sort_00_clicked(self): # tableau 0 Nom |
|||
global listeSorted |
global listeSorted |
||
global ui |
global ui |
||
global titre |
|||
global reverse_00 |
|||
global reverse_01 |
|||
global reverse_02 |
|||
global reverse_03 |
|||
None |
|||
# #[objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
}} |
|||
if self.CB_Length.isChecked(): |
|||
<translate> |
|||
listeSorted = sorted(listeSorted, key=itemgetter(4)) |
|||
titre = " by Length Name" |
|||
else: |
|||
listeSorted = sorted(listeSorted, key=itemgetter(0)) |
|||
titre = " by Name" |
|||
self.treeWidget.clear() |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
<!--T:74--> |
|||
if reverse_00 == 1: |
|||
ver 00.08 (2020-02-25) : upgrade with Layout |
|||
ui.on_PB_Reverse_clicked() |
|||
reverse_00 = 0 |
|||
else: |
|||
reverse_00 = 1 |
|||
reverse_01 = reverse_02 = reverse_03 = 0 |
|||
self.treeWidget.verticalScrollBar().setStyleSheet("background-color: #0000ce;") |
|||
<!--T:75--> |
|||
def on_PB_Sort_01_clicked(self): # tableau 1 Label |
|||
ver 00.07 (06/05/2018) : modify procedure for search the last cell used |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
global reverse_00 |
|||
global reverse_01 |
|||
global reverse_02 |
|||
global reverse_03 |
|||
<!--T:68--> |
|||
# #https://docs.python.org/2/howto/sorting.html |
|||
ver 00.06 (13/12/2017) : correct little bug line del line num 1881 "del listeSortedBis[doublon][4:] # supprime le fond inutile" thanks renatorivo |
|||
# #sorted("This is a test string from Andrew".split(), key=str.lower) |
|||
# #['a', 'Andrew', 'from', 'is', 'string', 'test', 'This'] |
|||
# # |
|||
# #[objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
<!--T:72--> |
|||
if self.CB_Length.isChecked(): |
|||
ver 00.05 (27/11/2017) : add creation spreadsheet and many option for him |
|||
listeSorted = sorted(listeSorted, key=itemgetter(5)) |
|||
titre = " by Length Label" |
|||
else: |
|||
listeSorted = sorted(listeSorted, key=itemgetter(1)) |
|||
titre = " by Label" |
|||
self.treeWidget.clear() |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
<!--T:52--> |
|||
if reverse_01 == 1: |
|||
ver 00.04 (29-09-2017) : add search by numeric value (length, radius....) |
|||
ui.on_PB_Reverse_clicked() |
|||
reverse_01 = 0 |
|||
else: |
|||
reverse_01 = 1 |
|||
reverse_00 = reverse_02 = reverse_03 = 0 |
|||
self.treeWidget.verticalScrollBar().setStyleSheet("background-color: #0073cc;") |
|||
<!--T:54--> |
|||
def on_PB_Sort_02_clicked(self): # tableau 2 False True |
|||
values researched : |
|||
global listeSorted |
|||
</translate> |
|||
global ui |
|||
global titre |
|||
global reverse_00 |
|||
global reverse_01 |
|||
global reverse_02 |
|||
global reverse_03 |
|||
{{Code|code= |
|||
self.treeWidget.clear() |
|||
global impost ; impost = ["Angle","Angle0","Angle1","Angle2","Angle3","ChamferSize","Circumradius","Columns","Degree", |
|||
listeSorted = sorted(listeSorted, key=itemgetter(2)) |
|||
"FilletRadius","FirstAngle","Growth","Height","LastAngle","Length","Length2","MajorRadius", |
|||
titre = " by Visibility" |
|||
"MinorRadius","Pitch","Polygon","Radius","Radius1","Radius2","Radius3","Rows","Size","Width", |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
"X","X1","X2","Xmax","Xmin","X2max","X2min", |
|||
"Y","Y1","Y2","Ymax","Ymin","Y2max","Y2min", |
|||
if reverse_02 == 1: |
|||
"Z","Z1","Z2","Zmax","Zmin","Z2max","Z2min"] |
|||
ui.on_PB_Reverse_clicked() |
|||
reverse_02 = 0 |
|||
self.treeWidget.verticalScrollBar().setStyleSheet("background-color: #007000;") |
|||
else: |
|||
reverse_02 = 1 |
|||
self.treeWidget.verticalScrollBar().setStyleSheet("background-color: #cc0000;") |
|||
reverse_00 = reverse_01 = reverse_03 = 0 |
|||
def on_PB_Sort_03_clicked(self): # tableau 3 False Groupe premier niveau |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
global reverse_00 |
|||
global reverse_01 |
|||
global reverse_02 |
|||
global reverse_03 |
|||
if self.CB_Length.isChecked(): |
|||
listeSorted = sorted(listeSorted, key=itemgetter(6)) |
|||
titre = " by Length Group" |
|||
else: |
|||
listeSorted = sorted(listeSorted, key=itemgetter(3)) |
|||
titre = " by Group" |
|||
self.treeWidget.clear() |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
if reverse_03 == 1: |
|||
ui.on_PB_Reverse_clicked() |
|||
reverse_03 = 0 |
|||
else: |
|||
reverse_03 = 1 |
|||
reverse_00 = reverse_01 = reverse_02 = 0 |
|||
self.treeWidget.verticalScrollBar().setStyleSheet("background-color: #ff5555;") |
|||
def on_PB_Reverse_clicked(self): # reverse tableau |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
listeSorted.reverse() |
|||
self.treeWidget.clear() |
|||
if titre[-9:] == " reverse>": |
|||
titre = titre.replace(">","<") |
|||
elif titre[-9:] == " reverse<": |
|||
titre = titre.replace("<",">") |
|||
else: |
|||
titre += " reverse<" |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def on_PB_SplitName_clicked(self): # Split Name and Label |
|||
global ui |
|||
global titre |
|||
global SplitNameLabel |
|||
global listeSorted |
|||
if SplitNameLabel == 0: |
|||
self.PB_SplitName.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_21.png")) |
|||
self.PB_SplitName.setToolTip("Split name and label <img src=" + self.path + "Macro_FCTreeView_22.png" + " />") |
|||
SplitNameLabel = 1 |
|||
else: |
|||
self.PB_SplitName.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_22.png")) |
|||
self.PB_SplitName.setToolTip("Split name and label <img src=" + self.path + "Macro_FCTreeView_21.png" + " />") |
|||
SplitNameLabel = 0 |
|||
self.treeWidget.clear() |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def on_PB_Expend_clicked(self): |
|||
global ui |
|||
global titre |
|||
global derouler |
|||
global listeSorted |
|||
if derouler == 1: |
|||
derouler = 0 |
|||
self.PB_Expend.setText("Develop") |
|||
self.PB_Expend.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_15.png")) |
|||
self.PB_Expend.setToolTip("Click for Develop the listing objects <img src=" + self.path + "Macro_FCTreeView_15.png" + " />") |
|||
else: |
|||
derouler = 1 |
|||
self.PB_Expend.setText("Fold") |
|||
self.PB_Expend.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_14.png")) |
|||
self.PB_Expend.setToolTip("Click for Fold the listing objects <img src=" + self.path + "Macro_FCTreeView_14.png" + " />") |
|||
self.treeWidget.clear() |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def loadObjects(self): |
|||
global doc |
|||
global listeObjetsOriginal |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
enteteTitres = QtGui.QTreeWidgetItem(["Etiquette",]) # titres entete 1 colonnes |
|||
self.treeWidget.setHeaderItem(enteteTitres) # affichage des titres #(["Tree","First",...]) |
|||
documentActif = QtGui.QTreeWidgetItem(self.treeWidget, [str(doc.encode('utf-8'))+" Original"]) # titre du document |
|||
del listeObjetsOriginal[:] |
|||
del listeSorted[:] |
|||
listeType = [] |
|||
del listeType[:] |
|||
#### Liste ###### |
|||
for obj in FreeCAD.ActiveDocument.Objects: |
|||
objName = obj.Name |
|||
objLabel = obj.Label |
|||
objGroupe = "" |
|||
objLName = 0 |
|||
objLLabel = 0 |
|||
objLGroupe = 0 |
|||
objSignal = 0 |
|||
if objLabel[0].islower(): # firt char lower |
|||
objLabel = objLabel[0].upper() + objLabel[1:] |
|||
objSignal = 1 |
|||
####recherche de groupe et enfants debut#### |
|||
if len(obj.OutList) != 0: |
|||
if len(obj.OutList) > 1: |
|||
objGroupe = obj.Label + " (" + str(len(obj.OutList)) + " Objects)" |
|||
else: |
|||
objGroupe = obj.Label + " (" + str(len(obj.OutList)) + " Object)" |
|||
for enfants in obj.OutList: |
|||
objGroupe += "\n" + " ( " + enfants.Label + " )" |
|||
else: |
|||
objGroupe = "-" |
|||
####recherche de groupe et enfants fin#### |
|||
# #[objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
####recherche de type d objet debut#### |
|||
objTypeSolid = objTypeTypeID = objTypeShape = "" |
|||
try: |
|||
if str(obj.Shape.Solids).find('Solid')!= -1: |
|||
objTypeSolid = "Solid" |
|||
listeType.append("Solid") |
|||
except Exception: |
|||
None |
|||
try: |
|||
listeType.append(str(obj.TypeId.split("::")[1])) |
|||
objTypeTypeID = str(obj.TypeId.split("::")[1]) |
|||
except Exception: |
|||
None |
|||
try: |
|||
listeType.append(str(obj.Shape.ShapeType)) |
|||
objTypeShape = str(obj.Shape.ShapeType) |
|||
except Exception: |
|||
None |
|||
####recherche de type d objet fin#### |
|||
objLName = len(objName) # length |
|||
objLLabel = len(objLabel) # length |
|||
objLGroupe = len(objGroupe) # length |
|||
#### |
|||
# if Gui.activeDocument().getObject(objName).Visibility == True: |
|||
# listeObjetsOriginal.append([objName, objLabel, "True", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape]) |
|||
# else: |
|||
# listeObjetsOriginal.append([objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape]) |
|||
listeObjetsOriginal.append([objName, objLabel, str(Gui.activeDocument().getObject(objName).Visibility), objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape]) |
|||
#### |
|||
#### |
|||
self.treeWidget.clear() # efface le contenu du widget |
|||
listeSorted = copy.deepcopy(listeObjetsOriginal) # original organisation on begin |
|||
titre = " Original" # original organisation on begin |
|||
# |
|||
# listeSorted = sorted(listeSorted, key=itemgetter(0)) # sorted by Name on begin |
|||
# titre = " by Name" # sorted by Name on begin |
|||
#### |
|||
#### |
|||
listeType = sorted(set(listeType)) # supprime les doublons et met en ordre liste Type |
|||
for i in range(len(listeType)): |
|||
self.comboBox.addItem(_fromUtf8("")) # include in ComboBox |
|||
self.comboBox.setItemText(i, listeType[i]) |
|||
#### |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def on_PB_Visibility_clicked(self): |
|||
global visibilite |
|||
global group |
|||
global ui |
|||
global listeSorted |
|||
group = 0 |
|||
if visibilite == 0: |
|||
visibilite = 1 |
|||
else: |
|||
visibilite = 0 |
|||
visible = cache = 0 |
|||
for i in listeSorted: |
|||
if i[2] == "True": |
|||
visible += 1 |
|||
else: |
|||
cache += 1 |
|||
self.treeWidget.clear() # efface le widget |
|||
ui.sorted_List(titre + " (V " + str(visible) + ") (H " + str(cache) + ") = (O " + str(visible + cache) + ")") |
|||
def on_PB_Group_clicked(self): |
|||
global group |
|||
global visibilite |
|||
global ui |
|||
global listeSorted |
|||
visibilite = 0 |
|||
if group == 0: |
|||
group = 1 |
|||
else: |
|||
group = 0 |
|||
groupe = simple = 0 |
|||
for i in listeSorted: |
|||
if i[3] == "-": |
|||
groupe += 1 |
|||
else: |
|||
simple += 1 |
|||
self.treeWidget.clear() # efface le widget |
|||
ui.sorted_List(titre + " (G " + str(groupe) + ") (S " + str(simple) + ") = (O " + str(groupe + simple) + ")") |
|||
def on_PB_Original_clicked(self): # tableau organisation |
|||
global listeObjetsOriginal |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
for obj in listeObjetsOriginal: |
|||
if obj[2] == "True": |
|||
Gui.activeDocument().getObject(obj[0]).Visibility = True |
|||
else: |
|||
Gui.activeDocument().getObject(obj[0]).Visibility = False |
|||
listeSorted = copy.deepcopy(listeObjetsOriginal) |
|||
self.treeWidget.clear() |
|||
titre = " Original" |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
self.treeWidget.verticalScrollBar().setStyleSheet("background-color: QPalette.Base;") |
|||
def on_PB_All_Visible_clicked(self): |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
i = 0 |
|||
for obj in listeSorted: |
|||
Gui.activeDocument().getObject(obj[0]).Visibility = True |
|||
listeSorted[i][2] = "True" |
|||
i += 1 |
|||
self.treeWidget.clear() # efface le widget |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def on_PB_All_Hidden_clicked(self): |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
i = 0 |
|||
for obj in listeSorted: |
|||
Gui.activeDocument().getObject(obj[0]).Visibility = False |
|||
listeSorted[i][2] = "False" |
|||
i += 1 |
|||
self.treeWidget.clear() # efface le widget |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def on_PB_Reload_clicked(self): |
|||
global ui |
|||
global titre |
|||
self.treeWidget.clear() |
|||
titre = " Original" |
|||
ui.loadObjects() |
|||
def on_RB_Pressed(self): |
|||
global ui |
|||
global titre |
|||
self.treeWidget.clear() |
|||
ui.on_lineEdit_Search_Pressed() |
|||
def on_lineEdit_Search_Pressed(self): |
|||
global ui |
|||
global titre |
|||
global listeSorted |
|||
global searchString |
|||
global listeObjetsOriginal |
|||
global listeByStringSear |
|||
self.treeWidget.clear() |
|||
titre = " by string" |
|||
texte = self.lineEdit_Search.text() |
|||
searchString = " Searched" |
|||
listeSorted = copy.deepcopy(listeObjetsOriginal) |
|||
del listeByStringSear[:] |
|||
if texte != "": |
|||
comptName = comptLabel = 0 |
|||
# Search by Name + Label (not casse) |
|||
if self.RB_01_NameLabel.isChecked(): |
|||
texte = texte.upper() |
|||
for i in range(len(listeSorted)): |
|||
if texte in listeSorted[i][0][:len(texte)].upper(): # Name upper |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptName += 1 |
|||
if texte in listeSorted[i][1][:len(texte)].upper(): # Label upper |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptLabel += 1 |
|||
# Search by Name (casse) |
|||
elif self.RB_02_Name_CS.isChecked(): # case sensitivity |
|||
for i in range(len(listeSorted)): |
|||
if texte in listeSorted[i][0][:len(texte)]: # Name |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptName += 1 |
|||
# Search by Label (not casse) |
|||
elif self.RB_03_Label_NC.isChecked(): |
|||
for i in range(len(listeSorted)): |
|||
if texte.upper() in listeSorted[i][1][:len(texte)].upper():# Label |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptLabel += 1 |
|||
# Search by Name + Label casse sensitivity |
|||
elif self.RB_04_NamLabel_CS.isChecked(): |
|||
for i in range(len(listeSorted)): |
|||
if texte in listeSorted[i][0][:len(texte)]: # Name sensitivity |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptName += 1 |
|||
if listeSorted[i][7] == 1: |
|||
casse = listeSorted[i][1] |
|||
casse = casse[0].lower() + casse[1:] |
|||
if texte in casse[:len(texte)]: # Label sensitivity |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptLabel += 1 |
|||
elif texte in listeSorted[i][1][:len(texte)]: # Label sensitivity |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptLabel += 1 |
|||
# Search by case sensitivity in word |
|||
elif self.RB_05_NameLabel_AL.isChecked(): |
|||
for i in range(len(listeSorted)): |
|||
if texte in listeSorted[i][0]: # Name sensitivity in word |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptName += 1 |
|||
if listeSorted[i][7] == 1: |
|||
casse = listeSorted[i][1] |
|||
casse = casse[0].lower() + casse[1:] |
|||
if texte in casse: # Label sensitivity in word |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptLabel += 1 |
|||
elif texte in listeSorted[i][1]: # Label sensitivity in word |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comptLabel += 1 |
|||
titre = " by string" |
|||
listeSorted = copy.deepcopy(listeByStringSear) |
|||
ui.sorted_List(titre +" (N " + str(comptName) + ") (L " + str(comptLabel) + ") = (T " + str(comptName + comptLabel) + ")") |
|||
else: |
|||
listeSorted = copy.deepcopy(listeObjetsOriginal) |
|||
ui.on_PB_ClearLEdit_clicked() |
|||
def on_PB_ClearLEdit_clicked(self): |
|||
global ui |
|||
global titre |
|||
global searchString |
|||
searchString = "" |
|||
self.treeWidget.clear() |
|||
self.lineEdit_Search.clear() |
|||
self.RB_01_NameLabel.setChecked(True)# |
|||
titre = " Original" |
|||
ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")") |
|||
def on_PB_Select_clicked(self): |
|||
global listeSorted |
|||
global ui |
|||
global titre |
|||
global selections |
|||
self.treeWidget.setToolTip("The title display the option, number and type object(s) displayed" + "\n" + "\n" |
|||
"O = Objects" + "\n" |
|||
"N = Name" + "\n" |
|||
"L = Label" + "\n" |
|||
"T = Total" + "\n" |
|||
"G = Group" + "\n" |
|||
"S = Single" + "\n" |
|||
"V = Visible" + "\n" |
|||
"H = Hidden" + "\n\n" |
|||
"If one object are selected :" + "\n" |
|||
"the Placement Base, Rotation and Center of mass is displayed" + "\n" |
|||
"if available !") |
|||
if selections == 0: |
|||
self.PB_Select.setText("Deselect") |
|||
self.PB_Select.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_24.png")) |
|||
self.PB_Select.setToolTip("Deselect all object(s) selected <img src=" + self.path + "Macro_FCTreeView_24.png" + " />") |
|||
self.treeWidget.setSelectionMode(QtGui.QAbstractItemView.ContiguousSelection) |
|||
self.treeWidget.selectAll() |
|||
for obj in listeSorted: |
|||
FreeCADGui.Selection.addSelection(App.ActiveDocument.getObject(obj[0].encode('utf-8'))) |
|||
#FreeCADGui.Selection.addSelection(App.ActiveDocument.getObject(unicode(obj[0]))) |
|||
selections = 1 |
|||
else: |
|||
self.PB_Select.setText("Select") |
|||
self.PB_Select.setIcon(QtGui.QIcon(self.path + "Macro_FCTreeView_23.png")) |
|||
self.PB_Select.setToolTip("Select all object(s) displayed <img src=" + self.path + "Macro_FCTreeView_23.png" + " />") |
|||
self.treeWidget.clearSelection() |
|||
FreeCADGui.Selection.clearSelection() |
|||
selections = 0 |
|||
def SIGNAL_comboType_Changed(self, item): |
|||
print self.comboBox.itemText(item) |
|||
global ui |
|||
global titre |
|||
global listeSorted |
|||
global searchString |
|||
global listeObjetsOriginal |
|||
global listeByStringSear |
|||
texte = self.comboBox.itemText(item) |
|||
self.treeWidget.clear() |
|||
titre = " by type object" |
|||
searchString = " Searched" |
|||
listeSorted = copy.deepcopy(listeObjetsOriginal) |
|||
del listeByStringSear[:] |
|||
# [objName, objLabel, str(Gui.activeDocument().getObject(objName).Visibility), objGroupe, objLName, objLLabel, objLGroupe, objSignal, objTypeSolid, objTypeTypeID, objTypeShape] |
|||
if texte != "": |
|||
comp = 0 |
|||
# Search by type object |
|||
for i in range(len(listeSorted)): |
|||
if (texte in listeSorted[i][8]) or (texte in listeSorted[i][9]) or (texte in listeSorted[i][10]): |
|||
listeByStringSear.append(listeSorted[i]) |
|||
comp += 1 |
|||
titre = " by " + texte |
|||
listeSorted = copy.deepcopy(listeByStringSear) |
|||
ui.sorted_List(titre + " ( " + texte + " " + str(comp) + ")") |
|||
else: |
|||
listeSorted = copy.deepcopy(listeObjetsOriginal) |
|||
ui.on_PB_ClearLEdit_clicked() |
|||
# print self.comboBox.itemText(item) |
|||
def on_PB_Quit_clicked(self): |
|||
global ui |
|||
# self.vueActive.removeEventCallback("SoMouseButtonEvent",self.click) # desinstalle la fonction souris |
|||
# FreeCADGui.Selection.removeObserver(s) # desinstalle la fonction residente SelObserver |
|||
self.window.hide() # hide the window and close the macro |
|||
FreeCAD.Console.PrintMessage("Quit FCTreeView" + "\n") |
|||
################################################################################################## |
|||
#class SelObserver: |
|||
# def addSelection(self, document, object, element, position): # Selection |
|||
# global sourisPass |
|||
# global listeSorted |
|||
# global ui |
|||
# |
|||
# if sourisPass == 0: |
|||
# if object in listeSorted[0]: |
|||
# print "wahou" |
|||
# print object |
|||
# sourisPass = 1 |
|||
# else: |
|||
# sourisPass = 0 |
|||
# |
|||
# |
|||
## print object |
|||
# |
|||
### def setPreselection(self,doc,obj,sub): # preselection |
|||
### print "setPreselection" |
|||
### def removeSelection(self,doc,obj,sub): # Effacer l'objet selectionne |
|||
### print "removeSelection" |
|||
### def setSelection(self,doc): # Selection dans ComboView |
|||
### print "SelObserver quit macro" |
|||
### def clearSelection(self,doc): # Si clic sur l'ecran, effacer la selection |
|||
### print "clearSelection" # Si clic sur un autre objet, efface le precedent |
|||
# |
|||
#s=SelObserver() |
|||
#FreeCADGui.Selection.addObserver(s) # installe la fonction en mode resident |
|||
#################################################################################################### |
|||
doc = App.activeDocument() |
|||
if doc == None: |
|||
doc = FreeCAD.newDocument() |
|||
doc = unicode(doc.Name) |
|||
#####Section demarrage et controle################################################################# |
|||
# |
|||
mw = FreeCADGui.getMainWindow() |
|||
dw=mw.findChildren(QtGui.QDockWidget) |
|||
for i in dw: |
|||
if str(i.objectName()) == "FCTreeView": |
|||
#FreeCAD.Console.PrintError("FCTreeView is already open see \"Menu > View > Panels\"" + "\n") |
|||
#va=i.toggleViewAction() |
|||
if i.isVisible(): |
|||
#va.setChecked(False) # activer False |
|||
i.setVisible(False) # visible False |
|||
else: |
|||
#va.setChecked(True) # activer True |
|||
i.setVisible(True) # visible True |
|||
break |
|||
if i.objectName() != "FCTreeView": |
|||
#####MainWindow################################################################################ |
|||
# |
|||
if testing == 1: # MainWindow |
|||
MainWindow = QtGui.QMainWindow() # create a new window volant |
|||
MainWindow.setObjectName("FCTreeView") |
|||
ui = Ui_MainWindow(MainWindow) |
|||
ui.setupUi(MainWindow) |
|||
MainWindow.show() |
|||
ui.loadObjects() # load the objects |
|||
#####DockWidget################################################################################ |
|||
# |
|||
else: |
|||
myNewFreeCADWidget = QtGui.QDockWidget() # create a new dockwidget |
|||
myNewFreeCADWidget.setObjectName("FCTreeView") |
|||
ui = Ui_MainWindow(myNewFreeCADWidget) |
|||
ui.setupUi(myNewFreeCADWidget) |
|||
FCmw = FreeCADGui.getMainWindow() |
|||
if testing == 2: # RightDock |
|||
FCmw.addDockWidget(QtCore.Qt.RightDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window Right |
|||
else: # LeftDock |
|||
FCmw.addDockWidget(QtCore.Qt.LeftDockWidgetArea,myNewFreeCADWidget) # add the widget to the main window Left |
|||
#FCmw.addDockWidget(QtCore.Qt.TopDockWidgetArea ,myNewFreeCADWidget) # add the widget to the main window Top |
|||
ui.loadObjects() # load the objects |
|||
}} |
}} |
||
<translate> |
<translate> |
||
==To do== <!--T:45--> |
|||
</translate> |
|||
<translate> |
|||
<!--T:46--> |
|||
<strike>Docked the macro</strike> |
|||
</translate> |
|||
<translate> |
|||
==Version== <!--T:47--> |
|||
<!--T: |
<!--T:55--> |
||
ver 00.03 (23/09/2017) : add search by type object |
ver 00.03 (23/09/2017) : add search by type object |
||
Line 1,514: | Line 341: | ||
ver 00.01 (08/09/2017) : |
ver 00.01 (08/09/2017) : |
||
</translate> |
</translate> |
||
<languages/> |
Revision as of 18:03, 24 September 2020
Description |
---|
New version GUI modifyed for the HD dpi (QGridLayout) run only FC version 0.18 and more (PySide2 Qt5) Macro for list all objects in the project in one list without hierarchy, options sort by name, label, visibility, group, by length option search by name, label .... without case sensitive or with case sensitive and select all objects displayed in the macro window. For the precedent version see Macro_FCTreeView.FCMacro and install it manually. Macro version: 00.09 Last modified: 2020-09-24 FreeCAD version: 0.18 and below Download: Macro FCTreeView Icon package unzip the .zip file and copy the icon in your macro directory. Author: Mario52 |
Author |
Mario52 |
Download |
Macro FCTreeView Icon package unzip the .zip file and copy the icon in your macro directory. |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
00.09 |
Date last modified |
2020-09-24 |
FreeCAD Version(s) |
0.18 and below |
Default shortcut |
None |
See also |
None |
Description
Macro for list all objects in the project in one list without hierarchy, options sort by name, label, visibility, group, by length option search by name, label .... without case sensitive or with case sensitive and select all objects displayed in the macro window.
Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro
# This code is copied instead of the original macro code # to guide the user to the online download page. # Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki # or if the RAW code URL is somewhere else in the wiki. from PySide import QtGui, QtCore diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Information", "This macro must be downloaded from this link\n" "\n" "https://gist.githubusercontent.com/mario52a/67517ef758ff20005d0a6adcfd8c9190/raw/59bc2028978c82744c83c6b138ab3ef30e0bf6f3/Macro_FCTreeView.FCMacro" + "\n" "\n" "Quit this window to access the download page") diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) diag.setWindowModality(QtCore.Qt.ApplicationModal) diag.exec_() import webbrowser webbrowser.open("https://gist.githubusercontent.com/mario52a/67517ef758ff20005d0a6adcfd8c9190/raw/59bc2028978c82744c83c6b138ab3ef30e0bf6f3/Macro_FCTreeView.FCMacro")
How To Use
Section Window
The title display the option, number and type object(s) displayed
- O = Objects
- N = Name
- L = Label
- T = Total
- G = Group
- S = Single
- V = Visible
- H = Hidden
If one object are selected : the Placement Base, Rotation and Center of mass is displayed (if available !) Icon used for the Name of object (the scrollbar is colored blue)
Icon used for the Label of object (the scrollbar is colored blue clear)
Icon used for visualise if the object is status Visible (mouse click for Hidden) (the scrollbar is colored green)
Icon used for visualise if the object is status Hidden (mouse click for Visible) (the scrollbar is colored red)
Icon used for the Name contains objects (or folder Group)
Icon used for inform the object in a group the number objects is displayed in top group (the scrollbar is colored red clear)
Icon used for displayed the single object (not group)
Section Sort by :
Name Icon used for flip/flop normal/reverse the data listing sort by Name
Label Icon used for flip/flop normal/reverse the data listing sort by Label
Visible Icon used for flip/flop normal/reverse the data listing sort by Visibile/Hidden
Group Icon used for flip/flop normal/reverse the data listing sort by Group/Single object
Length If this check Box is checked the sort is created by length with the button clicked (Name, Label ...)
Section Global
Split flip/flop Split the Name list
Split flip/flop Split the Name and Label list
Expend flip/flop the data listing Fold/Expend
Expend flip/flop the data listing Expend/Fold
Visibility flip/flop normal/Visibility
Reload reload the data in the project
Original return in original organisation after operation visibility/Hidden
All Visible visualise if the object is status Visible
All Hidden visualise if the object is status Hidden
Section Search
Clear Clear the search line edit
The radioButton options Search:
- ("NLwc") : Search by Name and Label Without respecting the sensitive Case
- ("Nsc") : Search by Name and respecting the Sensitive Case
- ("Lwc") : Search by Label Without respecting the sensitive Case
- ("NLsc") : Search by Name and Label and respecting the Sensitive Case
- ("NLwsc") : Search by Name and Label in Word and respecting the Sensitive Case (same panel selection of FreeCAD)
- (Nu) : Search by numeric value (radius, length, angle .....) see version section
Select flip/flop for Selected all object(s) displayed in the window
Unselected flip/flop Unselected all object(s)
S Sheet access in Spreadsheet options
The SpreadSheet options:
- CheckBox options for select the data to save in spreadsheet
Select : Select all checkBox option to save
Select : unSelect all checkBox option to save
- Value : alone the value is saved in the cell
- Val Gr : the value and the unit are saved in unique cell
- Val Gr Ph : the value, the unit and the physic data is saved in unique cell
- Split : if the Split checkBox is checked, the data is cut saved in separate cell
- Combobox mm : select the unit length desired. The value is convert in the selected unit. The units length available are:
- km, hm, dam, m, dm, cm, mm, um, nm, pm, fm, in, lk, ft, yd, rd, ch, fur, mi, lea, nmi
- Combobox gram : select the unit weight desired. The value is convert in the selected unit. The units weight available are:
- t, q, kg, hg, dag, g, dg, cg, mg, µg, ng, pg, fg, gr, dr, oz, oz t, lb, t lb, st, qtr, cwt, tonneau fr, ct
- Spinbox Densite : give the density by dm3 of the material used (Default : 1.0000)
- Spinbox Round : give the round value desired (Default : 3)
- Combobox Name spreadSheet : List the spreadsheet in the document
- Line edit Name spreadSheet : Display the actual spreadsheet or give the name for the new spreadsheet
Select select all checkbox options
Unselect unselected all checkbox options
Save save the data in Spreadsheet displayed. if no spreadsheet is active the spreadsheet named FCSpreadSheet is created
Quit quit the Spreadsheet options
Icons
The icon must be copied into the same directory as the macro Macro_FCTreeView_Icon
Script
For prevent many instance the clic on ToolBar button are effect flip/flop (hide/visible)
The macro is located in right dock for change it modify the value line number 133 testing = 0 (or change it with the mouse as a widget normal)
Macro_FCTreeView.FCMacro
To do
Docked the macro
Version
ver 00.09 (2020-09-24) : correct the "freeze" macro after call the assembly4 workbench i try activate "Class SelObserver" and it work ???
class SelObserver:
def addSelection(self, document, object, element, position): # Selection
global sourisPass
global listeSorted
global ui
None
ver 00.08 (2020-02-25) : upgrade with Layout
ver 00.07 (06/05/2018) : modify procedure for search the last cell used
ver 00.06 (13/12/2017) : correct little bug line del line num 1881 "del listeSortedBis[doublon][4:] # supprime le fond inutile" thanks renatorivo
ver 00.05 (27/11/2017) : add creation spreadsheet and many option for him
ver 00.04 (29-09-2017) : add search by numeric value (length, radius....)
values researched :
global impost ; impost = ["Angle","Angle0","Angle1","Angle2","Angle3","ChamferSize","Circumradius","Columns","Degree",
"FilletRadius","FirstAngle","Growth","Height","LastAngle","Length","Length2","MajorRadius",
"MinorRadius","Pitch","Polygon","Radius","Radius1","Radius2","Radius3","Rows","Size","Width",
"X","X1","X2","Xmax","Xmin","X2max","X2min",
"Y","Y1","Y2","Ymax","Ymin","Y2max","Y2min",
"Z","Z1","Z2","Zmax","Zmin","Z2max","Z2min"]
ver 00.03 (23/09/2017) : add search by type object
ver 00.02 (11/09/2017) : modify for docked and prevent many instance the clic on button are effect flip/flop (macro hide/visible)
ver 00.01 (08/09/2017) :