Macro FCTreeView

From FreeCAD Documentation
Revision as of 13:43, 9 September 2017 by Mario52 (talk | contribs) (upgrade)

File:Macro FCTreeView Macro FCTreeView

Description
This macro display all object of the project in one list with options sort search by name label...

Macro version: 00.01 (08/09/2017)
Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
00.01 (08/09/2017)
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

'Do not Translate - Do not change - Page not finished

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.

How To Use

Macro FCTreeView

Section Window

The title display the option, number and type object(s) displayed

  • O = Original
  • 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 Icon used for the Name of object (the scrollbar is colored blue)

Icon used for the Label of object 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) 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) 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 the Name contains objects (or folder Group)

Icon used for inform the object in a group the number objects is displayed in top 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) 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

Group flip/flop normal/Group

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)

Select flip/flop for Selected all object(s) displayed in the window

Unselected flip/flop Unselected all object(s)

Icons

The icon must be copied into the same directory as the macro

Icon used for the Name of object Icon used for visualise if the object is status Visible (mouse click for Hidden) Icon used for visualise if the object is status Hidden (mouse click for Visible) Icon used for inform the object in a group the number objects is displayed in top group Icon used for displayed the single object (not group) Icon used for the Label of object Icon used for flip/flop normal/Visibility Icon used for flip/flop normal/Group Icon used for Reverse the data listing (momentarily not used) Icon used for quit Macro FCTreeView (momentarily not used) Icon used for flip/flop normal/reverse the data listing sort by Name Icon used for flip/flop normal/reverse the data listing sort by Label Icon used for flip/flop normal/reverse the data listing sort by Visibility/Hidden Icon used for flip/flop normal/reverse the data listing sort by Grout/Single object Icon used for flip/flop the data listing Fold/Expend Icon used for flip/flop the data listing Expend/Fold Icon used for reload the data in the project Icon used for the Name contains objects (or folder Group) Icon used for return in original organisation after operation visibility/Hidden If this check Box is checked the sort is created by length with the button clicked (Name, Label ...) Icon used for Clear the search line edit Icon used for flip/flop Split the Name list Icon used for flip/flop Split the Name and Label list Icon used for Selected all object(s) displayed in the window Icon used for Unselected all object(s)

Script

The icon ToolBar Macro FCTreeView

Macro FCTreeView.FCMacro

# -*- 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.6706 (Git)
#Build type: Release
#Branch: releases/FreeCAD-0-16
#Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
#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.01"
__date__    = "08/09/2017"

import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
 
import time
from pivy import coin

from PySide import QtSvg, QtXml
import copy
import operator
from operator import itemgetter, attrgetter, methodcaller

####
from PySide import QtCore
#global langue 
#s=QtCore.QLocale()
#s.countryToString(s.country())
#s.name()
#langue = s.languageToString(s.language())
#print s.name()   # fr
#print langue     # French
####

import time

Gui = FreeCADGui
App = FreeCAD

global ui                     ; ui             = ""
global doc                    ; doc            = ""
global sourisPass             ; sourisPass     = 0
global listeObjetsOriginal    ; listeObjetsOriginal = [[]]    # Name, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal
global listeSorted            ; listeSorted         = [[]]    # Name, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal
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

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):
        self.window = MainWindow

        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(341, 624)
        MainWindow.setMinimumSize(QtCore.QSize(341,624))
        MainWindow.setMaximumSize(QtCore.QSize(341,624))
        MainWindow.move(950, 120)                     # deplace la fenetre
        self.centralwidget = QtGui.QWidget(MainWindow)
        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))
        #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, 420, 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, 470, 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, 544, 321, 71))
        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(50, 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, 40, 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(134, 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(179, 4, 50, 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_Quit = QtGui.QPushButton(self.centralwidget)
#        self.PB_Quit.setGeometry(QtCore.QRect(251, 570, 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.clicked.connect(self.on_PB_Quit_clicked)
#
        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)

        MainWindow.setCentralWidget(self.centralwidget)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle("FCTreeView (" + __version__ + " (" + __date__ + "))")
        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 = Original" + "\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.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" + " />")

    def details(self,  type, name ):
        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 = Original" + "\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]
        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 ui
        global titre
        global reverse_00
        global reverse_01
        global reverse_02
        global reverse_03

#       #[objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal]
        if self.CB_Length.isChecked():
            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)) + ")")

        if reverse_00 == 1:
            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;")

    def on_PB_Sort_01_clicked(self):    # tableau 1 Label
        global listeSorted
        global ui
        global titre
        global reverse_00
        global reverse_01
        global reverse_02
        global reverse_03

#       #[objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal]
        if self.CB_Length.isChecked():
            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)) + ")")

        if reverse_01 == 1:
            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;")

    def on_PB_Sort_02_clicked(self):    # tableau 2 False True
        global listeSorted
        global ui
        global titre
        global reverse_00
        global reverse_01
        global reverse_02
        global reverse_03

        self.treeWidget.clear()
        listeSorted = sorted(listeSorted, key=itemgetter(2))
        titre = " by Visibility"
        ui.sorted_List(titre + " (O " + str(len(listeSorted)) + ")")

        if reverse_02 == 1:
            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[:]

        #### 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####

            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])
#            else:
#                listeObjetsOriginal.append([objName, objLabel, "False", objGroupe, objLName, objLLabel, objLGroupe, objSignal])
            listeObjetsOriginal.append([objName, objLabel, str(Gui.activeDocument().getObject(objName).Visibility), objGroupe, objLName, objLLabel, objLGroupe, objSignal])
####
####
        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
####
        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 = Original" + "\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 on_PB_Quit_clicked(self):
#
##        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
#        if sourisPass == 0:
#            sourisPass = 1
#        else:
#            sourisPass = 0
#            
#        print object
#        ff = ui
#        ff.souris()

##    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)

MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow(MainWindow)
ui.setupUi(MainWindow)
MainWindow.show()
ui.loadObjects()

To do

Docked

Version

ver 00.01 (08/09/2017)  :