mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-14 09:14:14 +02:00
da6eb83035
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>
167 lines
4.8 KiB
C++
167 lines
4.8 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "exportproperties.h"
|
|
#include "qetapp.h"
|
|
|
|
/**
|
|
Constructeur par defaut :
|
|
* le repertoire de destination est l'emplacement des documents de l'utilisateur
|
|
* le format d'export est PNG
|
|
* la grille et les bornes ne doivent pas etre dessinees
|
|
* la bordure et le cartouche doivent etre dessines
|
|
* la zone exportee est le schema avec son cadre et son cartouche
|
|
*/
|
|
ExportProperties::ExportProperties() :
|
|
destination_directory(QETApp::documentDir()),
|
|
format("PNG"),
|
|
draw_grid(false),
|
|
draw_guides(false),
|
|
draw_border(true),
|
|
draw_titleblock(true),
|
|
draw_terminals(false),
|
|
draw_terminal_names(false),
|
|
draw_bg_transparent(false),
|
|
draw_colored_conductors(true),
|
|
dxf_blocks(false),
|
|
dxf_attributes(false),
|
|
svg_small_pictures(false),
|
|
exported_area(QET::BorderArea)
|
|
{
|
|
}
|
|
|
|
/**
|
|
Destructeur
|
|
*/
|
|
ExportProperties::~ExportProperties()
|
|
{
|
|
}
|
|
|
|
/**
|
|
Exporte les options dans une configuration.
|
|
@param settings Parametres a ecrire
|
|
@param prefix prefixe a ajouter devant les noms des parametres
|
|
*/
|
|
void ExportProperties::toSettings(QSettings &settings,
|
|
const QString &prefix) const
|
|
{
|
|
settings.setValue(prefix % "path",
|
|
QDir::toNativeSeparators(
|
|
destination_directory.absolutePath()));
|
|
settings.setValue(prefix % "format",
|
|
format);
|
|
settings.setValue(prefix % "drawgrid",
|
|
draw_grid);
|
|
settings.setValue(prefix % "drawguides",
|
|
draw_guides);
|
|
settings.setValue(prefix % "drawborder",
|
|
draw_border);
|
|
settings.setValue(prefix % "drawtitleblock",
|
|
draw_titleblock);
|
|
settings.setValue(prefix % "drawterminals",
|
|
draw_terminals);
|
|
settings.setValue(prefix % "drawterminalnames",
|
|
draw_terminal_names);
|
|
settings.setValue(prefix % "drawbgtransparent",
|
|
draw_bg_transparent);
|
|
settings.setValue(prefix % "drawcoloredconductors",
|
|
draw_colored_conductors);
|
|
settings.setValue(prefix % "dxfblocks",
|
|
dxf_blocks);
|
|
settings.setValue(prefix % "dxfattributes",
|
|
dxf_attributes);
|
|
settings.setValue(prefix % "svgsmallpictures",
|
|
svg_small_pictures);
|
|
settings.setValue(prefix % "area",
|
|
QET::diagramAreaToString(exported_area));
|
|
}
|
|
|
|
/**
|
|
Lit les options depuis une configuration.
|
|
@param settings Parametres a lire
|
|
@param prefix prefixe a ajouter devant les noms des parametres
|
|
*/
|
|
void ExportProperties::fromSettings(QSettings &settings,
|
|
const QString &prefix) {
|
|
QString export_path = QETApp::documentDir();
|
|
destination_directory.setPath(
|
|
settings.value(
|
|
prefix % "path",
|
|
export_path).toString());
|
|
if (!destination_directory.exists())
|
|
destination_directory.setPath(export_path);
|
|
|
|
format = settings.value(prefix % "format").toString();
|
|
|
|
draw_grid = settings.value(prefix % "drawgrid",
|
|
false).toBool();
|
|
draw_guides = settings.value(prefix % "drawguides",
|
|
false).toBool();
|
|
draw_border = settings.value(prefix % "drawborder",
|
|
true ).toBool();
|
|
draw_titleblock = settings.value(prefix % "drawtitleblock",
|
|
true ).toBool();
|
|
draw_terminals = settings.value(prefix % "drawterminals",
|
|
false).toBool();
|
|
draw_terminal_names = settings.value(prefix % "drawterminalnames",
|
|
false).toBool();
|
|
draw_bg_transparent = settings.value(prefix % "drawbgtransparent",
|
|
false).toBool();
|
|
draw_colored_conductors = settings.value(
|
|
prefix % "drawcoloredconductors",
|
|
true ).toBool();
|
|
dxf_blocks = settings.value(prefix % "dxfblocks",
|
|
false).toBool();
|
|
dxf_attributes = settings.value(prefix % "dxfattributes",
|
|
false).toBool();
|
|
svg_small_pictures = settings.value(prefix % "svgsmallpictures",
|
|
false).toBool();
|
|
|
|
exported_area = QET::diagramAreaFromString(
|
|
settings.value(
|
|
prefix % "area",
|
|
"border").toString());
|
|
}
|
|
|
|
/**
|
|
@brief ExportProperties::defaultProperties
|
|
@return the default properties stored in the setting file
|
|
*/
|
|
ExportProperties ExportProperties::defaultExportProperties()
|
|
{
|
|
QSettings settings;
|
|
|
|
ExportProperties def;
|
|
def.fromSettings(settings, "export/default");
|
|
|
|
return(def);
|
|
}
|
|
|
|
/**
|
|
@brief ExportProperties::defaultPrintProperties
|
|
@return the default properties stored in the setting file
|
|
*/
|
|
ExportProperties ExportProperties::defaultPrintProperties()
|
|
{
|
|
QSettings settings;
|
|
|
|
ExportProperties def;
|
|
def.fromSettings(settings, "print/default");
|
|
|
|
return(def);
|
|
}
|