[qet] [3341] Conductor: add option one text per potential in the same diagram ( work in progress)

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


Revision: 3341
Author:   blacksun
Date:     2014-10-03 19:02:01 +0200 (Fri, 03 Oct 2014)
Log Message:
-----------
Conductor: add option one text per potential in the same diagram (work in progress)

Modified Paths:
--------------
    trunk/sources/conductorproperties.cpp
    trunk/sources/conductorproperties.h
    trunk/sources/configpages.cpp
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/conductor.h
    trunk/sources/ui/conductorpropertiesdialog.cpp
    trunk/sources/ui/conductorpropertieswidget.cpp
    trunk/sources/ui/conductorpropertieswidget.h
    trunk/sources/ui/conductorpropertieswidget.ui
    trunk/sources/ui/diagrampropertiesdialog.cpp

Modified: trunk/sources/conductorproperties.cpp
===================================================================
--- trunk/sources/conductorproperties.cpp	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/conductorproperties.cpp	2014-10-03 17:02:01 UTC (rev 3341)
@@ -224,7 +224,9 @@
 	verti_rotate_text(270),
 	horiz_rotate_text(0),
 	style(Qt::SolidLine),
-	m_show_text(true)
+	m_show_text(true),
+	m_one_text_per_folio(false),
+	m_no_one_text_per_folio(false)
 {
 }
 
@@ -254,6 +256,8 @@
 	e.setAttribute("num", text);
 	e.setAttribute("numsize", text_size);
 	e.setAttribute("displaytext", m_show_text);
+	e.setAttribute("onetextperfolio", m_one_text_per_folio);
+	e.setAttribute("noonetextperfolio", m_no_one_text_per_folio);
 	e.setAttribute("vertirotatetext", verti_rotate_text);
 	e.setAttribute("horizrotatetext", horiz_rotate_text);
 	
@@ -292,6 +296,8 @@
 	text = e.attribute("num");
 	text_size = e.attribute("numsize", QString::number(9)).toInt();
 	m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
+	m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
+	m_no_one_text_per_folio = e.attribute("noonetextperfolio", QString::number(0)).toInt();
 	verti_rotate_text = e.attribute("vertirotatetext").toDouble();
 	horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
 
@@ -311,6 +317,7 @@
 	settings.setValue(prefix + "text", text);
 	settings.setValue(prefix + "textsize", QString::number(text_size));
 	settings.setValue(prefix + "displaytext", m_show_text);
+	settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
 	settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
 	settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
 	singleLineProperties.toSettings(settings, prefix);
@@ -339,6 +346,7 @@
 	text = settings.value(prefix + "text", "_").toString();
 	text_size = settings.value(prefix + "textsize", "7").toInt();
 	m_show_text = settings.value(prefix + "displaytext", true).toBool();
+	m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
 	verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
 	horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
 
@@ -371,7 +379,9 @@
 		other.text_size == text_size &&\
 		other.verti_rotate_text == verti_rotate_text &&\
 		other.horiz_rotate_text == horiz_rotate_text &&\
-		other.singleLineProperties == singleLineProperties
+		other.singleLineProperties == singleLineProperties &&\
+		other.m_one_text_per_folio == m_one_text_per_folio &&\
+		other.m_no_one_text_per_folio == m_no_one_text_per_folio
 	);
 }
 

Modified: trunk/sources/conductorproperties.h
===================================================================
--- trunk/sources/conductorproperties.h	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/conductorproperties.h	2014-10-03 17:02:01 UTC (rev 3341)
@@ -85,6 +85,8 @@
 	double verti_rotate_text;
 	double horiz_rotate_text;
 	bool m_show_text;
+	bool m_one_text_per_folio;
+	bool m_no_one_text_per_folio;
 	/// conducteur style (Qt::SolidLine or Qt::DashLine)
 	Qt::PenStyle style;
 	

Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/configpages.cpp	2014-10-03 17:02:01 UTC (rev 3341)
@@ -47,6 +47,7 @@
 	ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true);
 	// default conductor properties
 	cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties());
+	cpw -> setHiddenNoOneTextPerFolio(true);
 	// default propertie of report label
 	rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties());
 	// default properties of xref

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2014-10-03 17:02:01 UTC (rev 3341)
@@ -1188,7 +1188,35 @@
  * If text was moved by user, this function do nothing, except check if text is near conductor.
  */
 void Conductor::calculateTextItemPosition() {
-	if (!text_item) return;
+	if (!text_item || !diagram()) return;
+
+	if (diagram() -> defaultConductorProperties.m_one_text_per_folio == true) {
+		QSet<Conductor *> conductor_list = relatedPotentialConductors(false);
+		Conductor *longuest_conductor = this;
+
+		//Search the longuest conductor
+		foreach (Conductor *c, conductor_list) {
+			if (c -> length() > longuest_conductor -> length()) {
+				longuest_conductor = c;
+			}
+		}
+
+		//The longuest conductor isn't this conductor
+		//we call calculateTextItemPosition of the longuest conductor
+		if(longuest_conductor != this) {
+			longuest_conductor -> calculateTextItemPosition();
+			return;
+		}
+
+		//At this point this conductor is the longuest conductor
+		//we hide all text of conductor_list
+		foreach (Conductor *c, conductor_list) {
+			c -> textItem() -> setVisible(false);
+		}
+	}
+
+	//Make sure text item is visible
+	text_item -> setVisible(true);
 	
 	//position
 	if (text_item -> wasMovedByUser()) {
@@ -1405,10 +1433,12 @@
  * @brief Conductor::relatedPotentialConductors
  * Return all conductors at the same potential of this conductor, this conductor isn't
  * part of the returned QSet.
+ * @param all_diagram : if true search in all diagram of the project,
+ * false search only in the parent diagram of this conductor
  * @param t_list, a list of terminal already cheched for the serach of potential.
  * @return  a QSet of conductor at the same potential.
  */
-QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_list) {
+QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram, QList <Terminal *> *t_list) {
 	bool declar_t_list = false;
 	if (t_list == 0) {
 		declar_t_list = true;
@@ -1426,7 +1456,7 @@
 			QList <Conductor *> other_conductors_list_t = terminal -> conductors();
 
 			//get terminal share the same potential of @terminal, of parent element
-			Terminal *t1_bis = relatedPotentialTerminal(terminal);
+			Terminal *t1_bis = relatedPotentialTerminal(terminal, all_diagram);
 			if (t1_bis && !t_list->contains(t1_bis)) {
 				t_list -> append(t1_bis);
 				other_conductors_list_t += t1_bis->conductors();
@@ -1435,7 +1465,7 @@
 			other_conductors_list_t.removeAll(this);
 			// Research the conductors connected to conductors already found
 			foreach (Conductor *c, other_conductors_list_t) {
-				other_conductors += c -> relatedPotentialConductors(t_list);
+				other_conductors += c -> relatedPotentialConductors(all_diagram, t_list);
 			}
 			other_conductors += other_conductors_list_t.toSet();
 		}
@@ -1454,11 +1484,13 @@
  * For folio report, return the terminal of linked other report.
  * For Terminal element, return the other terminal of terminal element.
  * @param t terminal to start search
+ * @param all_diagram :if true return all related terminal,
+ * false return only terminal in the same diagram of @t
  * @return
  */
-Terminal * Conductor::relatedPotentialTerminal (Terminal *t) {
+Terminal * Conductor::relatedPotentialTerminal (Terminal *t, const bool all_diagram) {
 	// If terminal parent element is a folio report.
-	if (t->parentElement()->linkType() & Element::AllReport) {
+	if (all_diagram && t->parentElement()->linkType() & Element::AllReport) {
 		QList <Element *> elmt_list = t->parentElement()->linkedElements();
 		if (!elmt_list.isEmpty()) {
 			return (elmt_list.first()->terminals().first());

Modified: trunk/sources/qetgraphicsitem/conductor.h
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.h	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/qetgraphicsitem/conductor.h	2014-10-03 17:02:01 UTC (rev 3341)
@@ -107,7 +107,7 @@
 	virtual Highlight highlight() const;
 	virtual void setHighlighted(Highlight);
 	void autoText();
-	QSet<Conductor *> relatedPotentialConductors(QList <Terminal *> *t_list=0);
+	QSet<Conductor *> relatedPotentialConductors(const bool all_diagram = true, QList <Terminal *> *t_list=0);
 	QETDiagramEditor* diagramEditor() const;
 	void editProperty ();
 	
@@ -181,6 +181,6 @@
 	static qreal conductor_bound(qreal, qreal, bool);
 	static Qt::Corner movementType(const QPointF &, const QPointF &);
 	static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
-	Terminal * relatedPotentialTerminal (Terminal *);
+	Terminal * relatedPotentialTerminal (Terminal *, const bool all_diagram = true);
 };
 #endif

Modified: trunk/sources/ui/conductorpropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/conductorpropertiesdialog.cpp	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/ui/conductorpropertiesdialog.cpp	2014-10-03 17:02:01 UTC (rev 3341)
@@ -36,6 +36,7 @@
 {
 	ui->setupUi(this);
 	m_cpw = new ConductorPropertiesWidget(conductor->properties());
+	m_cpw -> setHiddenOneTextPerFolio(true);
 	ui -> main_layout -> insertWidget(1, m_cpw);
 }
 

Modified: trunk/sources/ui/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.cpp	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/ui/conductorpropertieswidget.cpp	2014-10-03 17:02:01 UTC (rev 3341)
@@ -70,17 +70,21 @@
 	setColorButton(m_properties.color);
 	int index = ui -> m_line_style_cb->findData(m_properties.style);
 	if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index);
-	ui -> m_text_le      -> setText    (m_properties.text);
-	ui -> m_text_size_sb -> setValue   (m_properties.text_size);
-	ui -> m_show_text_cb -> setChecked (m_properties.m_show_text);
-	ui -> m_earth_cb     -> setChecked (m_properties.singleLineProperties.hasGround);
-	ui -> m_neutral_cb   -> setChecked (m_properties.singleLineProperties.hasNeutral);
-	ui -> m_pen_cb       -> setChecked (m_properties.singleLineProperties.isPen());
-	ui -> m_phase_cb     -> setChecked (m_properties.singleLineProperties.phasesCount());
-	ui -> m_phase_slider -> setValue   (m_properties.singleLineProperties.phasesCount());
-	m_verti_select       -> setValue   (m_properties.verti_rotate_text);
-	m_horiz_select       -> setValue   (m_properties.horiz_rotate_text);
 
+	ui -> m_text_le                  -> setText    (m_properties.text);
+	ui -> m_text_size_sb             -> setValue   (m_properties.text_size);
+	ui -> m_show_text_cb             -> setChecked (m_properties.m_show_text);
+	ui -> m_one_text_per_folio_cb    -> setChecked (m_properties.m_one_text_per_folio);
+	ui -> m_no_one_text_per_folio_cb -> setChecked (m_properties.m_no_one_text_per_folio);
+	ui -> m_earth_cb                 -> setChecked (m_properties.singleLineProperties.hasGround);
+	ui -> m_neutral_cb               -> setChecked (m_properties.singleLineProperties.hasNeutral);
+	ui -> m_pen_cb                   -> setChecked (m_properties.singleLineProperties.isPen());
+	ui -> m_phase_cb                 -> setChecked (m_properties.singleLineProperties.phasesCount());
+	ui -> m_phase_slider             -> setValue   (m_properties.singleLineProperties.phasesCount());
+
+	m_verti_select                   -> setValue   (m_properties.verti_rotate_text);
+	m_horiz_select                   -> setValue   (m_properties.horiz_rotate_text);
+
 	setConductorType(m_properties.type);
 	updatePreview(false);
 }
@@ -93,16 +97,20 @@
 	ConductorProperties properties_;
 	if (ui -> m_multi_rb  -> isChecked()) properties_.type = ConductorProperties::Multi;
 	else if (ui -> m_single_rb -> isChecked()) properties_.type = ConductorProperties::Single;
-	properties_.color = ui->m_color_pb->palette().color(QPalette::Button);
-	properties_.style = static_cast<Qt::PenStyle>(ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).toInt());
-	properties_.text = ui -> m_text_le -> text();
-	properties_.text_size = ui -> m_text_size_sb -> value();
-	properties_.m_show_text = ui -> m_show_text_cb -> isChecked();
-	properties_.verti_rotate_text = m_verti_select -> value();
-	properties_.horiz_rotate_text = m_horiz_select -> value();
-	properties_.singleLineProperties.hasGround = ui -> m_earth_cb -> isChecked();
+
+	properties_.color                   = ui->m_color_pb->palette().color(QPalette::Button);
+	properties_.style                   = static_cast<Qt::PenStyle>(ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).toInt());
+	properties_.text                    = ui -> m_text_le -> text();
+	properties_.text_size               = ui -> m_text_size_sb -> value();
+	properties_.m_show_text             = ui -> m_show_text_cb -> isChecked();
+	properties_.m_one_text_per_folio    = ui -> m_one_text_per_folio_cb -> isChecked();
+	properties_.m_no_one_text_per_folio = ui -> m_no_one_text_per_folio_cb -> isChecked();
+	properties_.verti_rotate_text       = m_verti_select -> value();
+	properties_.horiz_rotate_text       = m_horiz_select -> value();
+
+	properties_.singleLineProperties.hasGround  = ui -> m_earth_cb -> isChecked();
 	properties_.singleLineProperties.hasNeutral = ui -> m_neutral_cb -> isChecked();
-	properties_.singleLineProperties.is_pen = ui -> m_pen_cb -> isChecked();
+	properties_.singleLineProperties.is_pen     = ui -> m_pen_cb -> isChecked();
 	properties_.singleLineProperties.setPhasesCount(ui -> m_phase_cb -> isChecked() ? ui -> m_phase_sb -> value() : 0);
 
 	return properties_;
@@ -116,11 +124,31 @@
 	this->setDisabled(ro);
 }
 
+/**
+ * @brief ConductorPropertiesWidget::addAutonumWidget
+ * @param widget
+ */
 void ConductorPropertiesWidget::addAutonumWidget(QWidget *widget) {
 	ui->m_autonum_layout->addWidget(widget);
 }
 
 /**
+ * @brief ConductorPropertiesWidget::setHiddenOneTextPerFolio
+ * @param hide
+ */
+void ConductorPropertiesWidget::setHiddenOneTextPerFolio(const bool &hide) {
+	ui -> m_one_text_per_folio_cb -> setHidden(hide);
+}
+
+/**
+ * @brief ConductorPropertiesWidget::setHiddenNoOneTextPerFolio
+ * @param hide
+ */
+void ConductorPropertiesWidget::setHiddenNoOneTextPerFolio(const bool &hide) {
+	ui -> m_no_one_text_per_folio_cb -> setHidden(hide);
+}
+
+/**
  * @brief ConductorPropertiesWidget::initWidget
  */
 void ConductorPropertiesWidget::initWidget() {

Modified: trunk/sources/ui/conductorpropertieswidget.h
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.h	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/ui/conductorpropertieswidget.h	2014-10-03 17:02:01 UTC (rev 3341)
@@ -41,6 +41,8 @@
 		void setReadOnly(const bool &ro);
 
 		void addAutonumWidget (QWidget *widget);
+		void setHiddenOneTextPerFolio   (const bool &hide);
+		void setHiddenNoOneTextPerFolio (const bool &hide);
 
 	private:
 		void initWidget();

Modified: trunk/sources/ui/conductorpropertieswidget.ui
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.ui	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/ui/conductorpropertieswidget.ui	2014-10-03 17:02:01 UTC (rev 3341)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>430</width>
-    <height>407</height>
+    <width>570</width>
+    <height>453</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -94,7 +94,22 @@
           </layout>
          </item>
          <item>
-          <layout class="QHBoxLayout" name="m_autonum_layout"/>
+          <layout class="QVBoxLayout" name="m_autonum_layout">
+           <item>
+            <widget class="QCheckBox" name="m_one_text_per_folio_cb">
+             <property name="text">
+              <string>Afficher un seul texte par potentiel présent sur un folio. (expérimental)</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QCheckBox" name="m_no_one_text_per_folio_cb">
+             <property name="text">
+              <string>Ne pas subir l'option :  afficher un seul texte par potentiel présent sur un folio. (Inactifl)</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
          </item>
          <item>
           <widget class="QLabel" name="label_3">

Modified: trunk/sources/ui/diagrampropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/diagrampropertiesdialog.cpp	2014-09-28 14:50:20 UTC (rev 3340)
+++ trunk/sources/ui/diagrampropertiesdialog.cpp	2014-10-03 17:02:01 UTC (rev 3341)
@@ -64,6 +64,7 @@
 
 	//Conductor widget
 	ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors, this);
+	cpw -> setHiddenNoOneTextPerFolio(true);
 	cpw -> setReadOnly(diagram_is_read_only);
 
 	//Conductor autonum


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