| 2201 | } |
| 2202 | |
| 2203 | void TOPPViewBase::loadFiles(const StringList& list, QSplashScreen* splash_screen) |
| 2204 | { |
| 2205 | static StringList colors = { "@bw", "@bg", "@b", "@r", "@g", "@m" }; |
| 2206 | static StringList gradients = { "Linear|0,#ffffff;100,#000000" , "Linear|0,#dddddd;100,#000000" , "Linear|0,#000000;100,#000000", |
| 2207 | "Linear|0,#ff0000;100,#ff0000" , "Linear|0,#00ff00;100,#00ff00" , "Linear|0,#ff00ff;100,#ff00ff" }; |
| 2208 | bool last_was_plus = false; |
| 2209 | bool last_was_annotation = false; |
| 2210 | for (StringList::const_iterator it = list.begin(); it != list.end(); ++it) |
| 2211 | { |
| 2212 | if (*it == "+") |
| 2213 | { |
| 2214 | last_was_plus = true; |
| 2215 | continue; |
| 2216 | } |
| 2217 | if (*it == "!") |
| 2218 | { |
| 2219 | last_was_annotation = true; |
| 2220 | continue; |
| 2221 | } |
| 2222 | |
| 2223 | // no matter what the current item is, after we are done with it, |
| 2224 | // we need to reset the 'glue' symbols |
| 2225 | RAIICleanup reset([&]() { |
| 2226 | last_was_plus = false; |
| 2227 | last_was_annotation = false; |
| 2228 | }); |
| 2229 | |
| 2230 | if (std::find(colors.begin(), colors.end(), *it) != colors.end()) |
| 2231 | { // its a color! |
| 2232 | if ((getActive2DWidget() != nullptr || getActive3DWidget() != nullptr) && getActiveCanvas() != nullptr) |
| 2233 | { |
| 2234 | Param tmp = getActiveCanvas()->getCurrentLayer().param; |
| 2235 | tmp.setValue("dot:gradient", gradients[Helpers::indexOf(colors, *it)]); |
| 2236 | getActiveCanvas()->setCurrentLayerParameters(tmp); |
| 2237 | } |
| 2238 | continue; |
| 2239 | } |
| 2240 | |
| 2241 | splash_screen->showMessage((String("Loading file: ") + *it).toQString()); |
| 2242 | splash_screen->repaint(); |
| 2243 | QApplication::processEvents(); |
| 2244 | |
| 2245 | if (!getActivePlotWidget()) |
| 2246 | { |
| 2247 | if (last_was_annotation) |
| 2248 | { |
| 2249 | log_->appendNewHeader(LogWindow::LogState::WARNING, "Error", "Cannot annotate without having added layers before."); |
| 2250 | continue; |
| 2251 | } |
| 2252 | // create new tab (also in case of last_was_plus)... |
| 2253 | addDataFile(*it, false, true); // add data file but don't show options |
| 2254 | continue; |
| 2255 | } |
| 2256 | |
| 2257 | // we have an active widget |
| 2258 | if (last_was_plus) |
| 2259 | { // add to current tab |
| 2260 | addDataFile(*it, false, true, "", getActivePlotWidget()->getWindowId()); |
nothing calls this directly
no test coverage detected