5,401

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Bah, suffit dans projet de renseigner les champs propriétés du cartouche et ensuite de générer tes - 10 folios de 1 à 10 de localisation =enrouleur
Tu modifies ensuite tes champs propriétés du cartouche et tu génères les suivant, non?

 * Fixed drawing artifacts while dragging. With hotspot_x=0 and y=0 works, but I leave the same has QET calcs when save from elements editor. The problem was the calc of total size. Now I round to the next tenth and works fine.

Thank you, now work fine.

5,403

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

il s'agit donc bien de réinventer la roue...

Peut-être pas !
Là ou tu as des constantes style [8] ça peut-être une variable dynamique ou tu comptes les colonnes demandées par l'utilisateur.

La largeur de chaque colonne tu peux aussi les récupérer depuis le Widget, etc.

5,404

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Toutefois, je vois pas pourquoi il faudrait limiter QET si c'est une implémentation aisée à réaliser.

Le patch était prêt, donc autant l'envoyer. nomicons/grin
Et je suis certain que certains auraient demandé à l'avoir.


Revision: 4628
Author:   scorpio810
Date:     2016-08-16 15:43:46 +0200 (Tue, 16 Aug 2016)
Log Message:
-----------
New fields titleblock properties %machine and %locmach can now be called
in the element rules autonum

5,405

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

5,406

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

scorpio810 wrote:

Revision: 4626
Author:   scorpio810
Date:     2016-08-12 13:32:56 +0200 (Fri, 12 Aug 2016)
Log Message:
-----------
Titleblock properties rename property %loc to %locmach

@Galexis, Nuri :
Çà vous intéressent d'avoir %machine et %locmach dans les règles de num des éléments?

For me you could try to fix hotspot by hotspot_x="5" hotspot_y="24" and just recalculate  width: (is the total width) and height: (is the total height).

Read code is better than explanation. nomicons/smile


/**
@return Le rectangle delimitant le contour de l'element
*/
QRectF Element::boundingRect() const {
return(QRectF(QPointF(-hotspot_coord.x(), -hotspot_coord.y()), dimensions));
}

/**
Definit la taille de l'element sur le schema. Les tailles doivent etre
des multiples de 10 ; si ce n'est pas le cas, les dimensions indiquees
seront arrrondies aux dizaines superieures.
@param wid Largeur de l'element
@param hei Hauteur de l'element
@return La taille finale de l'element
*/
QSize Element::setSize(int wid, int hei) {
prepareGeometryChange();
// chaque dimension indiquee est arrondie a la dizaine superieure
while (wid % 10) ++ wid;
while (hei % 10) ++ hei;
// les dimensions finales sont conservees et retournees
return(dimensions = QSize(wid, hei));
}

/**
@return la taille de l'element sur le schema
*/
QSize Element::size() const {
return(dimensions);
}

/**
Definit le hotspot de l'element par rapport au coin superieur gauche de son rectangle delimitant.
Necessite que la taille ait deja ete definie
@param hs Coordonnees du hotspot
*/
QPoint Element::setHotspot(QPoint hs) {
// la taille doit avoir ete definie
prepareGeometryChange();
if (dimensions.isNull()) hotspot_coord = QPoint(0, 0);
else {
// les coordonnees indiquees ne doivent pas depasser les dimensions de l'element
int hsx = qMin(hs.x(), dimensions.width());
int hsy = qMin(hs.y(), dimensions.height());
hotspot_coord = QPoint(hsx, hsy);
}
return(hotspot_coord);
}








/**
* @brief ElementScene::toXml
* Export this element as a xml file
* @param all_parts (true by default) if true, export the entire element in xml,
* if false, only export the selected parts.
* @return an xml document that describe the element.
*/
const QDomDocument ElementScene::toXml(bool all_parts)
{
    QRectF size= elementSceneGeometricRect();

        //if the element doesn't contains the origin point of the scene
        //we move the element to the origin for solve this default before saving
    if (!size.contains(0,0) && all_parts)
    {
        centerElementToOrigine();
            //recalcul the size after movement
        size= elementSceneGeometricRect();
    }

        //define the size of the element by the upper multiple of 10
    int upwidth = ((qRound(size.width())/10)*10)+10;
    if ((qRound(size.width())%10) > 6) upwidth+=10;

    int upheight = ((qRound(size.height())/10)*10)+10;
    if ((qRound(size.height())%10) > 6) upheight+=10;

        //the margin between the real size of the element and the rectangle that delimits
    int xmargin = qRound(upwidth - size.width());
    int ymargin = qRound(upheight - size.height());

        // document XML
    QDomDocument xml_document;

        //Root of xml document
    QDomElement root = xml_document.createElement("definition");
    root.setAttribute("type", "element");
    root.setAttribute("width", QString("%1").arg(upwidth));
    root.setAttribute("height", QString("%1").arg(upheight));
    root.setAttribute("hotspot_x", QString("%1").arg(-(qRound(size.x() - (xmargin/2)))));
    root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
    root.setAttribute("orientation", "dyyy"); //we keep the orientation for compatibility with previous version of qet
    root.setAttribute("version", QET::version);
    root.setAttribute("link_type", m_elmt_type);

xml = ['<definition hotspot_x="4" hotspot_y="4" width="%i" height="%i" orientation="dyyy" link_type="simple" type="element">' \
               %(totalWith, max( TB_HEIGHT, TB_HEIGHT )),

I think is :  %(totalWith, max( TB_WIDTH, TB_HEIGHT )), no?

scorpio810 wrote:

but I see à minor problem : hotspot size is smaller than the element and when you move element cause a lot of artifacts.

I need to open element in element editor for recalculate hotspot (automatic with save) element width=" " height=" " is wrong.

unalcalde wrote:

I post the sample project I used.

Thank you,

but I see à minor problem : hotspot size is smaller than the element and when you move element cause a lot of artifacts.

galexis wrote:

I propose to you somme modfication to have GUI to choose project file.
You have to install python3-tk and use commande or launcher :

python3 adress_script.py

python3 path to your QET_TB_maker_v0.2.py


Traceback (most recent call last):
 File "QET_TB_maker_v0.2.py", line 375, in <module>
   sQETProjectFile = askopenfilename(title="Choose QET project",filetypes=[('qet files','.qet'),('all files','.*')])
 File "/usr/lib/python3.5/tkinter/filedialog.py", line 375, in askopenfilename
   return Open(**options).show()
 File "/usr/lib/python3.5/tkinter/commondialog.py", line 48, in show
   s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: can't invoke "grab" command: application has been destroyed


Windows tk is empty.

5,413

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Çà risque d’être compliqué sans ré-écrire une grosse partie de ce code.

laurent@Toshiba:~/Documents$ python3 QET_TB_maker_v0.2.py

<< Terminal Block maker for QET 0.2 - by Raul Roda >>

Remember the next conditions:
 * Terminal elements must be 'terminal' as type in the Element Editor.
 * If terminal elements has more than one textfield, the first one is considered.
 * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.

Path to place created QET Terminal Blocks  [/home/laurent/.qet/elements/temp_tb/]:  

Select recent project number or type full path  []: /home/laurent/Documents/12.qet

Calculating...


Done.

laurent@Toshiba:~/Documents$

But temp_tb folder is empty

@Galexis : t'as un mini projet à envoyer pour tester?

5,415

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Nuri, je te dégrossi vite fait une partie du code, pour que tu puisses comprendre .

https://svnweb.tuxfamily.org/filedetail … p;peg=4627




qreal DiagramFolioList::colWidths[8] = {0.05, 0.05, 0.45, 0.10, 0.10, 0.05, 0.10, 0.10};


Création du tableau et largeur de chacune des 8 colonnes.




int cols = 8;//colWidths.size();



fillRow(p, row_rect, diagram_list[i] -> border_and_titleblock.author(),


diagram_list[i] -> title(),


QString::number(diagram_list[i] ->folioIndex()+1),


diagram_list[i] -> border_and_titleblock.folio(),


diagram_list[i] -> border_and_titleblock.machine(),


diagram_list[i] -> border_and_titleblock.locmach(),


diagram_list[i] -> border_and_titleblock.indexrev(),


diagram_list[i] -> border_and_titleblock.date().toString(Qt::SystemLocaleShortDate));


Nos constantes dont on va rechercher les valeurs.





// reduce the font size if the text entry is long


if (origFontMetrics.width(folio) > 0.95*colWidths[0]*row_rect.width())


workingFont.setPointSizeF(origFontSize * 0.95*colWidths[0]*row_rect.width() / origFontMetrics.width(folio));


else


workingFont.setPointSizeF(origFontSize);


qp -> setFont(workingFont);


qp -> drawText(QRectF(x, y, colWidths[0]*row_rect.width(), row_rect.height()), Qt::AlignCenter, folio);


x += colWidths[0]*row_rect.width();


Pour chaque constante tu affiches ou réduit la taille de police, entre les [] tu affectes ta constante à une colonne, ici c'est la constante folio qu'on affiche dans la colonne 1 (car on commence toujours à zéro!)

qp->setFont(QETApp::diagramTextsFont(13));

Taille de police d'origine.



qreal sum = 0;


for (int i = 0; i < 8; i++ )


sum += colWidths[i];


if ( sum < 0.99 || sum > 1.01 ) {


qDebug() << "Invalid input: Column widths do not sum to 1";


return;


}


On ajoute un controle pour que la largeur des colonnes soient compris dans cette fourchette, et donc quelles ne dépassent pas du tableau.




int startDiagram = id * 29;


for (int i = startDiagram; i < startDiagram+29 && i < diagram_list.size(); ++i) {


Chaque tableau contiendra 29 lignes, si le nombre de folios dépassent ce nombre, tu crées autant de tableaux.




--- trunk/sources/qetproject.cpp 2016-08-10 16:48:18 UTC (rev 4621)
+++ trunk/sources/qetproject.cpp 2016-08-11 18:32:08 UTC (rev 4622)
@@ -1039,7 +1039,7 @@
  setFolioSheetsQuantity(0);
 
  int diagCount = diagrams().size();
- for (int i = 0; i <= diagCount/58; i++) {
+ for (int i = 0; i <= diagCount/29; i++) {
 
  //create new diagram
  Diagram *diagram_folio_list = new DiagramFolioList(this);

@Galexis python3 !

Thank you Unalcalde,

you could send a example project for try or debug?


laurent@Toshiba:~/Documents$ python3 QET_TB_maker_v0.2.py 12.qet  
 
 
<< Terminal Block maker for QET 0.2 - by Raul Roda >>
 
 
 
Remember the next conditions:
 
 * Terminal elements must be 'terminal' as type in the Element Editor.
 
 * If terminal elements has more than one textfield, the first one is considered.
 
 * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.
 
 
 
Path to place created QET Terminal Blocks  [/home/laurent/.qet/elements/temp_tb/]:  
 
 
Select recent project number or type full path  []:  
 
 
Calculating...
 
Traceback (most recent call last):
 
 File "QET_TB_maker_v0.2.py", line 386, in <module>
 
   qet_tree = etree.parse(sQETProjectFile)   
 File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1184, in parse
 
   tree.parse(source, parser)
 
 File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 585, in parse
 
   source = open(source, "rb")
 
FileNotFoundError: [Errno 2] No such file or directory: ''

For Gnu/linux add home user path to qet element and create temp_tb folder if isn't exist.




--- QET_TB_maker.py    2016-08-14 16:02:26.208878660 +0200
+++ QET_TB_maker.py    2016-08-14 18:31:58.000000000 +0200
@@ -8,7 +8,11 @@
 import xml.etree.ElementTree as etree
 
 ########## GLOBAL CONSTANTS
-USER_COLLECTION_PATH="/home/raul/.qet/elements/temp_tb/" #path to create terminal blocks elements
+
+USER_COLLECTION_PATH= os.environ['HOME'] + '/.qet/elements/temp_tb/' #path to create terminal blocks elements
+if not os.path.exists(USER_COLLECTION_PATH):
+    os.makedirs(USER_COLLECTION_PATH)
+
 TB_BLOCKS_IN_A_FOLIO = 50
 TB_HEAD_WIDTH = 40
 TB_HEAD_UNION_HEIGHT = 45



For MS Windows :
http://stackoverflow.com/questions/2176 … ory-python

5,419

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Nuri wrote:

ben...euh...non, c'était vraiment du premier degré, je me moquais pas !
Ce que j'avais compris, c'est que QET interprète la variable %loc comme étant la concaténation de %l (lettre de la ligne) et des lettres oc.
Donc avec la variable %locmach, on devrait avoir le même problème: %l + ocmach.

Ces propriétés de cartouche ne fonctionnent pas dans le dock de num de Davi, je me doutais un peu qu'en l'appelant aussi %loc, ça aurait pu prêter à confusion avec la variable autonum de davi, voila.

5,420

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Nuri: pas la peine de ré inventer la roue. nomicons/smile


Le code de diagramfoliolist fait déjà très bien le travail, il suffit de remplacer les constantes définies dans le code (regarde mes patch nomicons/wink ) par des variables appelées depuis la config de QET pour rendre le sommaire entièrement dynamique :

Dans la config de QET l'utilisateur pourrait sélectionner dans une liste les entêtes de chaque de colonne qu'il veut (ID, Folio, titre, installation, location, auteur, date, etc ), leur ordre dans le tableau, et définir la largeur de chacune d'entre elle.

unalcalde wrote:

Hi, edit the QET_TB_maker.py and write the path where are your QET collection in the line started by USER_COLLECTION_PATH. Normaly will be something like "/home/<you user name here>/.qet/elements/<folder where terminals blocks will save>/". Don't forget to write de last / symbol !!

Hello Unalcalde,

on UNIX System you could change your command line in the script "/home/<you user name here>/.qet/elements/"

by


~/.qet/elements/


On MS Windows, with installer is located in c:\users\user_name\AppData\Roaming\qet\elements.
To try :


%USERPROFILE%\AppData\Roaming\qet\elements\

Or

%APPDATA%\qet\elements\

With the ReadyToUse version is located on the folder  "conf\elements\" where ReadyToUse is (USB drive or other) .

http://stackoverflow.com/questions/1854 … -in-python
http://stackoverflow.com/questions/4719 … ning-under

Laurent

5,422

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Mouahaha, pas joli de se moquer de Galexis, hein Nuri. nomicons/tongue

Çà devrait être corrigé mardi par Joshua, voila. nomicons/smile

Clair, ça fait fait un joli crash, uhuhu !
Vraiment pas le temps de regarder ça ce W.E, peut-être Joshua?

5,425

(113 replies, posted in FR : Aide, suggestions, discussions, ...)

Clair, perso je n'ai pas d'idée sur comment m'y prendre, c'est peut-être un travail pour rdsivd?