[qet] [3201] xref: switch contact is managed by cross ref

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3201
Author:   blacksun
Date:     2014-07-07 16:36:53 +0200 (Mon, 07 Jul 2014)
Log Message:
-----------
xref: switch contact is managed by cross ref

Modified Paths:
--------------
    trunk/sources/editor/ui/elementpropertieseditorwidget.cpp
    trunk/sources/properties/xrefproperties.cpp
    trunk/sources/properties/xrefproperties.h
    trunk/sources/qetgraphicsitem/crossrefitem.cpp
    trunk/sources/qetgraphicsitem/crossrefitem.h
    trunk/sources/ui/xrefpropertieswidget.cpp
    trunk/sources/ui/xrefpropertieswidget.ui

Added Paths:
-----------
    trunk/elements/03relayage/02esclaves/auxiliary_contacts/contnonc.elmt

Added: trunk/elements/03relayage/02esclaves/auxiliary_contacts/contnonc.elmt
===================================================================
--- trunk/elements/03relayage/02esclaves/auxiliary_contacts/contnonc.elmt	                        (rev 0)
+++ trunk/elements/03relayage/02esclaves/auxiliary_contacts/contnonc.elmt	2014-07-07 14:36:53 UTC (rev 3201)
@@ -0,0 +1,31 @@
+<definition width="30" version="0.4" hotspot_x="25" hotspot_y="25" height="50" link_type="slave" type="element" ic="true" orientation="dyyy">
+    <names>
+        <name lang="ar">مُلامس NO-NC</name>
+        <name lang="de">Wechselkontakt (NO/NC)</name>
+        <name lang="ru">Проктой контакт (НР)</name>
+        <name lang="el">Απλή μεταγωγική επαφή</name>
+        <name lang="en">Simple contact</name>
+        <name lang="it">Contatto semplice (NC/NO)</name>
+        <name lang="fr">Contact NO - NC</name>
+        <name lang="pl">Zestyk przełączny przerwowy</name>
+        <name lang="es">Contacto simple</name>
+        <name lang="nl">enkel contact (NC/NO)</name>
+        <name lang="cs">Jednoduchý kontakt</name>
+    </names>
+    <kindInformations>
+        <kindInformation name="number" show="1">1</kindInformation>
+        <kindInformation name="type" show="1">simple</kindInformation>
+        <kindInformation name="state" show="1">SW</kindInformation>
+    </kindInformations>
+    <informations>Author: The QElectroTech team
+License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
+    <description>
+        <polygon antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" closed="false" y1="-10" x1="-15" y2="10" x2="0" y3="20" x3="0"/>
+        <input x="13" y="-3" size="9" text="_" tagg="label"/>
+        <line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-20" x1="0" y2="-10" x2="0"/>
+        <polygon antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" closed="false" y1="-20" x1="-20" y2="-8" x2="-20" y3="-8" x3="-12"/>
+        <terminal x="0" y="-20" orientation="n"/>
+        <terminal x="0" y="20" orientation="s"/>
+        <terminal x="-20" y="-20" orientation="n"/>
+    </description>
+</definition>

Modified: trunk/sources/editor/ui/elementpropertieseditorwidget.cpp
===================================================================
--- trunk/sources/editor/ui/elementpropertieseditorwidget.cpp	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/editor/ui/elementpropertieseditorwidget.cpp	2014-07-07 14:36:53 UTC (rev 3201)
@@ -79,6 +79,7 @@
 	// Slave option
 	ui -> m_state_cb -> addItem(tr("Normalement ouvert"),   QVariant("NO"));
 	ui -> m_state_cb -> addItem(tr("Normalement ferm\351"), QVariant("NC"));
+	ui -> m_state_cb -> addItem(tr("Inverseur"),			QVariant("SW"));
 	ui -> m_type_cb  -> addItem(tr("Simple"),				QVariant("simple"));
 	ui -> m_type_cb  -> addItem(tr("Puissance"),			QVariant("power"));
 	ui -> m_type_cb  -> addItem(tr("Temporis\351 travail"), QVariant("delayOn"));

Modified: trunk/sources/properties/xrefproperties.cpp
===================================================================
--- trunk/sources/properties/xrefproperties.cpp	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/properties/xrefproperties.cpp	2014-07-07 14:36:53 UTC (rev 3201)
@@ -26,6 +26,7 @@
 	m_show_power_ctc = true;
 	m_display = Cross;
 	m_snap_to = Bottom;
+	m_prefix_keys << "power" << "delay" << "switch";
 }
 
 /**
@@ -40,8 +41,9 @@
 	settings.setValue(prefix + "displayhas", display);
 	QString snap = m_snap_to == Bottom? "bottom" : "label";
 	settings.setValue(prefix + "snapto", snap);
-	settings.setValue(prefix + "powerprefix",  m_prefix.value("power"));
-	settings.setValue(prefix + "delayprefix", m_prefix.value("delay"));
+	foreach (QString key, m_prefix.keys()) {
+		settings.setValue(prefix + key + "prefix", m_prefix.value(key));
+	}
 }
 
 /**
@@ -56,8 +58,9 @@
 	display == "cross"? m_display = Cross : m_display = Contacts;
 	QString snap = settings.value(prefix + "snapto", "label").toString();
 	snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
-	m_prefix.insert("power", settings.value(prefix + "powerprefix").toString());
-	m_prefix.insert("delay", settings.value(prefix + "delayprefix").toString());
+	foreach (QString key, m_prefix_keys) {
+		m_prefix.insert(key, settings.value(prefix + key + "prefix").toString());
+	}
 }
 
 /**
@@ -71,8 +74,9 @@
 	xml_element.setAttribute("displayhas", display);
 	QString snap = m_snap_to == Bottom? "bottom" : "label";
 	xml_element.setAttribute("snapto", snap);
-	xml_element.setAttribute("powerprefix", m_prefix.value("power"));
-	xml_element.setAttribute("delayprefix", m_prefix.value("delay"));
+	foreach (QString key, m_prefix.keys()) {
+		xml_element.setAttribute(key + "prefix", m_prefix.value(key));
+	}
 }
 
 /**
@@ -86,8 +90,9 @@
 	display == "cross"? m_display = Cross : m_display = Contacts;
 	QString snap = xml_element.attribute("snapto", "label");
 	snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
-	m_prefix.insert("power", xml_element.attribute("powerprefix"));
-	m_prefix.insert("delay", xml_element.attribute("delayprefix"));
+	foreach (QString key, m_prefix_keys) {
+		m_prefix.insert(key, xml_element.attribute(key + "prefix"));
+	}
 }
 
 bool XRefProperties::operator ==(const XRefProperties &xrp) const{

Modified: trunk/sources/properties/xrefproperties.h
===================================================================
--- trunk/sources/properties/xrefproperties.h	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/properties/xrefproperties.h	2014-07-07 14:36:53 UTC (rev 3201)
@@ -19,6 +19,7 @@
 #define XREFPROPERTIES_H
 
 #include "propertiesinterface.h"
+#include <QStringList>
 
 /**
  * @brief The XRefProperties class
@@ -64,6 +65,7 @@
 	DisplayHas m_display;
 	SnapTo m_snap_to;
 	QHash <QString, QString> m_prefix;
+	QStringList m_prefix_keys;
 };
 
 #endif // XREFPROPERTIES_H

Modified: trunk/sources/qetgraphicsitem/crossrefitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.cpp	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/qetgraphicsitem/crossrefitem.cpp	2014-07-07 14:36:53 UTC (rev 3201)
@@ -92,8 +92,9 @@
 	txt += "-";
 	txt += elmt->diagram()->convertPosition(elmt -> scenePos()).toString();
 	if (add_prefix) {
-		if (elmt->kindInformations()["type"].toString() == "power") txt.prepend(m_properties.prefix("power"));
+		if      (elmt->kindInformations()["type"].toString() == "power")        txt.prepend(m_properties.prefix("power"));
 		else if (elmt->kindInformations()["type"].toString().contains("delay")) txt.prepend(m_properties.prefix("delay"));
+		else if (elmt->kindInformations()["state"].toString() == "SW")          txt.prepend(m_properties.prefix("switch"));
 	}
 	return txt;
 }
@@ -111,11 +112,23 @@
 	foreach (Element *elmt, m_element->linkedElements()) {
 		QString state = elmt->kindInformations()["state"].toString();
 
-		if (state == "NO") tmp_str = &no_str;
-		else if (state == "NC") tmp_str = &nc_str;
+		//NO and NC are displayed in single place in the cross
+		if (state == "NO" || state == "NC") {
+			if (state == "NO") tmp_str = &no_str;
+			else if (state == "NC") tmp_str = &nc_str;
 
-		if (!tmp_str->isEmpty()) *tmp_str += "\n";
-		*tmp_str += elementPositionText(elmt, add_prefix);
+			if (!tmp_str->isEmpty()) *tmp_str += "\n";
+			*tmp_str += elementPositionText(elmt, add_prefix);
+		}
+
+		//SW are displayed in NC and NO column in the cross
+		else if (state == "SW") {
+			for (int i = 0; i < 2; i++) {
+				tmp_str = i==0? &no_str : &nc_str;
+				if (!tmp_str->isEmpty()) *tmp_str += "\n";
+				*tmp_str += elementPositionText(elmt, add_prefix);
+			}
+		}
 	}
 }
 
@@ -350,7 +363,10 @@
 		for (int i=0; i<info["number"].toInt(); i++) {
 			int option = 0;
 
-			info["state"].toString() == "NO"? option = NO : option = NC;
+			QString state = info["state"].toString();
+				 if (state == "NO") option = NO;
+			else if (state == "NC") option = NC;
+			else if (state == "SW") option = SW;
 
 			QString type = info["type"].toString();
 			if (type == "power") option += Power;
@@ -368,83 +384,111 @@
 
 /**
  * @brief CrossRefItem::drawContact
- * draw one contacte, the type of contact to draw is define in ctc.
- * @param painter painter to use
- * @param ctc option for draw the contact, see enum CONTACTS
+ * Draw one contact, the type of contact to draw is define in @flags.
+ * @param painter, painter to use
+ * @param flags, define how to draw the contact (see enul CONTACTS)
+ * @param str, the text to display for this contact (the position of the contact).
  */
 void CrossRefItem::drawContact(QPainter &painter, int flags, QString str) {
 	int offset = m_drawed_contacts*10;
 
-	//draw the basic line
-	painter.drawLine(0, offset+6, 8, offset+6);
-	painter.drawLine(16, offset+6, 24, offset+6);
+	//Draw NO or NC contact
+	if (flags &NOC) {
+		//draw the basic line
+		painter.drawLine(0, offset+6, 8, offset+6);
+		painter.drawLine(16, offset+6, 24, offset+6);
 
-	///take exemple of this code for display the terminal text
-	/*QFont font = QETApp::diagramTextsFont(4);
-	font.setBold(true);
-	painter.setFont(font);
-	QRectF bt(0, offset, 24, 10);
-	int txt = 10 + m_drawed_contacts;
-	painter.drawText(bt, Qt::AlignLeft|Qt::AlignTop, QString::number(txt));
-	painter.drawText(bt, Qt::AlignRight|Qt::AlignTop, QString::number(txt));
-	painter.setFont(QETApp::diagramTextsFont(5));*/
+		///take exemple of this code for display the terminal text
+		/*QFont font = QETApp::diagramTextsFont(4);
+		font.setBold(true);
+		painter.setFont(font);
+		QRectF bt(0, offset, 24, 10);
+		int txt = 10 + m_drawed_contacts;
+		painter.drawText(bt, Qt::AlignLeft|Qt::AlignTop, QString::number(txt));
+		painter.drawText(bt, Qt::AlignRight|Qt::AlignTop, QString::number(txt));
+		painter.setFont(QETApp::diagramTextsFont(5));*/
 
-	//draw open contact
-	if (flags &NO) {
-		painter.drawLine(8, offset+9, 16, offset+6);
-	}
-	//draw close contact
-	if (flags &NC) {
-		QPointF p1[3] = {
-			QPointF(8, offset+6),
-			QPointF(9, offset+6),
-			QPointF(9, offset+2.5)
-		};
-		painter.drawPolyline(p1,3);
-		painter.drawLine(8, offset+3, 16, offset+6);
-	}
+		//draw open contact
+		if (flags &NO) {
+			painter.drawLine(8, offset+9, 16, offset+6);
+		}
+		//draw close contact
+		if (flags &NC) {
+			QPointF p1[3] = {
+				QPointF(8, offset+6),
+				QPointF(9, offset+6),
+				QPointF(9, offset+2.5)
+			};
+			painter.drawPolyline(p1,3);
+			painter.drawLine(8, offset+3, 16, offset+6);
+		}
 
-	//draw half circle for power contact
-	if (flags &Power) {
-		QRectF arc(4, offset+4, 4, 4);
-		if (flags &NO)
-			painter.drawArc(arc, 180*16, 180*16);
-		else
-			painter.drawArc(arc, 0, 180*16);
-	}
+		//draw half circle for power contact
+		if (flags &Power) {
+			QRectF arc(4, offset+4, 4, 4);
+			if (flags &NO)
+				painter.drawArc(arc, 180*16, 180*16);
+			else
+				painter.drawArc(arc, 0, 180*16);
+		}
 
-	// draw half circle for delay contact
-	if(flags &DelayOn || flags &DelayOff) {
-		// for delay on contact
-		if (flags &DelayOn) {
-			if (flags &NO) {
-				painter.drawLine(12, offset+4, 12, offset+6);
-				QRectF r(9.5, offset+1, 5, 3);
-				painter.drawArc(r, 180*16, 180*16);
+		// draw half circle for delay contact
+		if(flags &Delay) {
+			// for delay on contact
+			if (flags &DelayOn) {
+				if (flags &NO) {
+					painter.drawLine(12, offset+4, 12, offset+6);
+					QRectF r(9.5, offset+1, 5, 3);
+					painter.drawArc(r, 180*16, 180*16);
+				}
+				if (flags &NC) {
+					painter.drawLine(QPointF(13.5, offset+2), QPointF(13.5, offset+3.5));
+					QRectF r(11, offset-1, 5, 3);
+					painter.drawArc(r, 180*16, 180*16);
+				}
 			}
-			if (flags &NC) {
-				painter.drawLine(QPointF(13.5, offset+2), QPointF(13.5, offset+3.5));
-				QRectF r(11, offset-1, 5, 3);
-				painter.drawArc(r, 180*16, 180*16);
+			// for delay off contact
+			else {
+				if (flags &NO) {
+					painter.drawLine(12, offset+3, 12, offset+6);
+					QRectF r(9.5, offset+2, 5, 3);
+					painter.drawArc(r, 0, 180*16);
+				}
+				if (flags &NC) {
+					painter.drawLine(QPointF(13.5, offset+1), QPointF(13.5, offset+3.5));
+					QRectF r(11, offset, 5, 3);
+					painter.drawArc(r, 0, 180*16);
+				}
 			}
 		}
-		// for delay off contact
-		else {
-			if (flags &NO) {
-				painter.drawLine(12, offset+3, 12, offset+6);
-				QRectF r(9.5, offset+2, 5, 3);
-				painter.drawArc(r, 0, 180*16);
-			}
-			if (flags &NC) {
-				painter.drawLine(QPointF(13.5, offset+1), QPointF(13.5, offset+3.5));
-				QRectF r(11, offset, 5, 3);
-				painter.drawArc(r, 0, 180*16);
-			}
-		}
+
+		painter.drawText(20, offset, 30, 10, Qt::AlignRight | Qt::AlignVCenter, str);
+		++m_drawed_contacts;
 	}
 
-	painter.drawText(20, offset, 30, 10, Qt::AlignRight | Qt::AlignVCenter, str);
-	++m_drawed_contacts;
+	//Draw a switch contact
+	else if (flags &SW) {
+		//draw the NO side
+		painter.drawLine(0, offset+6, 8, offset+6);
+		//Draw the NC side
+		QPointF p1[3] = {
+			QPointF(0, offset+16),
+			QPointF(8, offset+16),
+			QPointF(8, offset+12)
+		};
+		painter.drawPolyline(p1, 3);
+		//Draw the common side
+		QPointF p2[3] = {
+			QPointF(7, offset+14),
+			QPointF(16, offset+11),
+			QPointF(24, offset+11),
+		};
+		painter.drawPolyline(p2, 3);
+		//Draw position text
+		painter.drawText(20, offset+5, 30, 10, Qt::AlignRight | Qt::AlignVCenter, str);
+		//a switch contact take place of two normal contact
+		m_drawed_contacts += 2;
+	}
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/crossrefitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.h	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/qetgraphicsitem/crossrefitem.h	2014-07-07 14:36:53 UTC (rev 3201)
@@ -48,9 +48,12 @@
 	enum CONTACTS {
 		NO = 1,
 		NC = 2,
-		Power = 4,
-		DelayOn = 8,
-		DelayOff = 16
+		NOC = 3,
+		SW = 4,
+		Power = 8,
+		DelayOn = 16,
+		DelayOff = 32,
+		Delay = 48
 	};
 
 	QRectF boundingRect			() const;

Modified: trunk/sources/ui/xrefpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.cpp	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/ui/xrefpropertieswidget.cpp	2014-07-07 14:36:53 UTC (rev 3201)
@@ -110,8 +110,9 @@
 		 xrp.setSnapTo(XRefProperties::Bottom);
 	else xrp.setSnapTo(XRefProperties::Label);
 	xrp.setShowPowerContac(ui->m_show_power_cb->isChecked());
-	xrp.setPrefix("power", ui->m_power_prefix_le->text());
-	xrp.setPrefix("delay", ui->m_delay_prefix_le->text());
+	xrp.setPrefix("power",  ui->m_power_prefix_le->text());
+	xrp.setPrefix("delay",  ui->m_delay_prefix_le->text());
+	xrp.setPrefix("switch", ui->m_switch_prefix_le->text());
 
 	m_properties.insert(type, xrp);
 }
@@ -136,8 +137,9 @@
 		 ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("bottom"));
 	else ui->m_snap_to_cb->setCurrentIndex(ui->m_snap_to_cb->findData("label"));
 	ui->m_show_power_cb->setChecked(xrp.showPowerContact());
-	ui->m_power_prefix_le->setText(xrp.prefix("power"));
-	ui->m_delay_prefix_le->setText(xrp.prefix("delay"));
+	ui->m_power_prefix_le-> setText(xrp.prefix("power"));
+	ui->m_delay_prefix_le-> setText(xrp.prefix("delay"));
+	ui->m_switch_prefix_le->setText(xrp.prefix("switch"));
 	ui->m_cross_properties_gb->setDisabled(!ui->m_display_has_cross_rb->isChecked());
 }
 

Modified: trunk/sources/ui/xrefpropertieswidget.ui
===================================================================
--- trunk/sources/ui/xrefpropertieswidget.ui	2014-07-07 07:06:02 UTC (rev 3200)
+++ trunk/sources/ui/xrefpropertieswidget.ui	2014-07-07 14:36:53 UTC (rev 3201)
@@ -84,26 +84,36 @@
       </item>
       <item>
        <layout class="QGridLayout" name="gridLayout">
-        <item row="1" column="1">
-         <widget class="QLineEdit" name="m_delay_prefix_le"/>
-        </item>
-        <item row="0" column="1">
-         <widget class="QLineEdit" name="m_power_prefix_le"/>
-        </item>
         <item row="0" column="0">
          <widget class="QLabel" name="label">
           <property name="text">
-           <string>Préfixe des contacts de puissance:</string>
+           <string>Préfixe des contacts de puissance :</string>
           </property>
          </widget>
         </item>
         <item row="1" column="0">
          <widget class="QLabel" name="label_2">
           <property name="text">
-           <string>Préfixe des contacts temporisés:</string>
+           <string>Préfixe des contacts temporisés :</string>
           </property>
          </widget>
         </item>
+        <item row="1" column="1">
+         <widget class="QLineEdit" name="m_delay_prefix_le"/>
+        </item>
+        <item row="0" column="1">
+         <widget class="QLineEdit" name="m_power_prefix_le"/>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="label_5">
+          <property name="text">
+           <string>Préfixe des contacts inverseurs :</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QLineEdit" name="m_switch_prefix_le"/>
+        </item>
        </layout>
       </item>
       <item>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/