Esempio n. 1
15
void MainWindow::saveAllSheetsToImages(const QString &fileName)
{
    int indexOfExtension = fileName.indexOf(QRegularExpression("\\.\\w+$"), 0);
    QString currentFileName;
    currentSheetNumber = -1;
    ui->toolBar->actions()[ToolButton::Next]->setEnabled(true);
    ui->svgView->hideBorders(true);

    while (ui->toolBar->actions()[ToolButton::Next]->isEnabled()) //while "Next Sheet" tool button is enabled,
    {                                                             //i.e. while rendering all sheets
        renderNextSheet();
        currentFileName = fileName;

        if (currentSheetNumber > 0 || ui->toolBar->actions()[ToolButton::Next]->isEnabled())
            //i.e. there is more than one sheet
            currentFileName.insert(indexOfExtension, QString("_%1").arg(currentSheetNumber));

        saveSheet(currentFileName);
    }

    ui->svgView->hideBorders(false);

    //we used renderNextSheet() for the first sheet instead of renderFirstSheet()
    //so we need to check the number of sheet and disable previous toolbutton if needed
    if (currentSheetNumber == 0)
        ui->toolBar->actions()[ToolButton::Previous]->setDisabled(true);
}
Esempio n. 2
0
void MainWindow::saveAllSheetsToImages(QString &fileName, int indexOfExtension)
{
    QString currentFileName;
    currentSheetNumber = -1;
    ui->toolBar->actions()[4]->setEnabled(true); //enable "Next Sheet" tool button

    while (ui->toolBar->actions()[4]->isEnabled()) //while "Next Sheet" tool button is enabled,
    {                                              //i.e. render all sheets
        renderNextSheet();
        currentFileName = fileName;
        currentFileName.insert(indexOfExtension, QString("_%1").arg(currentSheetNumber));
        saveSheet(currentFileName);
    }
    ui->svgView->hideBorders(false);

    if (currentSheetNumber == 0)
        ui->toolBar->actions()[5]->setDisabled(true); //disable "Previous Sheet" tool button
}
Esempio n. 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    preferencesDialog = new PreferencesDialog();
    fontDialog = new FontDialog();
    errorMessage = new QErrorMessage();
    sheetNumberLabel = new QLabel("<h2>1</h2>");
    sheetNumberLabel->setToolTip(tr("Number of Current Sheet"));
    sheetNumberLabel->setFrameShape(QFrame::Panel);
    sheetNumberLabel->setFrameShadow(QFrame::Sunken);
    sheetNumberLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    sheetNumberLabel->setMinimumWidth(ui->toolBar->height());
    errorMessage->setMinimumSize(200, 150);

    //----File----
    connect(ui->actionConvert_to_Handwritten, SIGNAL(triggered()),
            this, SLOT(renderFirstSheet()));
    connect(ui->actionLoad_Text_from_File, SIGNAL(triggered()),
            this, SLOT(loadTextFromFile()));
    connect(ui->actionLoad_Font, SIGNAL(triggered()),
            this, SLOT(loadFont()));
    connect(ui->actionFont_Editor, SIGNAL(triggered()),
            fontDialog, SLOT(exec()));
    connect(ui->actionSave_Current_Sheet_as, SIGNAL(triggered()),
            this, SLOT(saveSheet()));
    connect(ui->actionSave_All_Sheets, SIGNAL(triggered()),
            this, SLOT(saveAllSheets()));
    connect(ui->actionPrint_Current_Sheet, SIGNAL(triggered()),
            this, SLOT(printSheet()));
    connect(ui->actionPrint_All, SIGNAL(triggered()),
            this, SLOT(printAllSheets()));

    //----Edit----
    //connect menu action "Show Toolbar"
    connect(ui->actionShow_ToolBar, SIGNAL(triggered(bool)),
            ui->toolBar, SLOT(setVisible(bool)));
    connect(ui->toolBar, SIGNAL(visibilityChanged(bool)),
            ui->actionShow_ToolBar, SLOT(setChecked(bool)));

    //preferencesDialog connections
    connect(ui->actionPreferences, SIGNAL(triggered()),
            preferencesDialog, SLOT(exec()));
    connect(preferencesDialog, SIGNAL(settingsChanged()),
            this, SLOT(loadSettings()));

    //----Help----
    connect(ui->actionAbout_Scribbler, SIGNAL(triggered()),
            this, SLOT(showAboutBox()));
    connect(ui->actionLicenses_and_Credits, SIGNAL(triggered()),
            this, SLOT(showLicensesBox()));
    connect(ui->actionHowTo, SIGNAL(triggered()),
            this, SLOT(showHowToBox()));

    //----ToolBar----
    //add actions to tool bar and connect them to slots
    connect(ui->toolBar->addAction(QPixmap("://render.png"), tr("Convert to Handwritten")), SIGNAL(triggered(bool)),
            this, SLOT(renderFirstSheet()));
    connect(ui->toolBar->addAction(QPixmap("://printer.png"), tr("Print Sheets")), SIGNAL(triggered(bool)),
            this, SLOT(printAllSheets()));
    connect(ui->toolBar->addAction(QPixmap("://save.png"), tr("Save Sheets")), SIGNAL(triggered(bool)),
            this, SLOT(saveAllSheets()));

    ui->toolBar->addSeparator();

    connect(ui->toolBar->addAction(QPixmap("://left.png"), tr("Previous Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(renderPreviousSheet()));
    ui->toolBar->addWidget(sheetNumberLabel);
    connect(ui->toolBar->addAction(QPixmap("://right.png"), tr("Next Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(renderNextSheet()));

    connect(fontDialog, SIGNAL(fontReady()),
            this, SLOT(updateCurrentSheet()));
    errorMessage->setModal(true);

    ui->toolBar->actions()[ToolButton::Render]->setShortcut(Qt::ControlModifier + Qt::Key_R);
    ui->toolBar->actions()[ToolButton::Print]->setShortcut(Qt::ControlModifier + Qt::Key_P);
    ui->toolBar->actions()[ToolButton::Save]->setShortcut(Qt::ControlModifier + Qt::Key_S);
    ui->toolBar->actions()[ToolButton::Next]->setShortcut(Qt::ControlModifier + Qt::Key_Right);
    ui->toolBar->actions()[ToolButton::Previous]->setShortcut(Qt::ControlModifier + Qt::Key_Left);
    ui->textEdit->installEventFilter(this);
    ui->toolBar->actions()[ToolButton::Next]->setDisabled(true);
    ui->toolBar->actions()[ToolButton::Previous]->setDisabled(true);

    //initialize some class members
    sheetPointers.push_back(0);
    currentSheetNumber = 0;

    preferencesDialog->loadSettingsFromFile();
    preferencesDialog->loadSettingsToFile();
}
Esempio n. 4
0
void Window::createActions()
{
    newSceneAct = new QAction(tr("&New"), this);
    newSceneAct->setStatusTip(tr("Create an empty scene"));
    connect(newSceneAct, SIGNAL(triggered()), glWidget, SLOT(cleanSheet()));
	
	showBrushControlAct = new QAction(tr("&Brush Control"), this);
	showBrushControlAct->setStatusTip(tr("Show brush settings"));
    connect(showBrushControlAct, SIGNAL(triggered()), m_brushControl, SLOT(show()));
	
	showFeatherEditAct = new QAction(tr("&Feather Editor"), this);
	showFeatherEditAct->setStatusTip(tr("Show feather editor"));
    connect(showFeatherEditAct, SIGNAL(triggered()), m_featherEdit, SLOT(show()));
	
	showTimeControlAct = new QAction(tr("&Time Control"), this);
	showTimeControlAct->setStatusTip(tr("Show time control"));
    connect(showTimeControlAct, SIGNAL(triggered()), m_timeControl, SLOT(show()));
	
    showBarbEditAct = new QAction(tr("&Barb Preview"), this);
    showBarbEditAct->setStatusTip(tr("Show barb preview"));
    connect(showBarbEditAct, SIGNAL(triggered()), m_barbEdit, SLOT(show()));
	
	showRenderEditAct = new QAction(tr("&Render View"), this);
    showRenderEditAct->setStatusTip(tr("Show render view"));
    connect(showRenderEditAct, SIGNAL(triggered()), m_renderEdit, SLOT(show()));
	
	showSceneEditAct = new QAction(tr("&Scene Tree"), this);
    showSceneEditAct->setStatusTip(tr("Show scene edit"));
    connect(showSceneEditAct, SIGNAL(triggered()), m_sceneEdit, SLOT(show()));
    
	saveSceneAct = new QAction(tr("&Save"), this);
	saveSceneAct->setStatusTip(tr("Save current scene file"));
    connect(saveSceneAct, SIGNAL(triggered()), glWidget, SLOT(saveSheet()));
	
	saveSceneAsAct = new QAction(tr("&Save As"), this);
	saveSceneAsAct->setStatusTip(tr("Save current scene into another file"));
	connect(saveSceneAsAct, SIGNAL(triggered()), glWidget, SLOT(saveSheetAs()));
	
	importMeshAct = new QAction(tr("&Import Body Mesh"), this);
	importMeshAct->setStatusTip(tr("Load a mesh cache file as the body"));
	connect(importMeshAct, SIGNAL(triggered()), glWidget, SLOT(importBodyMesh()));
	
	importFDMAct = new QAction(tr("&Import Feather Distribution Map"), this);
	importFDMAct->setStatusTip(tr("Load an OpenEXR image as feather distribution"));
	connect(importFDMAct, SIGNAL(triggered()), glWidget, SLOT(importFeatherDistributionMap()));
	
	openSceneAct = new QAction(tr("&Open"), this);
	openSceneAct->setStatusTip(tr("Load a file as current scene"));
	connect(openSceneAct, SIGNAL(triggered()), this, SLOT(openFile()));
	
	revertAct = new QAction(tr("&Revert To Saved"), this);
	revertAct->setStatusTip(tr("Discard changes to current scene after lastest save"));
    connect(revertAct, SIGNAL(triggered()), glWidget, SLOT(revertSheet()));
	
	importBakeAct = new QAction(tr("&Import Body Animation"), this);
	importBakeAct->setStatusTip(tr("Attach bake point cache to the body"));
    connect(importBakeAct, SIGNAL(triggered()), glWidget, SLOT(chooseBake()));
	
	for (int i = 0; i < MaxRecentFiles; ++i) {
        recentFileActs[i] = new QAction(this);
        recentFileActs[i]->setVisible(false);
        connect(recentFileActs[i], SIGNAL(triggered()),
                this, SLOT(openRecentFile()));
    }
    
    exportBakeAct = new QAction(tr("&Export Baked Feather"), this);
	exportBakeAct->setStatusTip(tr("Write feather cache"));
    connect(exportBakeAct, SIGNAL(triggered()), glWidget, SLOT(exportBake()));
    
    exportStatAct = new QAction(tr("&Export Feather Model"), this);
	exportStatAct->setStatusTip(tr("Write feather model"));
    connect(exportStatAct, SIGNAL(triggered()), glWidget, SLOT(exportModel()));
	
	growOnAct = new QAction(tr("Eable Grow On Faces"), this);
	growOnAct->setStatusTip(tr("Tag selected faces to grow feathers"));
	connect(growOnAct, SIGNAL(triggered()), this, SLOT(tagFaceOn()));
	
	growOffAct = new QAction(tr("Disable Grow On Faces"), this);
	growOffAct->setStatusTip(tr("Tag selected faces NOT to grow feathers"));
    connect(growOffAct, SIGNAL(triggered()), this, SLOT(tagFaceOff()));
	
	selectGrowonAct = new QAction(tr("&Grow On/Off"), this);
	selectGrowonAct->setStatusTip(tr("Choose to activate grow on map"));
	connect(selectGrowonAct, SIGNAL(triggered()), this, SLOT(selectMap0()));
	
	selectDistributeAct = new QAction(tr("&Grow Distribution"), this);
	selectDistributeAct->setStatusTip(tr("Choose to activate distribution map"));
	connect(selectDistributeAct, SIGNAL(triggered()), this, SLOT(selectMap1()));
	
	selectDensityAct = new QAction(tr("&Grow Density"), this);
	selectDensityAct->setStatusTip(tr("Choose to activate density map"));
	connect(selectDensityAct, SIGNAL(triggered()), this, SLOT(selectMap2()));
}
Esempio n. 5
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    preferencesDialog = new PreferencesDialog();
    fontDialog = new FontDialog();

    //----File----
    connect(ui->actionConvert_to_Handwritten, SIGNAL(triggered()),
            this, SLOT(renderFirstSheet()));
    connect(ui->actionLoad_Text_from_File, SIGNAL(triggered()),
            this, SLOT(loadTextFromFile()));
    connect(ui->actionLoad_Font, SIGNAL(triggered()),
            this, SLOT(loadFont()));
    connect(ui->actionFont_Editor, SIGNAL(triggered()),
            fontDialog, SLOT(exec()));
    connect(ui->actionSave_Current_Sheet_as, SIGNAL(triggered()),
            this, SLOT(saveSheet()));
    connect(ui->actionSave_All_Sheets, SIGNAL(triggered()),
            this, SLOT(saveAllSheets()));
    connect(ui->actionPrint_Current_Sheet, SIGNAL(triggered()),
            this, SLOT(printSheet()));
    connect(ui->actionPrint_All, SIGNAL(triggered()),
            this, SLOT(printAllSheets()));

    //----Edit----
    //connect menu action "Show Toolbar"
    connect(ui->actionShow_ToolBar, SIGNAL(triggered(bool)),
            ui->toolBar, SLOT(setVisible(bool)));
    connect(ui->toolBar, SIGNAL(visibilityChanged(bool)),
            ui->actionShow_ToolBar, SLOT(setChecked(bool)));

    //preferencesDialog connections
    connect(ui->actionPreferences, SIGNAL(triggered()),
            preferencesDialog, SLOT(exec()));
    connect(preferencesDialog, SIGNAL(settingsChanged()),
            ui->svgView, SLOT(loadSettingsFromFile()));

    //----Help----
    connect(ui->actionAbout_Scribbler, SIGNAL(triggered()),
            this, SLOT(showAboutBox()));
    connect(ui->actionLicenses_and_Credits, SIGNAL(triggered()),
            this, SLOT(showLicensesBox()));

    //----ToolBar----
    //add actions to tool bar and connect them to slots
    connect(ui->toolBar->addAction(QPixmap("://render.png"), tr("Convert to Handwritten")), SIGNAL(triggered(bool)),
            this, SLOT(renderFirstSheet()));
    connect(ui->toolBar->addAction(QPixmap("://printer.png"), tr("Print Current Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(printSheet()));
    connect(ui->toolBar->addAction(QPixmap("://save.png"), tr("Save Current Sheet as Image")), SIGNAL(triggered(bool)),
            this, SLOT(saveSheet()));

    ui->toolBar->addSeparator();

    connect(ui->toolBar->addAction(QPixmap("://right.png"), tr("Next Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(renderNextSheet()));
    connect(ui->toolBar->addAction(QPixmap("://left.png"), tr("Previous Sheet")), SIGNAL(triggered(bool)),
            this, SLOT(renderPreviousSheet()));

    connect(fontDialog, SIGNAL(fontReady()),
            ui->svgView, SLOT(loadFont()));

    ui->toolBar->actions()[4]->setDisabled(true);
    ui->toolBar->actions()[5]->setDisabled(true);

    //initialize some class members
    sheetPointers.push_back(0);
    currentSheetNumber = 0;
    version = "0.4 alpha";

    preferencesDialog->loadSettingsFromFile();

    /* This is a hack to avoid a bug. When program starts, it needs some time
     * (at least 1 ms on my configuration, but I set delay to 100 ms just to be sure
     * that it will work on weaker machines) before it can write settings to file,
     * otherwise ui->colorButton->palette().background().color() will return
     * default buttons background color, which will be written to settings
     * file at once program launches.
     */

    QTime dieTime = QTime::currentTime().addMSecs(100);
    while (QTime::currentTime() < dieTime)
        QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

    preferencesDialog->loadSettingsToFile();
}