26 (edited by galexis 2016-08-15 20:53:04)

Re: Terminal block generator cross-platform

unalcald: wrote:

Galexis, fails to me on linux:

raul@pb:~/Descargas/a$ python QET_TB_maker_v0.2\ \(1\).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.


/home/raul/.qet/elements/temp_tb/
Traceback (most recent call last):
  File "QET_TB_maker_v0.2 (1).py", line 369, in <module>
    from tkinter.filedialog import *
ImportError: No module named tkinter.filedialog


I post the sample project I used.

You don't have run it with python3 but with python.
In python instruction " from tkinter.filedialog import *" is different.

I understand your point of view, It's your script: I propose and you decide. I keep my modification for my use.


Are you able to load label of folio and not id of folio?

27 (edited by unalcalde 2016-08-15 21:45:03)

Re: Terminal block generator cross-platform

When I said to run with python3, I meant to solve the problem of my script, no the problem with tkinter.

This script is not mine, is for the community.

I only said my point of view about a GUI version; maybe is less dependency of packages the console version. I made history of projects to make it more usable. We can try some days, and if we considerer is bether a GUI version, no problem, I'll do.


[font=Verdana, Helvetica, Arial, sans-serif]Are you able to load label of folio and not id of folio?[/font]

[font=Verdana, Helvetica, Arial, sans-serif] Yes i'll do, but nowadays I don't have a lot of time. Next week I'll make and fix new problems that you report. [/font]


[font=Verdana, Helvetica, Arial, sans-serif] Thanks. [/font]

Re: Terminal block generator cross-platform

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.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

29 (edited by unalcalde 2016-08-16 10:27:27)

Re: Terminal block generator cross-platform

Hi again,
Version 0.3 is avaibable. The changes are:

* I made a fusion between Galexis and my point of view. I implemented a GUI choose for QET project but remembering the last path for a quickly selection. I tried and no extra python modules are required from the defaults.

* If you use a portable instalation, you can define the path in the QET_COLLECTION_PATH variable and this value was the default value, so pressing Enter will be enough.

* Now can chose XRef folio type: By ID (folio number) or by folio Name

Post's attachments

Attachment icon QET_TB_maker_v0.3.py 17.82 kb, 566 downloads since 2016-08-16 

Re: Terminal block generator cross-platform

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.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

31 (edited by unalcalde 2016-08-16 13:24:43)

Re: Terminal block generator cross-platform

Hi,
I saw the video and the second terminal block didn't cause artifacts. But I don't know why.  I'll do the same steps that you and then I'll compare the original XML  and the XML with hotspot recalculate.
I'll see the differences and I'll try to fix.

Re: Terminal block generator cross-platform

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?

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

33 (edited by unalcalde 2016-08-16 13:31:11)

Re: Terminal block generator cross-platform

scoprio810, please explain me what are:
* hotspot_x: ??
* hotspot_y: ??
* width: (is the total width?)
* height: (is the total height?)

Re: Terminal block generator cross-platform

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

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

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

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

36 (edited by unalcalde 2016-08-16 16:13:12)

Re: Terminal block generator cross-platform

Hi again  :-)

Available version 0.35:
   * Now draws reservation teminals in the numeric part. The first placed terminals are not numeric ('-0','R','+1',..) and later the numeric ('1', '3',...). In this last numeric part, the program creates reserve for terminals that are not used.

   * 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.

Please, check for bugs.

Post's attachments

Attachment icon QET_TB_maker_v0.35.py 19.22 kb, 585 downloads since 2016-08-16 

Re: Terminal block generator cross-platform

 * 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.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

38 (edited by unalcalde 2016-08-16 19:20:28)

Re: Terminal block generator cross-platform

Thank you, now work fine.

you're welcome.

Re: Terminal block generator cross-platform

No body have tried this script on MS Windows plateform?

https://www.python.org/downloads/release/python-352/

Windows x86-64 executable installer/Windows x86 executable installer

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

Script work very well.

I try to test it at office on next days.

Re: Terminal block generator cross-platform

I just tried, and script work nice on Windows.
Just installed https://www.python.org/ftp/python/3.5.2 … -amd64.exe for VM seven 64 bits,
and add python to path with installer.

Move script on desktop folder and just click on link.
Or by command line : python QET_TB_maker_v0.35.py


"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

Perfect !!nomicons/smile

Re: Terminal block generator cross-platform

Thank you for this great python script, I think your script python with tkinter work fine on MAC OS too.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

44 (edited by unalcalde 2016-08-17 08:14:50)

Re: Terminal block generator cross-platform

Hi,
any ideas to solve this issue?

One solution is explained at next image.

The other option is to do automatically. Every terminal will sort by:
      First: Only letters: GND, R, S, T,...
      Second: Letters + Number : +1, -0, R1, U1, V1, GND1, ...
      Third: Only Numbers: 1, 3, 7, 33,...

    Inside first group , terminals are sorted alphabetically
    Inside second group, terminals are sorted by the numeric part, and every numeric group by letter alphabetically (GND1,U1,V1,W1)
    Inside third group, terminals are sorted numerically.


I think the second option will be better.

http://i68.tinypic.com/n33qs7.jpg

Re: Terminal block generator cross-platform

Hi,

perhaps filter by position {E7, E8, E8}  {E9, E9, E10} and after by letter if position is the same?

But in future, terminal element need to be improved by new feature properties like bloc name (parent) and terminal name (child).

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

Hi, version 0,4 is available.
Now  terminals names like LETTER + NUMBER, will be sorted as U1, V1, W1 y U2,V2,W2 instead of U1,U2,V1,V2, W1,W2. It makes automatically.

http://i65.tinypic.com/rj04nd.jpg

Post's attachments

Attachment icon QET_TB_maker_v0.4.py 22.52 kb, 599 downloads since 2016-08-17 

Re: Terminal block generator cross-platform

scorpio810 wrote:

I just tried, and script work nice on Windows.
Just installed https://www.python.org/ftp/python/3.5.2 … -amd64.exe for VM seven 64 bits,
and add python to path with installer.

Move script on desktop folder and just click on link.
Or by command line : python QET_TB_maker_v0.35.py


Tu installes python sur le pc et ensuites ? Je ne comprends pas ....

Re: Terminal block generator cross-platform

Bah, pour le test j'ai juste collé le script sur le bureau, c'est tout. nomicons/grin

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

C'est "and add python to path with installer." que je n'ai pas compris ... mais si faut juste installer python, c'est cool. Il n'existe pas de python en readytouse ? Au boulot se serait plus simple !

Re: Terminal block generator cross-platform

Pendant l'installation il te propose d'ajouter l’exécutable dans le path, il faut cocher l'option, ça évite d’avoir à écrire son chemin à chaque fois.
Ou d’éditer les variables d’environnement par la suite pour ajouter son chemin.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."