Ajout de la possibilite de modifier la hauteur du schema

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@53 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavierqet
2007-02-03 02:00:18 +00:00
parent 039949c0ee
commit 1e486712cc
6 changed files with 68 additions and 13 deletions

View File

@@ -34,7 +34,7 @@ void BorderInset::updateRectangles() {
border = QRectF(0, 0, nb_columns * columns_width, columns_height); border = QRectF(0, 0, nb_columns * columns_width, columns_height);
// rectangles relatifs au cartouche // rectangles relatifs au cartouche
inset = QRectF(border.bottomRight().x() - inset_width, border.bottomRight().y() - inset_height, inset_width, inset_height); inset = QRectF(border.bottomLeft().x(), border.bottomLeft().y(), inset_width, inset_height);
inset_author = QRectF(inset.topLeft(), QSizeF(2.0 * inset_width / 9.0, 0.5 * inset_height)); inset_author = QRectF(inset.topLeft(), QSizeF(2.0 * inset_width / 9.0, 0.5 * inset_height));
inset_date = QRectF(inset_author.bottomLeft(), inset_author.size()); inset_date = QRectF(inset_author.bottomLeft(), inset_author.size());
inset_title = QRectF(inset_author.topRight(), QSizeF(5.0 * inset_width / 9.0, inset_height)); inset_title = QRectF(inset_author.topRight(), QSizeF(5.0 * inset_width / 9.0, inset_height));
@@ -118,6 +118,7 @@ void BorderInset::draw(QPainter *qp, qreal x, qreal y) {
*/ */
void BorderInset::addColumn() { void BorderInset::addColumn() {
++ nb_columns; ++ nb_columns;
setInsetWidth(nb_columns * columns_width);
updateRectangles(); updateRectangles();
} }
@@ -127,6 +128,7 @@ void BorderInset::addColumn() {
void BorderInset::removeColumn() { void BorderInset::removeColumn() {
if (nb_columns == 3) return; if (nb_columns == 3) return;
-- nb_columns; -- nb_columns;
setInsetWidth(nb_columns * columns_width);
updateRectangles(); updateRectangles();
} }
@@ -150,10 +152,10 @@ void BorderInset::setColumnsHeaderHeight(const qreal &new_chh) {
/** /**
Change la hauteur des colonnes (et donc du cadre). Cette hauteur doit Change la hauteur des colonnes (et donc du cadre). Cette hauteur doit
rester superieure a 10px. rester superieure a la hauteur des en-tetes de colonnes + 20px.
*/ */
void BorderInset::setColumnsHeight(const qreal &new_ch) { void BorderInset::setColumnsHeight(const qreal &new_ch) {
columns_height = qMax(10.0, new_ch); columns_height = qMax(columns_header_height + 20.0, new_ch);
updateRectangles(); updateRectangles();
} }

View File

@@ -16,14 +16,14 @@
void draw(QPainter *, qreal = 0.0, qreal = 0.0); void draw(QPainter *, qreal = 0.0, qreal = 0.0);
// methodes d'acces en lecture aux dimensions // methodes d'acces en lecture aux dimensions
int nbColumn() const { return(nb_columns); } int nbColumn() const { return(nb_columns); }
qreal columnsWidth() const { return(columns_width); } qreal columnsWidth() const { return(columns_width); }
qreal columnsHeaderHeight() const { return(columns_header_height); } qreal columnsHeaderHeight() const { return(columns_header_height); }
qreal columnsHeight() const { return(columns_height); } qreal columnsHeight() const { return(columns_height); }
qreal borderWidth() const { return(nb_columns * columns_width); } qreal borderWidth() const { return(nb_columns * columns_width); }
qreal borderHeight() const { return(columns_height); } qreal borderHeight() const { return(columns_height + inset_height); }
qreal insetWidth() const { return(inset_width); } qreal insetWidth() const { return(inset_width); }
qreal insetHeight() const { return(inset_height); } qreal insetHeight() const { return(inset_height); }
// methodes d'acces en lecture aux informations du cartouche // methodes d'acces en lecture aux informations du cartouche
QString author() const { return(bi_author); } QString author() const { return(bi_author); }

View File

@@ -526,3 +526,24 @@ void DiagramView::removeColumn() {
// rafraichit la vue // rafraichit la vue
scene -> update(sceneRect()); scene -> update(sceneRect());
} }
void DiagramView::expand() {
// ajoute 10 pixels
scene -> border_and_inset.setColumnsHeight(scene -> border_and_inset.columnsHeight() + 20.0);
// met a jour la zone affichee par la vue
QRectF sr = sceneRect();
sr.setHeight(20.0 + sr.height());
setSceneRect(sr);
// rafraichit la vue
scene -> update(sceneRect());
}
void DiagramView::shrink() {
// enleve 10 pixels
scene -> border_and_inset.setColumnsHeight(scene -> border_and_inset.columnsHeight() - 20.0);
// rafraichit la vue
scene -> update(sceneRect());
}

View File

@@ -31,6 +31,8 @@
void dialogPrint(); void dialogPrint();
void addColumn(); void addColumn();
void removeColumn(); void removeColumn();
void expand();
void shrink();
Diagram *diagram() { return(scene); } Diagram *diagram() { return(scene); }
bool hasSelectedItems(); bool hasSelectedItems();

View File

@@ -225,9 +225,11 @@ void QETApp::actions() {
sel_inverse = new QAction( tr("Inverser la s\351lection"), this); sel_inverse = new QAction( tr("Inverser la s\351lection"), this);
supprimer = new QAction(QIcon(":/ico/delete.png"), tr("Supprimer"), this); supprimer = new QAction(QIcon(":/ico/delete.png"), tr("Supprimer"), this);
pivoter = new QAction(QIcon(":/ico/pivoter.png"), tr("Pivoter"), this); pivoter = new QAction(QIcon(":/ico/pivoter.png"), tr("Pivoter"), this);
infos_diagram = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this); infos_diagram = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this);
add_column = new QAction( tr("Ajouter une colonne"), this); add_column = new QAction( tr("Ajouter une colonne"), this);
remove_column = new QAction( tr("Enlever une colonne"), this); remove_column = new QAction( tr("Enlever une colonne"), this);
expand_diagram = new QAction( tr("Agrandir le sch\351ma"), this);
shrink_diagram = new QAction( tr("R\351tr\351cir le sch\351ma"), this);
toggle_aa = new QAction( tr("D\351sactiver l'&antialiasing"), this); toggle_aa = new QAction( tr("D\351sactiver l'&antialiasing"), this);
zoom_avant = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this); zoom_avant = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this);
@@ -308,9 +310,11 @@ void QETApp::actions() {
sel_inverse -> setStatusTip(tr("D\351s\351lectionne les \351l\351ments s\351lectionn\351s et s\351lectionne les \351l\351ments non s\351lectionn\351s")); sel_inverse -> setStatusTip(tr("D\351s\351lectionne les \351l\351ments s\351lectionn\351s et s\351lectionne les \351l\351ments non s\351lectionn\351s"));
supprimer -> setStatusTip(tr("Enl\350ve les \351l\351ments s\351lectionn\351s du sch\351ma")); supprimer -> setStatusTip(tr("Enl\350ve les \351l\351ments s\351lectionn\351s du sch\351ma"));
pivoter -> setStatusTip(tr("Pivote les \351l\351ments s\351lectionn\351s")); pivoter -> setStatusTip(tr("Pivote les \351l\351ments s\351lectionn\351s"));
infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche")); infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche"));
add_column -> setStatusTip(tr("Ajoute une colonne au sch\351ma")); add_column -> setStatusTip(tr("Ajoute une colonne au sch\351ma"));
remove_column -> setStatusTip(tr("Enl\350ve une colonne au sch\351ma")); remove_column -> setStatusTip(tr("Enl\350ve une colonne au sch\351ma"));
expand_diagram -> setStatusTip(tr("Agrandit le sch\351ma en hauteur"));
shrink_diagram -> setStatusTip(tr("R\351tr\351cit le sch\351ma en hauteur"));
toggle_aa -> setStatusTip(tr("Active / d\351sactive l'antialiasing pour le rendu du sch\351ma courant")); toggle_aa -> setStatusTip(tr("Active / d\351sactive l'antialiasing pour le rendu du sch\351ma courant"));
zoom_avant -> setStatusTip(tr("Agrandit le sch\351ma")); zoom_avant -> setStatusTip(tr("Agrandit le sch\351ma"));
@@ -382,6 +386,8 @@ void QETApp::actions() {
connect(infos_diagram, SIGNAL(activated()), this, SLOT(slot_editInfos()) ); connect(infos_diagram, SIGNAL(activated()), this, SLOT(slot_editInfos()) );
connect(add_column, SIGNAL(activated()), this, SLOT(slot_addColumn()) ); connect(add_column, SIGNAL(activated()), this, SLOT(slot_addColumn()) );
connect(remove_column, SIGNAL(activated()), this, SLOT(slot_removeColumn()) ); connect(remove_column, SIGNAL(activated()), this, SLOT(slot_removeColumn()) );
connect(expand_diagram, SIGNAL(activated()), this, SLOT(slot_expand()) );
connect(shrink_diagram, SIGNAL(activated()), this, SLOT(slot_shrink()) );
} }
/** /**
@@ -436,6 +442,8 @@ void QETApp::menus() {
menu_edition -> addAction(infos_diagram); menu_edition -> addAction(infos_diagram);
menu_edition -> addAction(add_column); menu_edition -> addAction(add_column);
menu_edition -> addAction(remove_column); menu_edition -> addAction(remove_column);
menu_edition -> addAction(expand_diagram);
menu_edition -> addAction(shrink_diagram);
// menu Affichage > Afficher // menu Affichage > Afficher
QMenu *menu_aff_aff = new QMenu(tr("Afficher")); QMenu *menu_aff_aff = new QMenu(tr("Afficher"));
@@ -947,3 +955,21 @@ void QETApp::slot_removeColumn() {
if (!sv) return; if (!sv) return;
sv -> removeColumn(); sv -> removeColumn();
} }
/**
Allonge le schema en cours en hauteur
*/
void QETApp::slot_expand() {
DiagramView *sv = diagramEnCours();
if (!sv) return;
sv -> expand();
}
/**
Retrecit le schema en cours en hauteur
*/
void QETApp::slot_shrink() {
DiagramView *sv = diagramEnCours();
if (!sv) return;
sv -> shrink();
}

View File

@@ -57,6 +57,8 @@
void slot_updateMenuFenetres(); void slot_updateMenuFenetres();
void slot_addColumn(); void slot_addColumn();
void slot_removeColumn(); void slot_removeColumn();
void slot_expand();
void slot_shrink();
protected: protected:
// Actions faisables au travers de menus dans l'application QElectroTech // Actions faisables au travers de menus dans l'application QElectroTech
@@ -85,6 +87,8 @@
QAction *infos_diagram; QAction *infos_diagram;
QAction *add_column; QAction *add_column;
QAction *remove_column; QAction *remove_column;
QAction *expand_diagram;
QAction *shrink_diagram;
QAction *poser_fil; QAction *poser_fil;
QAction *reduce_appli; QAction *reduce_appli;
QAction *restore_appli; QAction *restore_appli;