Ejemplo n.º 1
0
void PaintArea::clearHistory()
{
    _history.clear();
    _redo.clear();
    emit noUndo();
    emit noRedo();
}
Ejemplo n.º 2
0
void PaintArea::Undo()
{
    if (_history.size() != 0)
    {
        _redo.push_back(image);
        emit enableRedo();
        image = _history.back();
        _history.pop_back();
        update();
    }
    if (_history.size() == 0)
        emit noUndo();

}
Ejemplo n.º 3
0
/******************************************************************************
* Handles the menu item event.
******************************************************************************/
void ViewportMenu::onCreateCamera()
{
	UndoableTransaction::handleExceptions(_viewport->dataset()->undoStack(), tr("Create camera"), [this]() {
		SceneRoot* scene = _viewport->dataset()->sceneRoot();
		AnimationSuspender animSuspender(_viewport->dataset()->animationSettings());

		// Create and initialize the camera object.
		OORef<CameraObject> cameraObj;
		OORef<ObjectNode> cameraNode;
		{
			UndoSuspender noUndo(_viewport->dataset()->undoStack());
			cameraObj = new CameraObject(_viewport->dataset());
			cameraObj->setIsPerspective(_viewport->isPerspectiveProjection());
			if(_viewport->isPerspectiveProjection())
				cameraObj->fovController()->setFloatValue(0, _viewport->fieldOfView());
			else
				cameraObj->zoomController()->setFloatValue(0, _viewport->fieldOfView());

			// Create an object node for the camera.
			cameraNode = new ObjectNode(_viewport->dataset());
			cameraNode->setDataProvider(cameraObj);

			// Give the new node a name.
			cameraNode->setName(scene->makeNameUnique(tr("Camera")));

			// Position camera node to match the current view.
			AffineTransformation tm = _viewport->inverseViewMatrix();
			if(_viewport->isPerspectiveProjection() == false) {
				// Position camera with parallel projection outside of scene bounding box.
				tm = tm * AffineTransformation::translation(
						Vector3(0, 0, -_viewport->_projParams.znear + 0.2f * (_viewport->_projParams.zfar-_viewport->_projParams.znear)));
			}
			cameraNode->transformationController()->setTransformationValue(0, tm, true);
		}

		// Insert node into scene.
		scene->addChild(cameraNode);

		// Set new camera as view node for current viewport.
		_viewport->setViewType(Viewport::VIEW_SCENENODE);
		_viewport->setViewNode(cameraNode);
	});
}
Ejemplo n.º 4
0
PaintArea::PaintArea(QWidget *parent) : QWidget(parent)
{
    setAttribute(Qt::WA_StaticContents);
    modified = false;
    scribbling = false;
    myPenWidth = 1;
    myPenColor = Qt::black;
    myFillColor = Qt::white;
    _tool = 0;
    _scroll = image;
    _isselect = false;
    _right = false;
    mySprayWidth = 10;
    _scaled = false;
    _size_x = 400;
    _size_y = 300;
    emit setSize(_size_x, _size_y);
    emit noRedo();
    emit noUndo();
    srand (time(NULL));
}
Ejemplo n.º 5
0
// File Operations
bool PaintArea::openImage(const QString &fileName)
{
    QImage loadedImage;
    if (!loadedImage.load(fileName))
        return false;
    _size_x = loadedImage.width();
    _size_y = loadedImage.height();
    resize(_size_x, _size_y);
    setMinimumSize(_size_x, _size_y);
    setMaximumSize(_size_x, _size_y);
    emit setSize(_size_x, _size_y);
    image = loadedImage;
    modified = false;
    _scaled = false;
    update();
    _history.clear();
    _redo.clear();
    emit noRedo();
    emit noUndo();
    return true;
}
Ejemplo n.º 6
0
/******************************************************************************
* Is called after the application has been completely initialized.
******************************************************************************/
void ScriptAutostarter::applicationStarted()
{
	// Execute the script commands and files passed on the command line.
	QStringList scriptCommands = Application::instance().cmdLineParser().values("exec");
	QStringList scriptFiles = Application::instance().cmdLineParser().values("script");

	if(!scriptCommands.empty() || !scriptFiles.empty()) {

		// Get the current dataset.
		DataSet* dataset = Application::instance().datasetContainer()->currentSet();

		// Suppress undo recording. Actions performed by startup scripts cannot be undone.
		UndoSuspender noUndo(dataset);

		// Set up script engine.
		ScriptEngine engine(dataset);

		// Pass command line parameters to the script.
		QStringList scriptArguments = Application::instance().cmdLineParser().values("scriptarg");

		// Execute script commands.
		for(int index = scriptCommands.size() - 1; index >= 0; index--) {
			const QString& command = scriptCommands[index];
			try {
				engine.execute(command, scriptArguments);
			}
			catch(Exception& ex) {
				ex.prependGeneralMessage(tr("Error during Python script execution."));
				throw;
			}
		}

		// Execute script files.
		for(int index = scriptFiles.size() - 1; index >= 0; index--) {
			engine.executeFile(scriptFiles[index], scriptArguments);
		}
	}
}