Merge branch 'master' into terminal_strip

* master: (55 commits)
  modified:   lang/qet_nl.qm 	modified:   lang/qet_nl.ts
  Update *TS files
  Fix some misprint
  new and upgraded elements
  fix typo
  add terminals to thermo-couples
  upgraded elements and descriptions
  upgraded / added elements and descriptions
  updated descriptions
  more elements and descriptions
  fix typos
  update element-descriptions
  update elements / more element-descriptions
  fix designations / update descriptions
  fix designations / update descriptions
  update element-descriptions
  fix typo
  update element-descriptions
  update / add elements
  update element-descriptions
  ...
This commit is contained in:
joshua
2021-10-20 21:32:45 +02:00
2677 changed files with 45034 additions and 30152 deletions

View File

@@ -518,7 +518,6 @@ void BorderTitleBlock::draw(QPainter *painter)
//Set the QPainter
painter -> save();
QPen pen(Qt::black);
pen.setCosmetic(true);
painter -> setPen(pen);
painter -> setBrush(Qt::NoBrush);

View File

@@ -92,7 +92,7 @@ const QVariant DiagramContext::operator[](const QString &key) const
@return true if the insertion succeeds, false otherwise
*/
bool DiagramContext::addValue(const QString &key, const QVariant &value, bool show) {
if (keyIsAcceptable(key)) {
if (isKeyAcceptable(key)) {
m_content.insert(key, value);
m_content_show.insert(key, show);
return(true);
@@ -240,10 +240,11 @@ bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
@param key a key string
@return true if that key is acceptable, false otherwise
*/
bool DiagramContext::keyIsAcceptable(const QString &key) const
bool DiagramContext::isKeyAcceptable(const QString &key)
{
QRegularExpression re(DiagramContext::validKeyRegExp());
QRegularExpressionMatch match =re.match(key);
static const QRegularExpression re(DiagramContext::validKeyRegExp());
QRegularExpressionMatch match = re.match(key);
return match.hasMatch();
}

View File

@@ -81,13 +81,14 @@ class DiagramContext
void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
void toSettings(QSettings &, const QString &) const;
void fromSettings(QSettings &, const QString &);
static QString validKeyRegExp();
static bool isKeyAcceptable(const QString &);
private:
static bool stringLongerThan(const QString &, const QString &);
bool keyIsAcceptable(const QString &) const;
/// Diagram context data (key/value pairs)
static QString validKeyRegExp();
/// Diagram context data (key/value pairs)
QHash<QString, QVariant> m_content;
QHash<QString, bool> m_content_show;
};

View File

@@ -609,3 +609,67 @@ void changeElementDataCommand::redo() {
m_scene->setElementData(m_new);
QUndoCommand::redo();
}
RotateElementsCommand::RotateElementsCommand(ElementScene *scene, QUndoCommand *parent) :
ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent)
{
m_items = scene->selectedItems();
}
/**
@brief RotateElementsCommand::undo
*/
void RotateElementsCommand::undo()
{
for (QGraphicsItem *item : m_items)
{
if (item->type() == PartTerminal::Type) {
PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item);
term->setRotation(term->rotation()-90);
}
else if (item->type() == PartRectangle::Type) {
PartRectangle* rect = qgraphicsitem_cast<PartRectangle*>(item);
rect->setRotation(rect->rotation()-90);
}
else if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(line->rotation()-90);
}
else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(poly->rotation()-90);
}
else {
item->setRotation(item->rotation()-90);
}
}
}
/**
@brief RotateElementsCommand::redo
*/
void RotateElementsCommand::redo()
{
for (QGraphicsItem *item : m_items)
{
if (item->type() == PartTerminal::Type) {
PartTerminal* term = qgraphicsitem_cast<PartTerminal*>(item);
term->setRotation(term->rotation()+90);
}
else if (item->type() == PartRectangle::Type) {
PartRectangle* rect = qgraphicsitem_cast<PartRectangle*>(item);
rect->setRotation(rect->rotation()+90);
}
else if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(line->rotation()+90);
}
else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(poly->rotation()+90);
}
else {
item->setRotation(item->rotation()+90);
}
}
}

View File

@@ -22,6 +22,19 @@
#include "elementcontent.h"
#include "elementscene.h"
#include "elementview.h"
#include "graphicspart/abstractpartellipse.h"
#include "graphicspart/customelementgraphicpart.h"
#include "graphicspart/customelementpart.h"
#include "graphicspart/partarc.h"
#include "graphicspart/partdynamictextfield.h"
#include "graphicspart/partellipse.h"
#include "graphicspart/partline.h"
#include "graphicspart/partpolygon.h"
#include "graphicspart/partrectangle.h"
#include "graphicspart/partterminal.h"
#include "graphicspart/parttext.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
/**
@brief The ElementEditionCommand class
@@ -279,4 +292,24 @@ class changeElementDataCommand : public ElementEditionCommand
m_new;
};
/**
@brief The RotateSelectionInESCommand class
Rotate the selected items in the element editor
*/
class RotateElementsCommand : public ElementEditionCommand
{
public:
RotateElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr);
void undo() override;
void redo() override;
private:
ElementScene *m_scene =nullptr;
QList<QGraphicsItem*> m_items;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -603,6 +603,19 @@ void PartLine::setSecondEndLength(const qreal &l)
emit secondEndLengthChanged();
}
void PartLine::setRotation(qreal angle) {
QTransform rotation = QTransform().translate(m_line.p1().x(),m_line.p1().y()).rotate(angle-m_rot).translate(-m_line.p1().x(),-m_line.p1().y());
m_rot=angle;
setLine(rotation.map(m_line));
}
qreal PartLine::rotation() const {
return m_rot;
}
/**
@brief PartLine::path
@return this line has a QPainterPath.

View File

@@ -94,6 +94,8 @@ class PartLine : public CustomElementGraphicPart
void setFirstEndLength(const qreal &l);
qreal secondEndLength() const {return second_length;}
void setSecondEndLength(const qreal &l);
void setRotation(qreal angle);
qreal rotation() const;
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
@@ -124,5 +126,6 @@ class PartLine : public CustomElementGraphicPart
int m_vector_index = -1;
QPropertyUndoCommand *m_undo_command;
QVector<QetGraphicsHandlerItem *> m_handler_vector;
qreal m_rot;
};
#endif

View File

@@ -293,6 +293,21 @@ void PartPolygon::resetAllHandlerColor()
}
}
void PartPolygon::setRotation(qreal angle) {
QTransform rotation = QTransform().translate(m_polygon.first().x(),m_polygon.first().y()).rotate(angle-m_rot).translate(-m_polygon.first().x(),-m_polygon.first().y());
m_rot=angle;
setPolygon(rotation.map(m_polygon));
}
qreal PartPolygon::rotation() const {
return m_rot;
}
/**
@brief PartPolygon::itemChange
@param change

View File

@@ -87,6 +87,9 @@ class PartPolygon : public CustomElementGraphicPart
void setHandlerColor(QPointF pos, const QColor &color) final;
void resetAllHandlerColor() final;
void setRotation (qreal angle);
qreal rotation () const;
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
@@ -114,5 +117,6 @@ class PartPolygon : public CustomElementGraphicPart
QAction *m_insert_point,
*m_remove_point;
QPointF m_context_menu_pos;
qreal m_rot;
};
#endif

View File

@@ -30,7 +30,9 @@
*/
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
CustomElementGraphicPart(editor, parent)
{}
{
m_rot=0;
}
/**
@brief PartRectangle::~PartRectangle
@@ -169,6 +171,18 @@ void PartRectangle::setYRadius(qreal Y)
emit YRadiusChanged();
}
void PartRectangle::setRotation(qreal angle) {
QTransform rotation = QTransform().rotate(angle-m_rot);
m_rot=angle;
setRect(rotation.mapRect(m_rect));
}
qreal PartRectangle::rotation() const {
return m_rot;
}
/**
@brief PartRectangle::sceneGeometricRect
@return the minimum, margin-less rectangle this part can fit into, in scene
@@ -187,7 +201,7 @@ QRectF PartRectangle::sceneGeometricRect() const
*/
QPointF PartRectangle::sceneTopLeft() const
{
return(mapToScene(rect().topLeft()));
return(mapToScene(rect().topLeft()));
}
/**

View File

@@ -34,6 +34,7 @@ class PartRectangle : public CustomElementGraphicPart
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
Q_PROPERTY(qreal xRadius READ XRadius WRITE setXRadius NOTIFY XRadiusChanged)
Q_PROPERTY(qreal yRadius READ YRadius WRITE setYRadius NOTIFY YRadiusChanged)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
// constructors, destructor
public:
@@ -47,6 +48,7 @@ class PartRectangle : public CustomElementGraphicPart
void rectChanged();
void XRadiusChanged();
void YRadiusChanged();
void rotationChanged();
// methods
public:
@@ -69,6 +71,8 @@ class PartRectangle : public CustomElementGraphicPart
void setXRadius(qreal X);
qreal YRadius() const {return m_yRadius;}
void setYRadius(qreal Y);
void setRotation(qreal angle);
qreal rotation() const;
QRectF sceneGeometricRect() const override;
virtual QPointF sceneTopLeft() const;
@@ -109,5 +113,6 @@ class PartRectangle : public CustomElementGraphicPart
m_old_xRadius,
m_old_yRadius;
bool m_modifie_radius_equaly = false;
qreal m_rot;
};
#endif

View File

@@ -140,6 +140,7 @@ QRectF PartTerminal::boundingRect() const
return(br);
}
/**
Definit l'orientation de la borne
@param ori la nouvelle orientation de la borne
@@ -151,6 +152,32 @@ void PartTerminal::setOrientation(Qet::Orientation ori) {
updateSecondPoint();
emit orientationChanged();
}
/**
Redefines setRotation to call setOrientation
@param angle
*/
void PartTerminal::setRotation(qreal angle) {
qreal angle_mod = std::fmod(angle,360);
Qet::Orientation new_ori = Qet::North;
if (0 <= angle_mod && angle_mod < 90 ) new_ori = Qet::North;
else if (90 <= angle_mod && angle_mod < 180) new_ori = Qet::East;
else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South;
else new_ori = Qet::West;
setOrientation(new_ori);
}
qreal PartTerminal::rotation() const {
switch (d->m_orientation) {
case Qet::North : return 0;
case Qet::East : return 90;
case Qet::South : return 180;
case Qet::West : return 270;
}
}
/**
@brief PartTerminal::setName
@param name

View File

@@ -72,7 +72,11 @@ class PartTerminal : public CustomElementGraphicPart
void handleUserTransformation(const QRectF &, const QRectF &) override;
Qet::Orientation orientation() const {return d -> m_orientation;}
void setOrientation(Qet::Orientation ori);
void setOrientation(Qet::Orientation ori);
qreal rotation() const;
void setRotation(qreal angle);
QString name() const override { return d -> m_name; }
void setName(QString& name);

View File

@@ -109,6 +109,7 @@ void QETElementEditor::contextMenu(QPoint p, QList<QAction *> actions)
menu.addAction(ui->m_delete_action);
menu.addAction(ui->m_cut_action);
menu.addAction(ui->m_copy_action);
menu.addAction((ui->m_rotate_action));
menu.addSeparator();
menu.addAction(ui->m_paste_action);
menu.addAction(ui->m_paste_in_area_action);
@@ -1018,7 +1019,10 @@ void QETElementEditor::setupActions()
depth_toolbar -> addActions(m_depth_action_group -> actions());
addToolBar(Qt::TopToolBarArea, depth_toolbar);
//Zoom action
//Rotate action
connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));});
//Zoom action
ui->m_zoom_in_action -> setShortcut(QKeySequence::ZoomIn);
ui->m_zoom_out_action -> setShortcut(QKeySequence::ZoomOut);
ui->m_zoom_fit_best_action -> setShortcut(QKeySequence(tr("Ctrl+9")));

View File

@@ -25,7 +25,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="m_file_menu">
@@ -75,6 +75,7 @@
<addaction name="m_edit_names_action"/>
<addaction name="m_edit_author_action"/>
<addaction name="m_edit_element_properties_action"/>
<addaction name="m_rotate_action"/>
</widget>
<widget class="QMenu" name="m_display_menu">
<property name="title">
@@ -488,6 +489,18 @@
<string>Affiche des informations sur la bibliothèque Qt</string>
</property>
</action>
<action name="m_rotate_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/orientations.png</normaloff>:/ico/16x16/orientations.png</iconset>
</property>
<property name="text">
<string>Rotation</string>
</property>
<property name="shortcut">
<string>Space</string>
</property>
</action>
</widget>
<resources>
<include location="../../../qelectrotech.qrc"/>

File diff suppressed because it is too large Load Diff

View File

@@ -179,7 +179,6 @@ void MachineInfo::init_get_Screen_info()
*/
void MachineInfo::init_get_cpu_info()
{
#ifdef __GNUC__
#ifdef __APPLE_CC__
init_get_cpu_info_macos();
#else
@@ -188,7 +187,6 @@ void MachineInfo::init_get_cpu_info()
if (pc.os.type == "winnt")
init_get_cpu_info_winnt();
#endif
#endif
}
/**

View File

@@ -82,12 +82,14 @@ class MachineInfo
struct Built
{
QString version=
#ifdef __GNUC__
#ifdef __APPLE_CC__
#ifdef __GNUC__
#ifdef __APPLE_CC__
"CLANG " + QString(__clang_version__);
#else
#else
"GCC " + QString(__VERSION__);
#endif
#elif defined(Q_CC_MSVC)
"MSVC " + QString(QT_STRINGIFY(_MSC_FULL_VER));
#endif
QString QT=QString(QT_VERSION_STR);
QString date=QString(__DATE__);

View File

@@ -1515,7 +1515,6 @@ void TitleBlockTemplate::render(QPainter &painter,
painter.save();
//Setup the QPainter
QPen pen(Qt::black);
pen.setCosmetic(true);
painter.setPen(pen);
// draw the titleblock border
@@ -1661,7 +1660,7 @@ void TitleBlockTemplate::renderCell(QPainter &painter,
const QRect &cell_rect) const
{
// draw the border rect of the current cell
QPen pen(QBrush(), 0.0, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
QPen pen(QBrush(), 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
pen.setColor(Qt::black);
painter.setPen(pen);
painter.drawRect(cell_rect);

View File

@@ -120,8 +120,6 @@ void DiagramContextWidget::clear()
*/
int DiagramContextWidget::highlightNonAcceptableKeys()
{
static QRegularExpression re(DiagramContext::validKeyRegExp());
QBrush fg_brush = ui->m_table->palette().brush(QPalette::WindowText);
int invalid_keys = 0;
@@ -135,7 +133,7 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
bool highlight = false;
if (!qtwi_name -> text().isEmpty())
{
if (re!=QRegularExpression(qtwi_name -> text()))
if (! DiagramContext::isKeyAcceptable(qtwi_name->text()))
{
highlight = true;
++ invalid_keys;