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

Method loadWorksheet

src/backend/datasources/projects/OriginProjectParser.cpp:1236–1421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236bool OriginProjectParser::loadWorksheet(Worksheet* worksheet, bool preview) {
1237 DEBUG(Q_FUNC_INFO << ", preview = " << preview)
1238 if (worksheet->parentAspect())
1239 DEBUG(Q_FUNC_INFO << ", parent PATH " << STDSTRING(worksheet->parentAspect()->path()))
1240
1241 // load worksheet data
1242 const auto& graph = m_originFile->graph(findWorksheetByName(worksheet->name()));
1243 DEBUG(Q_FUNC_INFO << ", worksheet name = " << graph.name);
1244 worksheet->setComment(QLatin1String(graph.label.c_str()));
1245
1246 // TODO: width, height, view mode (print view, page view, window view, draft view)
1247 // Origin allows to freely resize the window and ajusts the size of the plot (layer) automatically
1248 // by keeping a certain width-to-height ratio. It's not clear what the actual size of the plot/layer is and how to handle this.
1249 // For now we simply create a new worksheet here with it's default size and make it using the whole view size.
1250 // Later we can decide to use one of the following properties:
1251 // 1) Window.frameRect gives Rect-corner coordinates (in pixels) of the Window object
1252 // 2) GraphLayer.clientRect gives Rect-corner coordinates (pixels) of the Layer inside the (printer?) page.
1253 // 3) Graph.width, Graph.height give the (printer?) page size in pixels.
1254 // const QRectF size(0, 0,
1255 // Worksheet::convertToSceneUnits(graph.width/600., Worksheet::Inch),
1256 // Worksheet::convertToSceneUnits(graph.height/600., Worksheet::Inch));
1257 // worksheet->setPageRect(size);
1258 graphSize.rwidth() = graph.width;
1259 graphSize.rheight() = graph.height;
1260 WARN(Q_FUNC_INFO << ", GRAPH width/height (px) = " << graphSize.width() << "/" << graphSize.height())
1261 // Graphic elements in Origin are scaled relative to the dimensions of the page (Format->Page) with 600 DPI (>=9.6), 300 DPI (<9.6)
1262 double dpi = 600.;
1263 if (m_originFile->version() < 9.6)
1264 dpi = 300.;
1265 WARN(Q_FUNC_INFO << ", GRAPH width/height (cm) = " << graphSize.width() * GSL_CONST_CGS_INCH / dpi << "/" << graphSize.height() * GSL_CONST_CGS_INCH / dpi)
1266 // Origin scales text and plots with the size of the layer when no fixed size is used (Layer properties->Size)
1267 // so we scale all text and plots with a scaling factor to the whole view height used as default
1268#if defined(HAVE_WINDOWS)
1269 const double fixedHeight = 14.75; // full height/2 [cm]
1270#else
1271 const double fixedHeight = 29.5; // full height [cm]
1272#endif
1273 elementScalingFactor = fixedHeight / (graph.height * GSL_CONST_CGS_INCH / dpi);
1274 // not using the full value for scaling text is better in most cases
1275 textScalingFactor = 1. + (elementScalingFactor - 1.) / 2.;
1276 WARN(Q_FUNC_INFO << ", ELEMENT SCALING FACTOR = " << elementScalingFactor)
1277 WARN(Q_FUNC_INFO << ", TEXT SCALING FACTOR = " << textScalingFactor)
1278 // default values (1000/1000)
1279 // DEBUG(Q_FUNC_INFO << ", WORKSHEET width/height = " << worksheet->pageRect().width() << "/" << worksheet->pageRect().height())
1280
1281 worksheet->setUseViewSize(true);
1282
1283 QHash<TextLabel*, QSizeF> textLabelPositions;
1284
1285 // worksheet background color
1286 const Origin::ColorGradientDirection bgColorGradient = graph.windowBackgroundColorGradient;
1287 const Origin::Color bgBaseColor = graph.windowBackgroundColorBase;
1288 const Origin::Color bgEndColor = graph.windowBackgroundColorEnd;
1289 worksheet->background()->setColorStyle(backgroundColorStyle(bgColorGradient));
1290 switch (bgColorGradient) {
1291 case Origin::ColorGradientDirection::NoGradient:
1292 case Origin::ColorGradientDirection::TopLeft:
1293 case Origin::ColorGradientDirection::Left:

Callers

nothing calls this directly

Calls 15

parentAspectMethod · 0.80
setCommentMethod · 0.80
heightMethod · 0.80
setUseViewSizeMethod · 0.80
setColorStyleMethod · 0.80
setFirstColorMethod · 0.80
setSecondColorMethod · 0.80
is3DMethod · 0.80
addChildFastMethod · 0.80
setIsLoadingMethod · 0.80
setSymmetricPaddingMethod · 0.80
setHorizontalPaddingMethod · 0.80

Tested by

no test coverage detected