mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-15 01:54:14 +02:00
Add an SVG export option to store pictures smaller
An SVG keeps every picture at full resolution, whatever size it is drawn at: a folio with 22 phone photos shown at a tenth of their size gave a 270 MB SVG and took 65 s to write, most of it compressing the photos again. The export dialog gets "SVG: smaller pictures" (off by default, kept with the other export settings), and --export-svg gets --svg-small-pictures. With it, a picture is stored at four times the size it is drawn at when that is smaller than the picture; smaller pictures stay whole. Four times is about 375 dpi on a printed folio. The exporter sets Diagram::smallPictures() for its own drawing only, so screen, print, PDF and PNG are unchanged. It is not part of applyProperties(), which every format uses. On that project: --export-svg 84.9 s -> 34.5 s (opening is 20 s of both), 270 MB -> 57 MB, peak memory 2.45 -> 1.86 GB. Rendered at twice the folio size, the two SVGs differ by more than 32/255 on 0.23 % of pixels, along photo detail. tst_svgsmallpictures: an 800x600 picture drawn at 0.1 is stored at 320x240 with the option, through --export-svg and through the dialog's QPicture route, and at 800x600 without it; a 40x30 picture stays whole. It fails when the factor is changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,6 +68,7 @@ ExportProperties ExportPropertiesWidget::exportProperties() const
|
||||
export_properties.draw_colored_conductors = draw_colored_conductors -> isChecked();
|
||||
export_properties.dxf_blocks = dxf_blocks -> isChecked();
|
||||
export_properties.dxf_attributes = dxf_attributes -> isChecked();
|
||||
export_properties.svg_small_pictures = svg_small_pictures -> isChecked();
|
||||
export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
|
||||
|
||||
return(export_properties);
|
||||
@@ -94,6 +95,7 @@ void ExportPropertiesWidget::setExportProperties(const ExportProperties &export_
|
||||
dxf_blocks -> setChecked(export_properties.dxf_blocks);
|
||||
dxf_attributes -> setChecked(export_properties.dxf_attributes);
|
||||
dxf_attributes -> setEnabled(export_properties.dxf_blocks);
|
||||
svg_small_pictures -> setChecked(export_properties.svg_small_pictures);
|
||||
|
||||
if (export_properties.exported_area == QET::BorderArea) {
|
||||
export_border -> setChecked(true);
|
||||
@@ -125,6 +127,7 @@ void ExportPropertiesWidget::setPrintingMode(bool mode) {
|
||||
export_border -> setVisible(!mode);
|
||||
export_elements -> setVisible(!mode);
|
||||
draw_bg_transparent -> setVisible(!mode);
|
||||
svg_small_pictures -> setVisible(!mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,6 +238,11 @@ void ExportPropertiesWidget::build()
|
||||
dxf_attributes -> setToolTip(tr("A symbol's texts (label, function...) become attributes of its block. LibreCAD does not show attributes."));
|
||||
optionshlayout -> addWidget(dxf_attributes, 5, 1);
|
||||
connect(dxf_blocks, &QCheckBox::toggled, dxf_attributes, &QCheckBox::setEnabled);
|
||||
|
||||
// pictures not at full resolution in an SVG: a much smaller file
|
||||
svg_small_pictures = new QCheckBox(tr("SVG: smaller pictures"), groupbox_options);
|
||||
svg_small_pictures -> setToolTip(tr("Pictures are stored at four times the size they have on the folio instead of their full resolution: a much smaller file, still sharp when printed"));
|
||||
optionshlayout -> addWidget(svg_small_pictures, 5, 0);
|
||||
|
||||
vboxLayout -> addWidget(groupbox_options);
|
||||
|
||||
@@ -252,6 +260,7 @@ void ExportPropertiesWidget::build()
|
||||
setTabOrder(draw_colored_conductors, draw_bg_transparent);
|
||||
setTabOrder(draw_bg_transparent, dxf_blocks);
|
||||
setTabOrder(dxf_blocks, dxf_attributes);
|
||||
setTabOrder(draw_bg_transparent, svg_small_pictures);
|
||||
|
||||
// connexion du bouton permettant le choix du repertoire
|
||||
connect(button_browse, &QPushButton::released, this, &ExportPropertiesWidget::slot_chooseADirectory);
|
||||
@@ -269,6 +278,7 @@ void ExportPropertiesWidget::build()
|
||||
connect(draw_colored_conductors, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(dxf_blocks, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(dxf_attributes, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(svg_small_pictures, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
#else
|
||||
connect(draw_grid, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(draw_border, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
@@ -279,5 +289,6 @@ void ExportPropertiesWidget::build()
|
||||
connect(draw_colored_conductors, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(dxf_blocks, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(dxf_attributes, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
connect(svg_small_pictures, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user