mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Rapatriement de la branche 0.2 dans le trunk
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@558 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,7 +16,9 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "diagramprintdialog.h"
|
||||
#include "qetprintpreviewdialog.h"
|
||||
#include <math.h>
|
||||
#include "diagramschooser.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -24,52 +26,52 @@
|
||||
@param printer Imprimante a utiliser
|
||||
@param parent Widget parent du dialogue
|
||||
*/
|
||||
DiagramPrintDialog::DiagramPrintDialog(Diagram *dia, QWidget *parent) :
|
||||
DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
diagram(dia),
|
||||
dialog(0)
|
||||
project_(project),
|
||||
dialog_(0)
|
||||
{
|
||||
// initialise l'imprimante
|
||||
printer = new QPrinter();
|
||||
printer_ = new QPrinter();
|
||||
|
||||
// orientation paysage par defaut
|
||||
printer -> setOrientation(QPrinter::Landscape);
|
||||
printer_ -> setOrientation(QPrinter::Landscape);
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
DiagramPrintDialog::~DiagramPrintDialog() {
|
||||
delete dialog;
|
||||
delete printer;
|
||||
delete dialog_;
|
||||
delete printer_;
|
||||
}
|
||||
|
||||
/**
|
||||
Definit le nom du PDF si l'utilisateur choisit une sortie vers un PDF
|
||||
*/
|
||||
void DiagramPrintDialog::setPDFName(const QString &name) {
|
||||
pdf_name = name;
|
||||
void DiagramPrintDialog::setFileName(const QString &name) {
|
||||
file_name_ = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@return le nom du PDF
|
||||
*/
|
||||
QString DiagramPrintDialog::PDFName() const {
|
||||
return(pdf_name);
|
||||
QString DiagramPrintDialog::fileName() const {
|
||||
return(file_name_);
|
||||
}
|
||||
|
||||
/**
|
||||
Definit le nom du document
|
||||
*/
|
||||
void DiagramPrintDialog::setDocName(const QString &name) {
|
||||
doc_name = name;
|
||||
doc_name_ = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@return le nom du document
|
||||
*/
|
||||
QString DiagramPrintDialog::docName() const {
|
||||
return(doc_name);
|
||||
return(doc_name_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,31 +79,38 @@ QString DiagramPrintDialog::docName() const {
|
||||
*/
|
||||
void DiagramPrintDialog::exec() {
|
||||
|
||||
#ifndef Q_OS_WIN32
|
||||
if (!pdf_name.isEmpty()) printer -> setOutputFileName(pdf_name);
|
||||
if (!doc_name.isEmpty()) printer -> setDocName(doc_name);
|
||||
#endif
|
||||
// prise en compte du nom du document
|
||||
if (!doc_name_.isEmpty()) printer_ -> setDocName(doc_name_);
|
||||
|
||||
// affichage du dialogue d'impression standard
|
||||
QPrintDialog print_dialog(printer, parentWidget());
|
||||
print_dialog.setWindowTitle(tr("Options d'impression"));
|
||||
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintShowPageSize);
|
||||
// affichage d'un premier dialogue demandant a l'utilisateur le type
|
||||
// d'impression qu'il souhaite effectuer
|
||||
buildPrintTypeDialog();
|
||||
if (dialog_ -> exec() == QDialog::Rejected) return;
|
||||
|
||||
if (print_dialog.exec() == QDialog::Rejected) return;
|
||||
// parametrage de l'imprimante en fonction du type d'impression choisi
|
||||
if (printer_choice_ -> isChecked()) {
|
||||
// affichage du dialogue d'impression standard pour parametrer l'imprimante
|
||||
QPrintDialog print_dialog(printer_, parentWidget());
|
||||
print_dialog.setWindowTitle(tr("Options d'impression", "window title"));
|
||||
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintShowPageSize);
|
||||
if (print_dialog.exec() == QDialog::Rejected) return;
|
||||
} else if (pdf_choice_ -> isChecked()) {
|
||||
printer_ -> setOutputFormat(QPrinter::PdfFormat);
|
||||
printer_ -> setOutputFileName(filepath_field_ -> text());
|
||||
} else {
|
||||
printer_ -> setOutputFormat(QPrinter::PostScriptFormat);
|
||||
printer_ -> setOutputFileName(filepath_field_ -> text());
|
||||
}
|
||||
|
||||
/*
|
||||
Apres l'execution de ce premier dialogue, on connait le format papier a
|
||||
utiliser, son orientation et on est sur que tout cela est supporte par
|
||||
l'imprimante.
|
||||
On peut donc en deduire le nombre de pages a imprimer
|
||||
*/
|
||||
|
||||
// affichage d'un second dialogue, non standard, pour connaitre les pages a imprimer
|
||||
buildDialog();
|
||||
if (dialog -> exec() == QDialog::Rejected) return;
|
||||
// Apercu avant impression
|
||||
QETPrintPreviewDialog preview_dialog(project_, printer_, parentWidget());
|
||||
connect(&preview_dialog, SIGNAL(paintRequested(const QList<Diagram *> &, bool, QPrinter *)), this, SLOT(print(const QList<Diagram *> &, bool, QPrinter *)));
|
||||
DiagramsChooser *dc = preview_dialog.diagramsChooser();
|
||||
dc -> setSelectedAllDiagrams();
|
||||
if (preview_dialog.exec() == QDialog::Rejected) return;
|
||||
|
||||
// effectue l'impression en elle-meme
|
||||
print();
|
||||
print(dc -> selectedDiagrams(), preview_dialog.fitDiagramsToPages(), printer_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,8 +118,8 @@ void DiagramPrintDialog::exec() {
|
||||
@return Le nombre de pages necessaires pour imprimer le schema
|
||||
avec l'orientation et le format papier utilise dans l'imprimante en cours.
|
||||
*/
|
||||
int DiagramPrintDialog::pagesCount(bool fullpage) const {
|
||||
return(horizontalPagesCount(fullpage) * verticalPagesCount(fullpage));
|
||||
int DiagramPrintDialog::pagesCount(Diagram *diagram, bool fullpage) const {
|
||||
return(horizontalPagesCount(diagram, fullpage) * verticalPagesCount(diagram, fullpage));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,9 +127,9 @@ int DiagramPrintDialog::pagesCount(bool fullpage) const {
|
||||
@return La largeur du "poster" en nombre de pages pour imprimer le schema
|
||||
avec l'orientation et le format papier utilise dans l'imprimante en cours.
|
||||
*/
|
||||
int DiagramPrintDialog::horizontalPagesCount(bool fullpage) const {
|
||||
int DiagramPrintDialog::horizontalPagesCount(Diagram *diagram, bool fullpage) const {
|
||||
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||
QRect printable_area = fullpage ? printer -> paperRect() : printer -> pageRect();
|
||||
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
||||
QRect diagram_rect = diagram -> border().toRect();
|
||||
|
||||
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
||||
@@ -132,9 +141,9 @@ int DiagramPrintDialog::horizontalPagesCount(bool fullpage) const {
|
||||
@return La largeur du "poster" en nombre de pages pour imprimer le schema
|
||||
avec l'orientation et le format papier utilise dans l'imprimante en cours.
|
||||
*/
|
||||
int DiagramPrintDialog::verticalPagesCount(bool fullpage) const {
|
||||
int DiagramPrintDialog::verticalPagesCount(Diagram *diagram, bool fullpage) const {
|
||||
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||
QRect printable_area = fullpage ? printer -> paperRect() : printer -> pageRect();
|
||||
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
||||
QRect diagram_rect = diagram -> border().toRect();
|
||||
|
||||
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
||||
@@ -142,128 +151,184 @@ int DiagramPrintDialog::verticalPagesCount(bool fullpage) const {
|
||||
}
|
||||
|
||||
/**
|
||||
Construit un dialogue non standard pour demander les pages a imprimer a l'utilisateur
|
||||
Construit un dialogue non standard pour demander a l'utilisateur quelle type
|
||||
d'impression il souhaite effectuer : PDF, PS ou imprimante physique
|
||||
*/
|
||||
void DiagramPrintDialog::buildDialog() {
|
||||
dialog = new QDialog(parentWidget());
|
||||
dialog -> setMinimumWidth(460);
|
||||
dialog -> setWindowTitle(tr("Options d'impression"));
|
||||
options_label = new QLabel();
|
||||
use_full_page = new QCheckBox(tr("Utiliser toute la feuille"));
|
||||
use_full_page_label_ = new QLabel(tr(
|
||||
"Si cette option est coch\351e, les marges de la feuille seront "
|
||||
"ignor\351es et toute sa surface sera utilis\351e pour l'impression. "
|
||||
"Cela peut ne pas \352tre support\351 par votre imprimante."
|
||||
));
|
||||
use_full_page_label_ -> setWordWrap(true);
|
||||
use_full_page_label_ -> setContentsMargins(20, 0, 0, 0);
|
||||
fit_diagram_to_page = new QCheckBox(tr("Adapter le sch\351ma \340 la page"));
|
||||
fit_diagram_to_page_label_ = new QLabel(tr(
|
||||
"Si cette option est coch\351e, le sch\351ma sera agrandi ou "
|
||||
"r\351tr\351ci de fa\347on \340 remplir toute la surface imprimable "
|
||||
"d'une et une seule page."
|
||||
));
|
||||
fit_diagram_to_page_label_ -> setWordWrap(true);
|
||||
fit_diagram_to_page_label_ -> setContentsMargins(20, 0, 0, 0);
|
||||
fit_diagram_to_page -> setChecked(true);
|
||||
range_from_label = new QLabel(tr("Pages \340 imprimer : plage de "));
|
||||
start_page = new QSpinBox();
|
||||
to_label = new QLabel(tr(" \340 "));
|
||||
end_page = new QSpinBox();
|
||||
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
void DiagramPrintDialog::buildPrintTypeDialog() {
|
||||
// initialisation des widgets
|
||||
dialog_ = new QDialog(parentWidget());
|
||||
printtype_label_ = new QLabel(tr("Quel type d'impression d\351sirez-vous effectuer ?"));
|
||||
printer_icon_ = new QLabel();
|
||||
pdf_icon_ = new QLabel();
|
||||
ps_icon_ = new QLabel();
|
||||
printtype_choice_ = new QButtonGroup();
|
||||
printer_choice_ = new QRadioButton("Impression sur une imprimante physique");
|
||||
pdf_choice_ = new QRadioButton("Impression vers un fichier au format PDF");
|
||||
ps_choice_ = new QRadioButton("Impression vers un fichier au format PostScript (PS)");
|
||||
filepath_field_ = new QLineEdit();
|
||||
browse_button_ = new QPushButton("...");
|
||||
buttons_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
QHBoxLayout *pages_layout = new QHBoxLayout();
|
||||
pages_layout -> addWidget(range_from_label);
|
||||
pages_layout -> addWidget(start_page);
|
||||
pages_layout -> addWidget(to_label);
|
||||
pages_layout -> addWidget(end_page);
|
||||
pages_layout -> addStretch();
|
||||
dialog_ -> setWindowTitle(tr("Choix du type d'impression"));
|
||||
printer_icon_ -> setPixmap(QPixmap(":/ico/printtype_printer.png"));
|
||||
pdf_icon_ -> setPixmap(QPixmap(":/ico/printtype_pdf.png"));
|
||||
ps_icon_ -> setPixmap(QPixmap(":/ico/printtype_ps.png"));
|
||||
printtype_choice_ -> addButton(printer_choice_);
|
||||
printtype_choice_ -> addButton(pdf_choice_);
|
||||
printtype_choice_ -> addButton(ps_choice_);
|
||||
printer_choice_ -> setChecked(true);
|
||||
if (!file_name_.isEmpty()) filepath_field_ -> setText(file_name_ + ".pdf");
|
||||
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(dialog);
|
||||
dialog_layout -> addWidget(options_label);
|
||||
dialog_layout -> addWidget(use_full_page);
|
||||
dialog_layout -> addWidget(use_full_page_label_);
|
||||
dialog_layout -> addWidget(fit_diagram_to_page);
|
||||
dialog_layout -> addWidget(fit_diagram_to_page_label_);
|
||||
dialog_layout -> addLayout(pages_layout);
|
||||
dialog_layout -> addStretch();
|
||||
dialog_layout -> addWidget(buttons);
|
||||
// connexions signaux / slots
|
||||
connect(printer_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||
connect(pdf_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||
connect(ps_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||
connect(browse_button_, SIGNAL(clicked(bool)), this, SLOT(browseFilePrintTypeDialog()));
|
||||
connect(buttons_, SIGNAL(accepted()), this, SLOT(acceptPrintTypeDialog()));
|
||||
connect(buttons_, SIGNAL(rejected()), dialog_, SLOT(reject()));
|
||||
|
||||
connect(use_full_page, SIGNAL(stateChanged(int)), this, SLOT(updateDialog()));
|
||||
connect(fit_diagram_to_page, SIGNAL(stateChanged(int)), this, SLOT(updateDialog()));
|
||||
connect(start_page, SIGNAL(valueChanged(int)), this, SLOT(checkStartPage()));
|
||||
connect(end_page, SIGNAL(valueChanged(int)), this, SLOT(checkEndPage()));
|
||||
connect(buttons, SIGNAL(accepted()), dialog, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), dialog, SLOT(reject()));
|
||||
// organisation graphique
|
||||
glayout0_ = new QGridLayout();
|
||||
hlayout0_ = new QHBoxLayout();
|
||||
vlayout0_ = new QVBoxLayout();
|
||||
|
||||
updateDialog();
|
||||
hlayout0_ -> addWidget(filepath_field_);
|
||||
hlayout0_ -> addWidget(browse_button_);
|
||||
glayout0_ -> addWidget(printer_icon_, 0, 0);
|
||||
glayout0_ -> addWidget(printer_choice_, 0, 1);
|
||||
glayout0_ -> addWidget(pdf_icon_, 1, 0);
|
||||
glayout0_ -> addWidget(pdf_choice_, 1, 1);
|
||||
glayout0_ -> addWidget(ps_icon_, 2, 0);
|
||||
glayout0_ -> addWidget(ps_choice_, 2, 1);
|
||||
glayout0_ -> addLayout(hlayout0_, 3, 1);
|
||||
|
||||
vlayout0_ -> addWidget(printtype_label_);
|
||||
vlayout0_ -> addLayout(glayout0_);
|
||||
vlayout0_ -> addWidget(buttons_);
|
||||
|
||||
dialog_ -> setLayout(vlayout0_);
|
||||
|
||||
updatePrintTypeDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
Assure la coherence du dialogue
|
||||
Assure la coherence du dialogue permettant le choix du type d'impression
|
||||
*/
|
||||
void DiagramPrintDialog::updateDialog() {
|
||||
int pages_count;
|
||||
// si on adapte le schema a la page, alors il n'y a qu'une page a imprimer
|
||||
if (fit_diagram_to_page -> isChecked()) {
|
||||
pages_count = 1;
|
||||
void DiagramPrintDialog::updatePrintTypeDialog() {
|
||||
// imprime-t-on vers un fichier ?
|
||||
bool file_print = !(printer_choice_ -> isChecked());
|
||||
|
||||
// on n'active le champ fichier que pour les impressions vers un fichier
|
||||
filepath_field_ -> setEnabled(file_print);
|
||||
browse_button_ -> setEnabled(file_print);
|
||||
|
||||
// on corrige eventuellement l'extension du fichier deja selectionne
|
||||
if (file_print) {
|
||||
QString filepath = filepath_field_ -> text();
|
||||
if (!filepath.isEmpty()) {
|
||||
if (pdf_choice_ -> isChecked() && filepath.endsWith(".ps")) {
|
||||
QRegExp re("\\.ps$", Qt::CaseInsensitive);
|
||||
filepath.replace(re, ".pdf");
|
||||
filepath_field_ -> setText(filepath);
|
||||
} else if (ps_choice_ -> isChecked() && filepath.endsWith(".pdf")) {
|
||||
QRegExp re("\\.pdf$", Qt::CaseInsensitive);
|
||||
filepath.replace(re, ".ps");
|
||||
filepath_field_ -> setText(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Verifie l'etat du dialogue permettant le choix du type d'impression lorsque
|
||||
l'utilisateur le valide.
|
||||
*/
|
||||
void DiagramPrintDialog::acceptPrintTypeDialog() {
|
||||
bool file_print = !(printer_choice_ -> isChecked());
|
||||
if (file_print) {
|
||||
// un fichier doit avoir ete entre
|
||||
if (filepath_field_ -> text().isEmpty()) {
|
||||
QMessageBox::information(
|
||||
parentWidget(),
|
||||
tr("Fichier manquant", "message box title"),
|
||||
tr("Vous devez indiquer le chemin du fichier PDF/PS \340 cr\351er.", "message box content")
|
||||
);
|
||||
} else dialog_ -> accept();
|
||||
} else {
|
||||
pages_count = pagesCount(use_full_page -> isChecked());
|
||||
}
|
||||
options_label -> setText(tr("Nombre total de pages : ") + QString("%1").arg(pages_count));
|
||||
setPagesRangeVisible(pages_count > 1);
|
||||
start_page -> setRange(1, pages_count);
|
||||
end_page -> setRange(1, pages_count);
|
||||
end_page -> setValue(pages_count);
|
||||
}
|
||||
|
||||
/**
|
||||
S'assure que la premiere page ne soit pas superieure a la derniere page
|
||||
*/
|
||||
void DiagramPrintDialog::checkStartPage() {
|
||||
if (start_page -> value() > end_page -> value()) {
|
||||
start_page -> blockSignals(true);
|
||||
start_page -> setValue(end_page -> value());
|
||||
start_page -> blockSignals(false);
|
||||
// une imprimante doit avoir ete selectionnee
|
||||
/// @todo
|
||||
dialog_ -> accept();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
S'assure que la derniere page ne soit pas inferieure a la premiere page
|
||||
Permet a l'utilisateur de choisir un fichier
|
||||
*/
|
||||
void DiagramPrintDialog::checkEndPage() {
|
||||
if (end_page -> value() < start_page -> value()) {
|
||||
end_page -> blockSignals(true);
|
||||
end_page -> setValue(start_page -> value());
|
||||
end_page -> blockSignals(false);
|
||||
void DiagramPrintDialog::browseFilePrintTypeDialog() {
|
||||
QString extension;
|
||||
QString filter;
|
||||
if (printer_choice_ -> isChecked()) return;
|
||||
else if (pdf_choice_ -> isChecked()) {
|
||||
extension = ".pdf";
|
||||
filter = tr("Fichiers PDF (*.pdf)", "file filter");
|
||||
}
|
||||
else if (ps_choice_ -> isChecked()) {
|
||||
extension = ".ps";
|
||||
filter = tr("Fichiers PostScript (*.ps)", "file filter");
|
||||
}
|
||||
|
||||
QString filepath = QFileDialog::getSaveFileName(
|
||||
parentWidget(),
|
||||
QString(),
|
||||
filepath_field_ -> text(),
|
||||
filter
|
||||
);
|
||||
|
||||
if (!filepath.isEmpty()) {
|
||||
if (!filepath.endsWith(extension)) filepath += extension;
|
||||
filepath_field_ -> setText(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@param visible true pour afficher les pages, false sinon
|
||||
*/
|
||||
void DiagramPrintDialog::setPagesRangeVisible(bool visible) {
|
||||
range_from_label -> setVisible(visible);
|
||||
start_page -> setVisible(visible);
|
||||
to_label -> setVisible(visible);
|
||||
end_page -> setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'impression elle-meme
|
||||
@param diagrams Schemas a imprimer
|
||||
@param fit_page Booleen indiquant s'il faut adapter les schemas aux pages
|
||||
ou non
|
||||
@param printer L'imprimante a utiliser
|
||||
*/
|
||||
void DiagramPrintDialog::print() {
|
||||
// recupere les informations collectees dans le second dialogue
|
||||
bool full_page = use_full_page -> isChecked();
|
||||
bool fit_page = fit_diagram_to_page -> isChecked();
|
||||
int first_page = start_page -> value();
|
||||
int last_page = end_page -> value();
|
||||
|
||||
// parametre l'imprimante
|
||||
printer -> setFullPage(full_page);
|
||||
void DiagramPrintDialog::print(const QList<Diagram *> &diagrams, bool fit_page, QPrinter */*printer*/) {
|
||||
//qDebug() << "Demande d'impression de " << diagrams.count() << "schemas.";
|
||||
|
||||
// QPainter utiliser pour effectuer le rendu
|
||||
QPainter qp(printer);
|
||||
QPainter qp(printer_);
|
||||
|
||||
// cas special : il n'y a aucun schema a imprimer
|
||||
if (!diagrams.count()) {
|
||||
qp.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// imprime les schemas
|
||||
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
||||
printDiagram(diagrams[i], fit_page, &qp, printer_);
|
||||
if (i != diagrams.count() - 1) {
|
||||
printer_ -> newPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Imprime un schema
|
||||
@param diagram Schema a imprimer
|
||||
@param fit_page True pour adapter les schemas aux pages, false sinon
|
||||
@param qp QPainter a utiliser (deja initialise sur printer)
|
||||
@param printer Imprimante a utiliser
|
||||
*/
|
||||
void DiagramPrintDialog::printDiagram(Diagram *diagram, bool fit_page, QPainter *qp, QPrinter *printer) {
|
||||
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
|
||||
// l'imprimante utilise-t-elle toute la feuille ?
|
||||
bool full_page = printer -> fullPage ();
|
||||
|
||||
// impression physique (!= fichier PDF)
|
||||
if (printer -> outputFileName().isEmpty()) {
|
||||
@@ -275,15 +340,19 @@ void DiagramPrintDialog::print() {
|
||||
|
||||
if (fit_page) {
|
||||
// impression adaptee sur une seule page
|
||||
diagram -> render(&qp, QRectF(), diagram -> border(), Qt::KeepAspectRatio);
|
||||
diagram -> render(qp, QRectF(), diagram -> border(), Qt::KeepAspectRatio);
|
||||
} else {
|
||||
// impression sur une ou plusieurs pages
|
||||
QRect diagram_rect = diagram -> border().toRect();
|
||||
QRect diagram_rect = diagram -> border().adjusted(0.0, 0.0, 1.0, 1.0).toAlignedRect();
|
||||
QRect printed_area = full_page ? printer -> paperRect() : printer -> pageRect();
|
||||
//qDebug() << "impression sur une ou plusieurs pages";
|
||||
//qDebug() << " schema :" << diagram_rect;
|
||||
//qDebug() << " page :" << printed_area;
|
||||
|
||||
int used_width = printed_area.width();
|
||||
int used_height = printed_area.height();
|
||||
int h_pages_count = horizontalPagesCount(full_page);
|
||||
int v_pages_count = verticalPagesCount(full_page);
|
||||
int h_pages_count = horizontalPagesCount(diagram, full_page);
|
||||
int v_pages_count = verticalPagesCount(diagram, full_page);
|
||||
|
||||
QVector< QVector< QRect > > pages_grid;
|
||||
// le schema est imprime sur une matrice de feuilles
|
||||
@@ -312,18 +381,20 @@ void DiagramPrintDialog::print() {
|
||||
QVector<QRect> pages_to_print;
|
||||
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
||||
int page_number = (i * h_pages_count) + j + 1;
|
||||
if (page_number >= first_page && page_number <= last_page) {
|
||||
//int page_number = (i * h_pages_count) + j + 1;
|
||||
//if (page_number >= first_page && page_number <= last_page) {
|
||||
pages_to_print << pages_grid.at(i).at(j);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
//qDebug() << " " << pages_to_print.count() << " pages a imprimer :";
|
||||
|
||||
// parcourt les pages pour impression
|
||||
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
|
||||
QRect current_rect(pages_to_print.at(i));
|
||||
//qDebug() << " " << current_rect;
|
||||
diagram -> render(
|
||||
&qp,
|
||||
qp,
|
||||
QRect(QPoint(0,0), current_rect.size()),
|
||||
current_rect.translated(diagram_rect.topLeft()),
|
||||
Qt::KeepAspectRatio
|
||||
|
||||
Reference in New Issue
Block a user