Esempio n. 1
0
void MainWindow::minimizeSubWindows(SubWindow::Type type) {
    QList<QMdiSubWindow *> subList = _mdiArea->subWindowList();
    for (int i = 0; i < subList.size(); ++i) {
        SubWindow *subWindow = dynamic_cast<SubWindow*>(subList[i]);
        if (subWindow && subWindow->type() == type) subWindow->showMinimized();
    }
}
Esempio n. 2
0
QList<SubWindow*> MainWindow::subWindowList(SubWindow::Type type) {
    QList<QMdiSubWindow *> candidates = _mdiArea->subWindowList();
    QList<SubWindow*> result;
    for (int i = 0; i < candidates.size(); ++i) {
        SubWindow *win = dynamic_cast<SubWindow*>(candidates[i]);
        if (win && win->type() == type)
            result << win;
    }
    return result;
}
Esempio n. 3
0
void MainWindow::doWindowsSaveGraphics() {
    QString path = FileLocations::location(FileLocationInfo::Output).absolutePath();
    QList<QMdiSubWindow *> windows = _mdiArea->subWindowList();

    int fileNo = 0;
    try {
        for (int i = 0; i < windows.size(); ++i) {
            SubWindow *subWindow = dynamic_cast<SubWindow*>(windows[i]);
            if (!subWindow)
                continue;
            if (subWindow->type() == SubWindow::SimulationOutput) {
                QPixmap pixmap = windows[i]->widget()->grab();
                if (pixmap.isNull())
                    throw Exception("Could not grab graphics for saving");
                QString filePath = QString("%1/%2-graphics-%3.png").arg(path).arg(++fileNo).arg(rinse(windows[i]->windowTitle()));
                bool ok = pixmap.save(filePath);
                if (!ok)
                    throw Exception("Could not save graphics file to:\n" + filePath);
            }
            else if (subWindow->type() == SubWindow::ModelView) {
                QString sourceFilePath = liveSim->graphFilePath();
                QString destFilePath = QString("%1/%2-model diagram.png").arg(path).arg(++fileNo);
                QFile::remove(destFilePath);
                bool ok = QFile::copy(sourceFilePath, destFilePath);
                if (!ok)
                    throw Exception("Could not write file with model diagram to:\n" + destFilePath);
            }
        }
    }
    catch (UniSim::Exception &ex) {
        showErrorMessage(ex);
    }

    if (fileNo == 0)
        showErrorMessage("No graphics found on screen for saving");
    else
        showErrorMessage(QString("%1 file(s) written to folder %2").arg(fileNo).arg(path));

}