mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-08 13:04:13 +02:00
Add View > Show to hide texts, shapes, pictures by kind (bugtracker #301)
A submenu under View (Affichage > Afficher) with one tick per kind: symbol texts, wire texts, free texts, shapes, pictures, tables and cross-references. Unticking one hides it on every folio of every open project; the status bar says how many kinds are hidden. Session only, not saved in the project. Each item is tagged with its kind by its constructor (ShownKinds::tag), so an item created while its kind is hidden starts hidden whatever created it. A tag rather than type(): the cross-reference under a contact's label is a plain QGraphicsTextItem. Items that already hide themselves (wire text switched off, one text per potential, a cross-reference snapped elsewhere) now go through ShownKinds::setVisible(): the kind state can only veto a show, and apply() re-shows only what it hid itself (hidden_key), never what an item hid. Conductor::updateTextVisibility() replaces the same visibility rule pasted in diagrampropertiesdialog.cpp and qetscriptapi.cpp. Hidden items are not selectable (Qt), so Select All, copy and delete skip them. Print, PDF and image export render the scene and leave them out; the DXF export walks items itself and skips them through ShownKinds::isHidden(). CrossRefItem::linkedChanged() keeps following its slaves while hidden only by kind, so its label is right when shown. Known limitation: QGraphicsScene::itemsBoundingRect() still counts hidden items, so Zoom to fit and borderless image export keep their space. Verified: tst_shownkinds (12 cases, two mutation checks) and ctest 55/55; GUI hide/show of symbol texts, wire texts (incl. one text per potential), free texts, shapes and cross-references returns pixel-identical folios; with nothing hidden, --export-dxf of the 24 examples is byte-identical to master (133 files) and --export-pdf renders identically (133 pages). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FPuYPS4T7QuEwjNu22rXD
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "../qetgraphicsitem/conductor.h"
|
||||
#include "../shownkinds.h"
|
||||
#include "../lastusedstyle.h"
|
||||
#include "../qetproject.h"
|
||||
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
@@ -1521,6 +1522,20 @@ QPointF Conductor::posForText(Qt::Orientations &flag)
|
||||
return p1;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::updateTextVisibility
|
||||
Show the text of this conductor if its properties ask for it and wire
|
||||
numbers are not hidden (View > Show). With "one text per potential",
|
||||
call calculateTextItemPosition() afterwards: it hides all texts of the
|
||||
potential but the longest conductor's.
|
||||
*/
|
||||
void Conductor::updateTextVisibility()
|
||||
{
|
||||
ShownKinds::setVisible(m_text_item,
|
||||
m_properties.type == ConductorProperties::Multi
|
||||
&& m_properties.m_show_text);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::calculateTextItemPosition
|
||||
Move the text at middle of conductor (if is vertical or horizontal)
|
||||
@@ -1548,10 +1563,11 @@ void Conductor::calculateTextItemPosition()
|
||||
|
||||
//At this point this conductor is the longest conductor we hide all text of conductor_list
|
||||
foreach (Conductor *c, relatedPotentialConductors(false)) {
|
||||
c -> textItem() -> setVisible(false);
|
||||
ShownKinds::setVisible(c -> textItem(), false);
|
||||
}
|
||||
//Make sure text item is visible
|
||||
m_text_item -> setVisible(true);
|
||||
//Make sure text item is visible, unless wire numbers are hidden
|
||||
//(View > Show)
|
||||
ShownKinds::setVisible(m_text_item, true);
|
||||
}
|
||||
|
||||
//position
|
||||
@@ -1806,11 +1822,7 @@ void Conductor::setProperties(const ConductorProperties &property)
|
||||
m_text_item->setFont(font);
|
||||
m_text_item->setColor(m_properties.text_color);
|
||||
|
||||
if (m_properties.type != ConductorProperties::Multi)
|
||||
m_text_item->setVisible(false);
|
||||
else
|
||||
m_text_item->setVisible(m_properties.m_show_text);
|
||||
|
||||
updateTextVisibility();
|
||||
calculateTextItemPosition();
|
||||
update();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user