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

Method exportToLaTeX

src/frontend/matrix/MatrixView.cpp:1198–1546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1196}
1197
1198void MatrixView::exportToLaTeX(const QString& path,
1199 const bool verticalHeaders,
1200 const bool horizontalHeaders,
1201 const bool latexHeaders,
1202 const bool gridLines,
1203 const bool entire,
1204 const bool captions) const {
1205 QFile file(path);
1206 if (!file.open(QFile::WriteOnly | QFile::Truncate))
1207 return;
1208
1209 QVector<QVector<QString>> toExport;
1210
1211 int firstSelectedCol = 0;
1212 int firstSelectedRowi = 0;
1213 int totalRowCount = 0;
1214 int cols = 0;
1215 if (entire) {
1216 cols = m_matrix->columnCount();
1217 totalRowCount = m_matrix->rowCount();
1218 toExport.reserve(totalRowCount);
1219 toExport.resize(totalRowCount);
1220 for (int row = 0; row < totalRowCount; ++row) {
1221 toExport[row].reserve(cols);
1222 toExport[row].resize(cols);
1223 // TODO: mode
1224 for (int col = 0; col < cols; ++col)
1225 toExport[row][col] = m_matrix->text<double>(row, col);
1226 }
1227 firstSelectedCol = 0;
1228 firstSelectedRowi = 0;
1229 } else {
1230 cols = selectedColumnCount();
1231 totalRowCount = selectedRowCount();
1232
1233 firstSelectedCol = firstSelectedColumn();
1234 if (firstSelectedCol == -1)
1235 return;
1236 firstSelectedRowi = firstSelectedRow();
1237 if (firstSelectedRowi == -1)
1238 return;
1239 const int lastSelectedCol = lastSelectedColumn();
1240 const int lastSelectedRowi = lastSelectedRow();
1241
1242 toExport.reserve(lastSelectedRowi - firstSelectedRowi + 1);
1243 toExport.resize(lastSelectedRowi - firstSelectedRowi + 1);
1244 int r = 0;
1245 for (int row = firstSelectedRowi; row <= lastSelectedRowi; ++row, ++r) {
1246 toExport[r].reserve(lastSelectedCol - firstSelectedCol + 1);
1247 toExport[r].resize(lastSelectedCol - firstSelectedCol + 1);
1248 int c = 0;
1249 // TODO: mode
1250 for (int col = firstSelectedCol; col <= lastSelectedCol; ++col, ++c)
1251 toExport[r][c] = m_matrix->text<double>(row, col);
1252 }
1253 }
1254
1255 int columnsStringSize = 0;

Callers 1

exportViewMethod · 0.45

Calls 15

safeExecutableNameFunction · 0.85
startHostProcessFunction · 0.85
text<double>Method · 0.80
lengthMethod · 0.80
splitMethod · 0.80
QStringClass · 0.50
openMethod · 0.45
columnCountMethod · 0.45
rowCountMethod · 0.45
reserveMethod · 0.45
resizeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected