Skip to content

Commit

Permalink
gui: comments / zero case / format
Browse files Browse the repository at this point in the history
Signed-off-by: arthurkoucher <arthurckoucher@gmail.com>
  • Loading branch information
AcKoucher committed Oct 5, 2023
1 parent 19f99fc commit 9fbe926
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/gui/src/gui.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ proc save_image { args } {
}
sta::check_positive_int "-width" $keys(-width)
set width $keys(-width)
if { $width == 0 } {
utl::error GUI 98 "Specified -width cannot be zero."
}
}

sta::check_argc_eq1 "save_image" $args
Expand Down
20 changes: 10 additions & 10 deletions src/gui/src/layoutViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,8 +1917,6 @@ void LayoutViewer::saveImage(const QString& filepath,

const qreal old_pixels_per_dbu = pixels_per_dbu_;

// TO DO: Add another check for height
// Add minimum dimensions based on the max resolution
if (width_px != 0) {
pixels_per_dbu_ = width_px / static_cast<float>(save_area.dx());
}
Expand All @@ -1940,19 +1938,21 @@ void LayoutViewer::saveImage(const QString& filepath,
// rendering be synchronous. We directly call the draw()
// method ourselves.

const QSize initial_size = QSize(bounding_rect.width(), bounding_rect.height());
const QSize initial_size
= QSize(bounding_rect.width(), bounding_rect.height());
const QSize img_size = Utils::adjustMaxImageSize(initial_size);

if (img_size != initial_size) {
const int max_size = std::max(img_size.width(), img_size.height());

logger_->warn(utl::GUI,
94,
"Can't save image with the specified size (max width/height "
"is {} pixels). Saved image dimensions = {} x {}.",
max_size,
img_size.width(),
img_size.height());
logger_->warn(
utl::GUI,
94,
"Specified resolution results in illegal size (max width/height "
"is {} pixels). Saving image with dimensions = {} x {}.",
max_size,
img_size.width(),
img_size.height());

// Set resolution according to adjusted size
pixels_per_dbu_ = computePixelsPerDBU(img_size, save_area);
Expand Down

0 comments on commit 9fbe926

Please sign in to comment.