The XML structure used to describe the items in QElectroTech 0.3

… Or the creator of the guide elements in XML. This page is intended to describe the XML structure used to store the definitions of the elements used in QElectroTech. It is intended for developers TEQ but also to non-developers who want to do without the item editor.

Example and general structure of an element definition

<!DOCTYPE definition SYSTEM "definition_element.dtd">
  <definition type="element" width="45" height="65" hotspot_x="25" hotspot_y="45" orientation="dnnn">
    <names>
      <name lang="fr">Moteur asynchrone triphasé</name>
      <name lang="en">Three-phase induction motor</name>
    </names>
    <informations>Author: Xavier Guerrin
License: CC-BY
</informations>
    <description>
      <!--U-->
      <polygon x1="-20" y1="-40" x2="-20" y2="-20" x3="-14" y3="-14" antialias="false" closed="false"/>
      <!--V-->
      <line x1="0" y1="-40" x2="0" y2="-20" antialias="false"/>
      <!--W-->
      <polygon x1="20" y1="-40" x2="20" y2="-20" x3="14" y3="-14" antialias="false" closed="false"/>
      <circle x="-20" y="-20" diameter="40" antialias="true" style="filling:white;"/>
      <!--Lettre M-->
      <text x="-13.5" y="12" size="24" text="M"/>
      <!--Bornes-->
      <terminal orientation="n" x="-20" y="-40"/>
      <terminal orientation="n" x="0"   y="-40"/>
      <terminal orientation="n" x="20"  y="-40"/>
    </description>
  </definition>
 

This XML is an “induction motor”: moteur asynchrone triphase

The doctype in the first line is not very important in that a DTD is not sufficient to fully validate an element definition

The main element is the XML tag “definition.” For the case we have several types of definitions in the future, use the type attribute to specify that this is a defining element.

Dimensions of the element

One of the first things to be specified in the definition of an element is its size: width (width) and height (height) in pixels. Both dimensions must be integer multiples of 10. If this is not the case, the TEQ will round to the next ten (eg 50 to 42 pixels). They determine the size and bounding rectangle of the item.

Schema explicatif

Attachment point (hotspot) of the element

The attachment point of the element is the point hanging on the mouse during a drag and drop the item. Must be integer coordinates. “Hotspot_x” is the abscissa, “hotspot_y” is ordered. It is considered that the upper left corner of the rectangle defining element is the origin. If the values ​​exceed the given bounding rectangle, it will be limited to the size of the element. The hotspot is also the center of rotation used during the shift of the element.

Element Orientation

We must then define what are the possible directions of the element. The orientation of the element is used when installing the drivers but also to prevent the user to rotate an element in a direction that would not make sense. The attribute policy is defined by a sequence of four characters, each character defines the behavior for an orientation.

  • 1 st character: North
  • 2 nd character: East
  • 3 th character: South
  • 4 th character: West

Each character can have the following value:

  • D to “default” indicates that, by default, the item is considered to be oriented in this direction. It is essential to indicate a default orientation.
  • Y for “yes”: the user can orient the element in that direction.
  • N for “no”: the user can not guide the element in that direction.

Example: orientation = “ydny” means that the item is drawn south-facing and can be turned to the north and west but not east.

Internal Connections

By default, it is not possible to connect two terminals of the same element. This behavior can be changed with the attribute “ic” and true.

The rest of the definition

The remaining definition is divided into three parts: the first is the definition of the name or names of the element with the XML element “names”. The second is an open field for additional information regarding the element with the XML element “information”. The third is the description of the design and composition of the element with the XML element “description”.

Define one or more names for the element

A given element has only one name per language. It is therefore possible to define as many names as possible translations. Depending on the language of the system (which may be different translations available for TEQ), the appropriate name is selected and displayed. Internally, the TEQ can handle file names.

The XML element “names” accepts children XML elements “name”. Each “name” must have “lang” attribute, containing a two-letter language. This is actually the first two letters of “local” system. Example: to specify the name of an element in a system configured with the language / locale “fr_FR @ euro”, indicate lang = “fr”.

Elements “name” without “lang” attribute are ignored. If the system language is not found in the names of the element, the English language (lang = “en”) is used instead.

Additional information Element

The XML element “names” is designed to accommodate a simple text box to store many and varied information about the item. Although this field is free (everyone brings what they want), the project recommends QElectroTech the presence of two minimum information: name and surname of the author of the item and its license, as in example at the top of this page. Moreover, unlike the name of the item, this field is not intended to be translated. The project QElectroTech recommends to write the contents in English.

Draw and dial element

The definition of the design of the item is close enough to the encoding of an SVG image. Parts of the drawing are drawn in the same order as the XML elements, that is to say that an element may overlap its predecessors. Invalid XML elements are ignored.

Attributes style

For most of the XML elements representing a portion of the drawing, it is possible to define style attributes including on the type of stroke and fill of these parts of the drawing.

The use of “style” attribute is one that is made in standard HTML and XHTML: its value is a result of couples style / value separated by semicolons. Example:

<circle x="-20" y="-20" diameter="40" antialias="true" style="line-weight:none;filling:white;"/>

Line Style

The line style is defined with the style “line-style”. The possible values ​​are:

  • dashed: dotted line
  • normal [default]: solid line

Line Color

The color of the line is defined with the style “color”. The possible values ​​are:

  • white: white line
  • black [default]: black line

This setting also applies to the text

Line width

The line thickness is defined with the style “line-weight.” The possible values ​​are:

  • thin: thin line, always displayed with a thickness of 1 pixel
  • normal [default]: line normal
  • none: no visible line

Filling

The filling is defined with the style “filling”. The possible values ​​are:

  • White: Fill in blank
  • Black: black filler
  • None [default]: no fill

Attribute antialiasing

In addition to the “style” attribute, it is possible to use the attribute “antialiasing”, this attribute accepts the values ​​“true” or “false”. The antialiasing is disabled by default. This attribute specifies whether to render this part of the drawing (and not the entire element) will be done so antialiased or not.

 Antialiasing \ \ An LED with and without antialiasing. Note that antialiasing is not always desirable.

Bookmark

The coordinates are relative to the reference whose origin is the attachment point (hotspot) and not the upper left corner of the rectangle bounding the element. The x axis is horizontal and moves to the right. The y-axis is vertical and goes down. The unit is pixel. The actual values ​​are accepted (example: x = “2.5”).

Do not leave the bounding rectangle element, under penalty of glitches.

Line

The line element accepts the following attributes:

  • X1: abscissa of the first end of the line
  • Y1: ordered the first end of the line
  • X2: x-axis of the second end of the line
  • Y2: ordered the second end of the line
  • End1: type of tip to the first end
  • Length1: length used to draw the tip of the first end. The default is “none”.
  • End2: type end to the second end
  • Length2: length used to draw the tip of the second end. The default is “none”.

The types of nozzles available are:

Tip value for the attribute \ \ end1 (or end2)
Normal “none”
Arrow simple “simple”
Arrow triangular “triangle”
Circle “circle”
Square “diamond”

Rectangle

A rectangle is defined by the coordinates of its upper left corner and dimensions (width and height). Rect element accepts the following attributes:

  • X: abscissa of the upper left corner of the rectangle
  • Y: ordinate of upper left corner of the rectangle
  • Width: width of the rectangle
  • Height: height of the rectangle

Ellipse

An ellipse is defined by the rectangle in which it operates. The ellipse element accepts the following attributes:

  • X: abscissa of the upper left corner of the rectangle
  • Y: ordinate of upper left corner of the rectangle
  • Width: width of the rectangle
  • Height: height of the rectangle

Circle

The circle element is defined by the following attributes:

  • X: abscissa of the upper left corner to square the circle
  • Y: ordinate of upper left corner to square the circle
  • Diameter: diameter of the circle

 Ellipse, circle and arc

Arc

An arc is defined as a portion of an ellipse. The element of arc therefore shares attributes with the ellipse:

  • X: abscissa of the upper left corner of the rectangle
  • Y: ordinate of upper left corner of the rectangle
  • Width: width of the rectangle
  • Height: height of the rectangle

To these attributes would add two more:

  • Start: start angle: the angle “0 degree” is three hours
  • Angle: range (in degrees) of the arc and a positive value is in the opposite direction of clockwise

Polygon

The polygon is defined by a sequence of points. The “polygon element thus takes a series of attributes of the form: x1, y1, x2, y2, x3, y3, x4, y4, etc … By default, the polygon is closed. It can be opened in closed using the optional attribute to “false”. Example: code> xml> <! - Draw a square → <polygon x1=“1” y1=“1” x2=“41” y2=“1” x3=“41” y3=“41” x4=“1” y4=“41” /> <! - Draw three sides of the square → <polygon x1=“1” y1=“1” x2=“41” y2=“1” x3=“41” y3=“41” x4=“1” y4=“41” closed=“false” /> </ Code>

Text

The text element accepts the following attributes:

  • X: abscissa of the beginning of the text
  • Y: ordinate of the start of the text
  • Text: text to draw
  • Size: size to use for the font
  • Rotation: angle of the text (see details below)

The font is “Sans Serif”.

You can set the default orientation angle of the text field with the attribute “rotation”. Its value is a decimal number that must be between -360.0 ° and 360.0 °. 0 ° corresponds to the position of the small hand of a watch when it is 3 hours. A negative number represents an angle in the opposite direction of clockwise while a positive value represents an angle in the direction of clockwise.

The positioning and rotation takes place over a point whose ordinate corresponds to the “baseline” of the text while the abscissa corresponds to the left side of the text itself.

Note that, once the item placed on the scheme or its position or orientation can not be changed by the user.

Terminal

The terminals are the connection points used to connect components together by intermediates of drivers. There are always drawn last (ie above the other parts of the drawing), regardless of their location in the XML file.

So they take three attributes:

  • X: abscissa of the terminal
  • Y: ordinate of the terminal
  • Orientation: orientation of the terminal = North (n), south (s), East (E) or West (W)

Text fields

Text fields are text editable by the user changes the text are recorded in drawings.

A text field is an XML element “input”. It accepts the same attributes that an element “text” except that the attribute “text” is the default text.

You can set the default orientation angle of the text field with the attribute “rotation”. Its value is a decimal number that must be between -360.0 ° and 360.0 °. 0 ° corresponds to the position of the small hand of a watch when it is 3 hours. A negative number represents an angle in the opposite direction of clockwise while a positive value represents an angle in the direction of clockwise. Note that, once the item placed on the diagram, this orientation can be changed by the user.

The positioning and rotation are carried over in the middle left side of the text field .

By default, the text field behaves so as to remain horizontal despite the rotations experienced by its parent (we say it does not follow the rotation of its parent element). This behavior can be changed with the attribute “rotate” and set to true.

Print/export
Languages
Translations of this page: