mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
* Added the m_rotate_action to qetelementeditor.ui * Adding QAction to qetelementeditor.cpp and connecting it to new slot RotateElementsCommand defined in editorcommands.cpp
* Some types of elements need to specialize the setRotation method in order to behave correctly : - PartTerminal needs to call setOrientation - PartLine, PartRectangle and PartPolygon need a different rotation center.
This commit is contained in:
committed by
Laurent Trinques
parent
9135099dbf
commit
c640d96bca
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
Redéfinit la fonction de rotation pour la traduire en orientation de la borne
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user