MCPcopy Create free account
hub / github.com/KDE/labplot / adjustWorksheetSize

Method adjustWorksheetSize

src/frontend/spreadsheet/PlotDataDialog.cpp:800–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798}
799
800void PlotDataDialog::adjustWorksheetSize(Worksheet* worksheet) const {
801 // adjust the sizes
802 const auto layout = worksheet->layout();
803 const auto plots = worksheet->children<CartesianPlot>();
804 const int count = plots.size();
805 const double minSize = 4.0;
806 switch (layout) {
807 case Worksheet::Layout::NoLayout:
808 case Worksheet::Layout::VerticalLayout: {
809 if (layout == Worksheet::Layout::NoLayout)
810 worksheet->setLayout(Worksheet::Layout::VerticalLayout);
811
812 const auto plot = plots.constFirst();
813 double height = Worksheet::convertFromSceneUnits(plot->rect().height(), Worksheet::Unit::Centimeter);
814 if (height < 4.) {
815 double newHeight = worksheet->layoutTopMargin() + worksheet->layoutBottomMargin() + (count - 1) * worksheet->layoutHorizontalSpacing()
816 + count * Worksheet::convertToSceneUnits(minSize, Worksheet::Unit::Centimeter);
817 QRectF newRect = worksheet->pageRect();
818 newRect.setHeight(round(newHeight));
819 worksheet->setPageRect(newRect);
820 }
821 break;
822 }
823 case Worksheet::Layout::HorizontalLayout: {
824 const auto plot = plots.constFirst();
825 double width = Worksheet::convertFromSceneUnits(plot->rect().width(), Worksheet::Unit::Centimeter);
826 if (width < 4.) {
827 double newWidth = worksheet->layoutLeftMargin() + worksheet->layoutRightMargin() + (count - 1) * worksheet->layoutVerticalSpacing()
828 + count * Worksheet::convertToSceneUnits(minSize, Worksheet::Unit::Centimeter);
829 QRectF newRect = worksheet->pageRect();
830 newRect.setWidth(round(newWidth));
831 worksheet->setPageRect(newRect);
832 }
833 break;
834 }
835 case Worksheet::Layout::GridLayout: {
836 const auto plot = plots.constFirst();
837 double width = Worksheet::convertFromSceneUnits(plot->rect().width(), Worksheet::Unit::Centimeter);
838 double height = Worksheet::convertFromSceneUnits(plot->rect().height(), Worksheet::Unit::Centimeter);
839 if (width < 4. || height < 4.) {
840 QRectF newRect = worksheet->pageRect();
841 if (height < 4.) {
842 double newHeight = worksheet->layoutTopMargin() + worksheet->layoutBottomMargin() + (count - 1) * worksheet->layoutHorizontalSpacing()
843 + count * Worksheet::convertToSceneUnits(minSize, Worksheet::Unit::Centimeter);
844 newRect.setHeight(round(newHeight));
845 } else {
846 double newWidth = worksheet->layoutLeftMargin() + worksheet->layoutRightMargin() + (count - 1) * worksheet->layoutVerticalSpacing()
847 + count * Worksheet::convertToSceneUnits(minSize, Worksheet::Unit::Centimeter);
848 newRect.setWidth(round(newWidth));
849 }
850 worksheet->setPageRect(newRect);
851 }
852 break;
853 }
854 }
855}
856
857void PlotDataDialog::setAxesColumnLabels(CartesianPlot* plot, const Column* column) {

Callers

nothing calls this directly

Calls 9

setLayoutMethod · 0.80
heightMethod · 0.80
rectMethod · 0.80
setHeightMethod · 0.80
setPageRectMethod · 0.80
sizeMethod · 0.45
pageRectMethod · 0.45
widthMethod · 0.45
setWidthMethod · 0.45

Tested by

no test coverage detected