Exemplo n.º 1
0
	void UndoableAction::Redo()
	{
		if (!IsUndone()) // Can't redo an action that hasn't been undone
			return;
		redoAction();
		m_Undone = false;
	}
Exemplo n.º 2
0
void MainWindow::connectActions()
{
    ui->actionSave_XML_file->setVisible(true);
    ui->actionOpen_XML_file->setVisible(true);

    connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(ui->actionOpen_XML_file, SIGNAL(triggered()), this, SLOT(openTreeFromXML()));
    ui->actionOpen_XML_file->setShortcuts(QKeySequence::Open);
    ui->actionOpen_XML_file->setStatusTip(tr("Open a sketch from an XML file"));

    connect(ui->actionSave_XML_file, SIGNAL(triggered()), this, SLOT(saveTreeToXML()));
    ui->actionSave_XML_file->setShortcuts(QKeySequence::Save);
    ui->actionSave_XML_file->setStatusTip(tr("Save your current sketch to an XML file"));

    /*connect(ui->actionGenerate_output_for_XML_file, SIGNAL(triggered()), this, SLOT(generateFromXML()));
    ui->actionGenerate_output_for_XML_file->setStatusTip(tr("Generate rendered output for an XML file"));*/

    connect(ui->actionDisplay_XML_file, SIGNAL(triggered()), this, SLOT(displayXMLFile()));
    ui->actionDisplay_XML_file->setStatusTip(tr("Display an XML file"));

    connect(ui->actionDisplay_LST_file, SIGNAL(triggered()), this, SLOT(displayLSTFile()));
    ui->actionDisplay_LST_file->setStatusTip(tr("Display an LST file"));

    connect(ui->actionGenerate_from_current, SIGNAL(triggered()), this, SLOT(generateFromCurrent()));
    ui->actionGenerate_from_current->setStatusTip(tr("Generate rendered output from the current sketch"));

    connect(ui->actionExport_Cylinder_Model_to_OBJ, SIGNAL(triggered()), this, SLOT(Export()));
    ui->actionExport_Cylinder_Model_to_OBJ->setStatusTip(tr("Export current view to OBJ file"));

    connect(ui->actionBlack_background, SIGNAL(triggered()), this, SLOT(blackBackground()));
    ui->actionBlack_background->setStatusTip(tr("Set tree display background to black"));

    connect(ui->actionWhite_background, SIGNAL(triggered()), this, SLOT(whiteBackground()));
    ui->actionWhite_background->setStatusTip(tr("Set tree display background to white"));



    connect(ui->actionUndo, SIGNAL(triggered()), this, SLOT(undoAction()));
    ui->actionUndo->setShortcuts(QKeySequence::Undo);
    ui->actionUndo->setStatusTip(tr("Undo your last action"));

    connect(ui->actionRedo, SIGNAL(triggered()), this, SLOT(redoAction()));
    ui->actionRedo->setShortcuts(QKeySequence::Redo);
    ui->actionRedo->setStatusTip(tr("Redo your last undone action"));


}
Exemplo n.º 3
0
bool ActionManager::Undo ()
{
  if (undoStack.IsEmpty ())
    return false;

  csRef<iAction> action (undoStack.Pop ());

  // Store redo action
  csRef<iAction> redoAction (action->Do ());
  if (redoAction.IsValid ())
    redoStack.Push (redoAction);

  NotifyListeners (action);

  return true;
}
Exemplo n.º 4
0
QToolBar* specActionLibrary::toolBar(QWidget* target)
{
	QToolBar* bar = new QToolBar(target) ;
	bar->setContentsMargins(0, 0, 0, 0) ;
	bar->setIconSize(QSize(20, 20)) ;

	specView* view = dynamic_cast<specView*>(target) ;
	specDataView*   dataView   = dynamic_cast<specDataView*>(target) ;
	specMetaView*   metaView   = dynamic_cast<specMetaView*>(target) ;
	specLogView*    logView    = dynamic_cast<specLogView*>(target) ;
	specPlot*       plot       = dynamic_cast<specPlot*>(target) ;
	specPlotWidget* plotWidget = dynamic_cast<specPlotWidget*>(target) ;

	if(view && view->model())
	{
		addParent(view) ;
		addParent(view->model()) ;
		addNewAction(bar, new specAddFolderAction(target)) ;
		if(metaView)
			addNewAction(bar, new specNewMetaItemAction(target));
		else
		{
			addNewAction(bar, new specImportSpecAction(target)) ;
			addNewAction(bar, new specTreeAction(target)) ;
			addNewAction(bar, new specFlattenTreeAction(target)) ;
		}
		if(dataView || metaView)
			addNewAction(bar, new specAddSVGItemAction(target)) ;
		addNewAction(bar, new genericExportAction(target)) ;
		bar->addSeparator() ;
		addNewAction(bar, new specCopyAction(target)) ;
		if(dataView || metaView)
			addNewAction(bar, new matrixExportAction(target)) ;
		addNewAction(bar, new specCutAction(target)) ;
		addNewAction(bar, new specPasteAction(target)) ;
		addNewAction(bar, new specDeleteAction(target)) ;
		bar->addSeparator() ;
		if(metaView || logView)
		{
			bar->addAction(undoAction(view)) ;
			bar->addAction(redoAction(view)) ;
			bar->addSeparator() ;
		}
		if(dataView)
		{
			addNewAction(bar, new toggle3DPlotAction(target)) ;
			addNewAction(bar, new specMergeAction(target)) ;
			addNewAction(bar, new specTiltMatrixAction(target)) ;
			addNewAction(bar, new specDescriptorEditAction(target)) ;
			bar->addSeparator() ;
			addNewAction(bar, new specRemoveDataAction(target)) ;
			addNewAction(bar, new specAverageDataAction(target)) ;
			addNewAction(bar, new specSpectrumCalculatorAction(target)) ;
			addNewAction(bar, new specNormalizeAction(target)) ;
		}
		addNewAction(bar, new specItemPropertiesAction(target)) ;
		addNewAction(bar, new specSetMultilineAction(target)) ;
		if(metaView)
		{
			addNewAction(bar, new specAddConnectionsAction(target)) ;
			addNewAction(bar, new specSelectConnectedAction(target)) ;
			addNewAction(bar, new specAddFitAction(target)) ;
			addNewAction(bar, new specRemoveFitAction(target)) ;
			addNewAction(bar, new specToggleFitStyleAction(target));
			addNewAction(bar, new specConductFitAction(target)) ;
		}
		if(logView)
			addNewAction(bar, new specDescriptorEditAction(target)) ;
		bar->addSeparator() ;
		if(dataView || metaView)
			addNewAction(bar, new changePlotStyleAction(target)) ;
		bar->setWindowTitle(tr("Items toolbar"));
	}

	if(plot)
	{
		addParent(plot);
		addNewAction(bar, new specTitleAction(target)) ;
		addNewAction(bar, new specXLabelAction(target)) ;
		addNewAction(bar, new specYLabelAction(target)) ;
		bar->addActions(plot->actions());
		bar->setWindowTitle(tr("Plot toolbar"));
	}

	if(plotWidget)
	{
		delete bar ;
		bar = plotWidget->createToolbar() ;
		bar-> addSeparator() ;
		bar-> addAction(purgeUndoAction) ;
		bar-> addSeparator() ;
		bar-> addAction(undoAction(this)) ;
		bar-> addAction(redoAction(this)) ;
		bar->setWindowTitle(tr("Main toolbar"));
	}

	return bar ;
}
Exemplo n.º 5
0
void MainWindow::createActions()
{
    //saveToXML = new QAction(QIcon(":/images/save.png"), tr("&Save..."), this);
    //saveToXML = new QAction(("&Save..."), this);
    //saveToXML->setShortcuts(QKeySequence::Save);
    //saveToXML->setStatusTip(tr("Save your current sketch to an XML file"));
    //saveToXML->setText("Save");
    //connect(saveToXML, SIGNAL(triggered()), this, SLOT(saveTreeToXML()));

    newSketch = new QAction(("&New"), this);
    newSketch->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
    newSketch->setStatusTip(tr("Start a new sketch"));
    connect(newSketch, SIGNAL(triggered()), this, SLOT(clearSketch()));

    generate = new QAction(("&Generate"), this);
    generate->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
    generate->setStatusTip(tr("Generate a tree from your current sketch"));
    connect(generate, SIGNAL(triggered()), this, SLOT(generateFromCurrent()));
    generate->setEnabled(false);

    generationOption = new QAction(("&Options"), this);
    generationOption->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
    generationOption->setStatusTip(tr("Choose settings for the tree generation process"));
    connect(generationOption, SIGNAL(triggered()), this, SLOT(generationOptions()));

    newVariation = new QAction(("&New Variation"), this);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    newVariation->setStatusTip(tr("Generate a new variation of the last type of tree you generated"));
    connect(newVariation, SIGNAL(triggered()), this, SLOT(generateNewVariation()));
    newVariation->setEnabled(false);


    displayFoliage = new QCheckBox(("&Foliage"), this);
    displayFoliage->setChecked(true);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    displayFoliage->setStatusTip(tr("Display foliage"));
    connect(displayFoliage, SIGNAL(toggled(bool)), this, SLOT(toggleFoliage( bool)));
    displayFoliage->setEnabled(false);
    displayFoliage->setChecked(true);

    displayTexture = new QCheckBox(("&Texture"), this);
    displayTexture->setChecked(true);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    displayTexture->setStatusTip(tr("Display texture"));
    connect(displayTexture, SIGNAL(toggled(bool)), this, SLOT(toggleTexture(bool)));
    displayTexture->setEnabled(false);
    displayTexture->setChecked(true);

    displaySubdivisionSurface = new QCheckBox(("&Subdivision Surface"), this);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    displaySubdivisionSurface->setStatusTip(tr("Generate a subdivision surface for the trunk and branches"));
    displaySubdivisionSurface->setChecked(true);
    connect(displaySubdivisionSurface, SIGNAL(toggled(bool)), this, SLOT(displayAsMesh(bool)));
    displaySubdivisionSurface->setEnabled(false);

    SubdivSpinBox = new QSpinBox();
    SubdivSpinBox->setSingleStep(1);
    SubdivSpinBox->setMaximumWidth(40);
    SubdivSpinBox->setValue(subdivs);
    SubdivSpinBox->setMaximum(3);
    SubdivSpinBox->setEnabled(false);

    connect(SubdivSpinBox, SIGNAL( valueChanged(int)), this, SLOT(SubdivSliderChange(int)));


    undo = new QAction(QIcon("./Resources/Icons/Undo.png"),("&Undo"), this);
    undo->setStatusTip(tr("Undo your last action"));
    connect(undo, SIGNAL(triggered()), this, SLOT(undoAction()));

    redo = new QAction(QIcon("./Resources/Icons/Redo.png"),("&Redo"), this);
    redo->setStatusTip(tr("Redo your last undone action"));
    connect(redo, SIGNAL(triggered()), this, SLOT(redoAction()));

    //viewXML = new QAction(("&Display XML file..."), this);
    //connect(viewXML, SIGNAL(triggered()), this, SLOT(viewXMLAction()));

    //viewLST = new QAction(("&Display LST file..."), this);
    //connect(viewLST, SIGNAL(triggered()), this, SLOT(viewLSTAction()));

    lineMode = new QToolButton(this);
    lineMode->setText("Line Mode");
    lineMode->setIcon(QIcon("./Resources/Icons/LineMode.png"));
    lineMode->setStatusTip(tr("Change to line drawing mode in the sketch interface"));
    connect(lineMode, SIGNAL(clicked()), this, SLOT(setLineMode()));
    lineMode->setCheckable(true);
    lineMode->setChecked(true);
    lineMode->setAutoExclusive(true);

    selectMode = new QToolButton(this);
    selectMode->setText("Select Mode");
    selectMode->setIcon(QIcon("./Resources/Icons/SelectMode.png"));
    selectMode->setStatusTip(tr("Change to selection mode in the sketch interface"));
    connect(selectMode, SIGNAL(clicked()), this, SLOT(setSelectMode()));
    selectMode->setCheckable(true);
    selectMode->setAutoExclusive(true);

    pencilMode = new QToolButton(this);
    pencilMode->setText("Pencil Mode");
    pencilMode->setIcon(QIcon("./Resources/Icons/PencilMode.png"));
    pencilMode->setStatusTip(tr("Change to pencil drawing mode in the sketch interface"));
    connect(pencilMode, SIGNAL(clicked()), this, SLOT(setPencilMode()));
    pencilMode->setCheckable(true);
    pencilMode->setAutoExclusive(true);

    brushSize = new QComboBox(this);
    QIntValidator *val = new QIntValidator(brushSize);
    val->setRange(3, 30);
    brushSize->setValidator(val);
    connect(brushSize, SIGNAL(activated(const QString&)), this, SLOT(setBrushSize(const QString&)));
    for (int i=0; i<BRUSH_SIZE_COUNT; ++i)
    {
        QString s;
        s.setNum(BRUSH_SIZE_OPTION[i]);
        brushSize->insertItem(i+1, s);
    }

    brushLabel = new QLabel(this);
    brushLabel->setText(" Brush size:  ");


    texSynthOption = new QAction(("&Synthesize Texture"), this);
    //  texSynthOption->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
    texSynthOption->setStatusTip(tr("Synthesize a new texture from a sample"));
    connect(texSynthOption, SIGNAL(triggered()), this,SLOT(SynthesizeTexture()));

}
Exemplo n.º 6
0
void QsciEditor::setupActions() {

	cutAct = new QAction( QIcon::fromTheme( "edit-cut" ), "Cu&t", this );
	cutAct->setStatusTip( "Cut the selected text" );
	cutAct->setShortcut( tr( "Ctrl+X" ) );

	copyAct = new QAction( QIcon::fromTheme( "edit-copy" ), "&Copy", this );
	copyAct->setStatusTip( "Copy the selected text" );
	copyAct->setShortcut( tr( "Ctrl+C" ) );

	pasteAct = new QAction( QIcon::fromTheme( "edit-paste" ), "&Paste", this );
	pasteAct->setStatusTip( "Paste the text on the clipboard" );
	pasteAct->setShortcut( tr( "Ctrl+V" ) );

	deleteAct = new QAction( QIcon::fromTheme( "edit-delete" ), "&Delete", this );
	deleteAct->setStatusTip( "Delete the selected Text" );
	deleteAct->setShortcut( tr( "Delete" ) );

	selectAct = new QAction( QIcon::fromTheme( "edit-select-all" ), "Select &All", this );
	selectAct->setStatusTip( "Select all the text" );
	selectAct->setShortcut( tr( "Ctrl+A" ) );

	deselectAct = new QAction( QIcon(), "Deselect &All", this );
	deselectAct->setStatusTip( "Deselect all the text" );
	deselectAct->setShortcut( tr( "Ctrl+Shift+A" ) );

	undoAct = new QAction( QIcon::fromTheme( "edit-undo" ), "&Undo", this );
	undoAct->setStatusTip( "Undo the last change" );
	undoAct->setShortcut( tr( "Ctrl+Z" ) );

	redoAct = new QAction( QIcon::fromTheme( "edit-redo" ), "&Redo", this );
	redoAct->setStatusTip( "Redo the undone change" );
	redoAct->setShortcut( tr( "Ctrl+Y" ) );

	searchAct = new QAction( QIcon::fromTheme( "edit-find" ), "&Search", this );
	searchAct->setStatusTip( "Search the document" );
	searchAct->setShortcut( tr( "Ctrl+F" ) );

	replaceAct = new QAction( QIcon::fromTheme( "edit-find-replace" ), "&Replace", this );
	replaceAct->setStatusTip( "Replace text in the document" );
	replaceAct->setShortcut( tr( "Ctrl+R" ) );

	changeFontAct = new QAction( QIcon::fromTheme( "preferences-desktop-font" ), "Change &Font", this );
	changeFontAct->setStatusTip( "Change the font of the document" );
	changeFontAct->setShortcut( tr( "Ctrl+Shift+F" ) );

	toggleCaseAct = new QAction( "T&oggle Case of Selection", this );
	toggleCaseAct->setStatusTip( "Toggle the case of the selected text" );
	toggleCaseAct->setShortcut( tr( "Ctrl+Alt+U" ) );

	connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( showCustomMenu( const QPoint& ) ) );

	connect( cutAct, SIGNAL( triggered() ), this, SLOT( cutAction() ) );
	connect( copyAct, SIGNAL( triggered() ), this, SLOT( copyAction() ) );
	connect( pasteAct, SIGNAL( triggered() ), this, SLOT( pasteAction() ) );
	connect( deleteAct, SIGNAL( triggered() ), this, SLOT( deleteAction() ) );

	connect( undoAct, SIGNAL( triggered() ), this, SLOT( undoAction() ) );
	connect( redoAct, SIGNAL( triggered() ), this, SLOT( redoAction() ) );

	connect( selectAct, SIGNAL( triggered() ), this, SLOT( selectAction() ) );
	connect( deselectAct, SIGNAL( triggered() ), this, SLOT( deselectAction() ) );

	connect( changeFontAct, SIGNAL( triggered() ), this, SLOT( changeFont() ) );
	connect( toggleCaseAct, SIGNAL( triggered() ), this, SLOT( toggleCase() ) );

	connect( searchAct, SIGNAL( triggered() ), this, SLOT( showSearch() ) );
	connect( this, SIGNAL( linesChanged() ), this, SLOT( resizeMargins() ) );

	addAction( cutAct );
	addAction( copyAct );
	addAction( pasteAct );
	addAction( deleteAct );
	addAction( selectAct );
	addAction( deselectAct );
	addAction( undoAct );
	addAction( redoAct );
	addAction( searchAct );
	addAction( replaceAct );
	addAction( changeFontAct );
	addAction( toggleCaseAct );

	/* Change keyBindings */
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_DOWN + ( SCMOD_CTRL << 16 ), SCI_PARADOWN );
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_UP + ( SCMOD_CTRL << 16 ), SCI_PARAUP );
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_DOWN + ( SCMOD_ALT << 16 ), SCI_LINESCROLLDOWN );
	SendScintilla( SCI_ASSIGNCMDKEY, SCK_UP + ( SCMOD_ALT << 16 ), SCI_LINESCROLLUP );

	/* Remove Ctrl+D as duplicate line */
	SendScintilla( SCI_CLEARCMDKEY, 68 + ( SCMOD_CTRL << 16 ) );
};