mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-17 15:49:59 +01:00
Merge pull request #387 from plc-user/master
only calculate grid-point-size, when min != max
This commit is contained in:
@@ -186,7 +186,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
p -> drawRect(r);
|
p -> drawRect(r);
|
||||||
|
|
||||||
if (draw_grid_) {
|
if (draw_grid_) {
|
||||||
/* Draw the point of the grid
|
/* Draw the points of the grid
|
||||||
* if background color is black,
|
* if background color is black,
|
||||||
* then grid spots shall be white,
|
* then grid spots shall be white,
|
||||||
* else they shall be black in color.
|
* else they shall be black in color.
|
||||||
@@ -232,19 +232,20 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
int minWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_min"), 1).toInt();
|
int minWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_min"), 1).toInt();
|
||||||
int maxWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_max"), 1).toInt();
|
int maxWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_max"), 1).toInt();
|
||||||
pen.setWidth(minWidthPen);
|
pen.setWidth(minWidthPen);
|
||||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
if (minWidthPen != maxWidthPen) {
|
||||||
qreal stepZoom = (5.0 - 1.0) / maxWidthPen;
|
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||||
for (int n=0; n<maxWidthPen; n++) {
|
qreal stepZoom = (5.0 - 1.0) / maxWidthPen;
|
||||||
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
for (int n=0; n<maxWidthPen; n++) {
|
||||||
int widthPen = minWidthPen + qRound(n * stepPen);
|
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
||||||
pen.setWidth(widthPen);
|
int widthPen = minWidthPen + qRound(n * stepPen);
|
||||||
|
pen.setWidth(widthPen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (zoom_factor <= 1.0)
|
||||||
|
pen.setWidth(minWidthPen);
|
||||||
|
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||||
|
pen.setWidth(maxWidthPen);
|
||||||
}
|
}
|
||||||
if (zoom_factor <= 1.0)
|
|
||||||
pen.setWidth(minWidthPen);
|
|
||||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
|
||||||
pen.setWidth(maxWidthPen);
|
|
||||||
|
|
||||||
p -> setPen(pen);
|
p -> setPen(pen);
|
||||||
if (zoom_factor > 0.5) // no grid below ... !
|
if (zoom_factor > 0.5) // no grid below ... !
|
||||||
p -> drawPoints(points);
|
p -> drawPoints(points);
|
||||||
|
|||||||
@@ -1153,7 +1153,7 @@ void DiagramView::editSelection()
|
|||||||
QGraphicsItem *item = m_diagram->selectedItems().first();
|
QGraphicsItem *item = m_diagram->selectedItems().first();
|
||||||
|
|
||||||
//We use dynamic_cast instead of qgraphicsitem_cast for QetGraphicsItem
|
//We use dynamic_cast instead of qgraphicsitem_cast for QetGraphicsItem
|
||||||
//because they haven't got they own type().
|
//because they haven't got their own type().
|
||||||
//Use qgraphicsitem_cast will have weird behavior for this class.
|
//Use qgraphicsitem_cast will have weird behavior for this class.
|
||||||
if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(item))
|
if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(item))
|
||||||
iti -> edit();
|
iti -> edit();
|
||||||
|
|||||||
@@ -559,19 +559,20 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
int minWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_min"), 1).toInt();
|
int minWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_min"), 1).toInt();
|
||||||
int maxWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_max"), 1).toInt();
|
int maxWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_max"), 1).toInt();
|
||||||
pen.setWidth(minWidthPen);
|
pen.setWidth(minWidthPen);
|
||||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
if (minWidthPen != maxWidthPen) {
|
||||||
qreal stepZoom = (25.0 - 1.0) / maxWidthPen;
|
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||||
for (int n=0; n<maxWidthPen; n++) {
|
qreal stepZoom = (25.0 - 1.0) / maxWidthPen;
|
||||||
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
for (int n=0; n<maxWidthPen; n++) {
|
||||||
int widthPen = minWidthPen + qRound(n * stepPen);
|
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
||||||
pen.setWidth(widthPen);
|
int widthPen = minWidthPen + qRound(n * stepPen);
|
||||||
|
pen.setWidth(widthPen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (zoom_factor <= 1.0)
|
||||||
|
pen.setWidth(minWidthPen);
|
||||||
|
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||||
|
pen.setWidth(maxWidthPen);
|
||||||
}
|
}
|
||||||
if (zoom_factor <= 1.0)
|
|
||||||
pen.setWidth(minWidthPen);
|
|
||||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
|
||||||
pen.setWidth(maxWidthPen);
|
|
||||||
|
|
||||||
p -> setPen(pen);
|
p -> setPen(pen);
|
||||||
p -> setBrush(Qt::NoBrush);
|
p -> setBrush(Qt::NoBrush);
|
||||||
qreal limit_x = r.x() + r.width();
|
qreal limit_x = r.x() + r.width();
|
||||||
|
|||||||
@@ -32,6 +32,10 @@
|
|||||||
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||||
premier est pris en compte. En cas d'incoherence, Qet::North est
|
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||||
retourne.
|
retourne.
|
||||||
|
Used to convert a string of characters (‘n’, ‘s’, ‘e’ or ‘w’)
|
||||||
|
into orientation. If the string is made up of several characters,
|
||||||
|
only the only the first is taken into account. In the event of an
|
||||||
|
inconsistency, Qet::North is returned.
|
||||||
@param s Chaine de caractere cense representer une orientation
|
@param s Chaine de caractere cense representer une orientation
|
||||||
@return l'orientation designee par la chaine de caractere
|
@return l'orientation designee par la chaine de caractere
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +64,7 @@ QString Qet::orientationToString(Qet::Orientation o) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
|
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
|
||||||
|
Indicates whether two terminal orientations are on the same axis (Vertical / Horizontal).
|
||||||
@param a La premiere orientation de Borne
|
@param a La premiere orientation de Borne
|
||||||
@param b La seconde orientation de Borne
|
@param b La seconde orientation de Borne
|
||||||
@return Un booleen a true si les deux orientations de bornes sont sur le meme axe
|
@return Un booleen a true si les deux orientations de bornes sont sur le meme axe
|
||||||
|
|||||||
@@ -1597,7 +1597,7 @@ void QETDiagramEditor::slot_updateUndoStack()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETDiagramEditor::slot_updateComplexActions
|
@brief QETDiagramEditor::slot_updateComplexActions
|
||||||
Manage the actions who need some conditions to be enable or not.
|
Manage the actions that need some conditions to be enabled or not.
|
||||||
This method does nothing if there is no project opened
|
This method does nothing if there is no project opened
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateComplexActions()
|
void QETDiagramEditor::slot_updateComplexActions()
|
||||||
@@ -1633,7 +1633,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
int selected_elements_count = dc.count(DiagramContent::Elements);
|
int selected_elements_count = dc.count(DiagramContent::Elements);
|
||||||
m_find_element->setEnabled(selected_elements_count == 1);
|
m_find_element->setEnabled(selected_elements_count == 1);
|
||||||
|
|
||||||
//Action that need items (elements, conductors, texts...) selected, to be enabled
|
//Actions that need items (elements, conductors, texts...) selected, to be enabled
|
||||||
bool copiable_items = dc.hasCopiableItems();
|
bool copiable_items = dc.hasCopiableItems();
|
||||||
bool deletable_items = dc.hasDeletableItems();
|
bool deletable_items = dc.hasDeletableItems();
|
||||||
m_cut -> setEnabled(!ro && copiable_items);
|
m_cut -> setEnabled(!ro && copiable_items);
|
||||||
|
|||||||
@@ -384,9 +384,11 @@ void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, co
|
|||||||
points << depart0;
|
points << depart0;
|
||||||
|
|
||||||
// prolongement de la borne de depart
|
// prolongement de la borne de depart
|
||||||
|
// extend start terminal
|
||||||
points << depart;
|
points << depart;
|
||||||
|
|
||||||
// commence le vrai trajet
|
// commence le vrai trajet
|
||||||
|
// starts the real path
|
||||||
if (depart.y() < arrivee.y()) {
|
if (depart.y() < arrivee.y()) {
|
||||||
// trajet descendant
|
// trajet descendant
|
||||||
if ((ori_depart == Qet::North && (ori_arrivee == Qet::South || ori_arrivee == Qet::West)) || (ori_depart == Qet::East && ori_arrivee == Qet::West)) {
|
if ((ori_depart == Qet::North && (ori_arrivee == Qet::South || ori_arrivee == Qet::West)) || (ori_depart == Qet::East && ori_arrivee == Qet::West)) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const qreal Terminal::Z = 1000;
|
|||||||
/**
|
/**
|
||||||
@brief Terminal::init
|
@brief Terminal::init
|
||||||
Methode privee pour initialiser la borne.
|
Methode privee pour initialiser la borne.
|
||||||
|
Private method to initialize the terminal.
|
||||||
@param number of terminal
|
@param number of terminal
|
||||||
@param name of terminal
|
@param name of terminal
|
||||||
@param hiddenName
|
@param hiddenName
|
||||||
@@ -92,17 +93,25 @@ Terminal::~Terminal() {
|
|||||||
est bien un Element, cette fonction renvoie l'orientation par rapport a
|
est bien un Element, cette fonction renvoie l'orientation par rapport a
|
||||||
la scene de la borne, en tenant compte du fait que l'element ait pu etre
|
la scene de la borne, en tenant compte du fait que l'element ait pu etre
|
||||||
pivote. Sinon elle renvoie son sens normal.
|
pivote. Sinon elle renvoie son sens normal.
|
||||||
|
Used to find out the orientation of the terminal. If the terminal's parent
|
||||||
|
is in fact an Element, this function returns the orientation of the
|
||||||
|
terminal with respect to the scene, taking into account the angle of
|
||||||
|
rotation. scene, taking into account the fact that the element may have
|
||||||
|
been rotated. Otherwise it returns its normal direction.
|
||||||
@return L'orientation actuelle de la Terminal.
|
@return L'orientation actuelle de la Terminal.
|
||||||
*/
|
*/
|
||||||
Qet::Orientation Terminal::orientation() const
|
Qet::Orientation Terminal::orientation() const
|
||||||
{
|
{
|
||||||
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
|
if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
|
||||||
// orientations actuelle et par defaut de l'element
|
// orientations actuelle et par defaut de l'element
|
||||||
|
// current and default element orientations
|
||||||
int ori_cur = elt -> orientation();
|
int ori_cur = elt -> orientation();
|
||||||
if (ori_cur == 0) return(d->m_orientation);
|
if (ori_cur == 0) return(d->m_orientation);
|
||||||
else {
|
else {
|
||||||
// calcul l'angle de rotation implique par l'orientation de l'element parent
|
// calcul l'angle de rotation implique par l'orientation de l'element parent
|
||||||
// angle de rotation de la borne sur la scene, divise par 90
|
// angle de rotation de la borne sur la scene, divise par 90
|
||||||
|
// calculates the angle of rotation implied by the orientation of the parent
|
||||||
|
// element angle of rotation of the terminal on the scene, divided by 90
|
||||||
int angle = ori_cur + d->m_orientation;
|
int angle = ori_cur + d->m_orientation;
|
||||||
while (angle >= 4) angle -= 4;
|
while (angle >= 4) angle -= 4;
|
||||||
return((Qet::Orientation)angle);
|
return((Qet::Orientation)angle);
|
||||||
|
|||||||
Reference in New Issue
Block a user