Ejemplo n.º 1
0
void CUndo::UndoOne(CBaseView * pLeft, CBaseView * pRight, CBaseView * pBottom)
{
	allviewstate allstate = m_viewstates.back();
	POINT pt = m_caretpoints.back();

	Undo(allstate.left, pLeft, pt);
	Undo(allstate.right, pRight, pt);
	Undo(allstate.bottom, pBottom, pt);

	m_viewstates.pop_back();
	m_caretpoints.pop_back();
}
Ejemplo n.º 2
0
bool mitk::LimitedLinearUndo::Undo(bool fine)
{
  if (fine)
  {
    // undo one object event ID
    return Undo();
  }
  else
  {
    // undo one group event ID
    int oeid = FirstObjectEventIdOfCurrentGroup(m_UndoList); // get the Object Event ID of the first item with a differnt Group ID (as seen from the end of stack)
    return Undo(oeid);
  }
}
Ejemplo n.º 3
0
static void MainLineIterate(typePos *Position)
    {
    int va, v2, cp;
    uint32 m;
    (Position->Dyn + 1)->move = MoveNone;
    Mobility(Position);
    if (!RobboTotalBaseScore(Position, &va))
        {
        if (VerboseRobboBases)
			{
			Send("info string Failure in MainLine\n");

#ifdef Log
			if (WriteLog)
				{
				log_file = fopen(log_filename, "a");
				fprintf(log_file, "info string Failure in MainLine\n");
				close_log();
				}
#endif
			}

        (Position->Dyn + 1)->move = MoveNone;
       Position->StackHeight = 0;
        return;
        }
    if (!RobboMove(Position, &m, &v2, &cp))
        {
        (Position->Dyn + 1)->move = MoveNone;
       Position->StackHeight = 0;
        return;
        }
    if (va == dDraw)
        {
       Position->StackHeight = 0;
        Make(Position, m);
       Position->StackHeight = 1;
        Undo(Position, m);
        return;
        }
    m &= 0x7fff;
   Position->StackHeight = 0;
    Make(Position, m);
   Position->StackHeight = 1;
    MainLineIterate(Position);
    Undo(Position, m);
   Position->StackHeight = 1;
    }
Ejemplo n.º 4
0
uint64 PERFD (typePOS* POSITION, int n)
{
  int i;
  uint64 TOTAL = 0, TIME;
  typeMoveList LM[256], *lm;
  DrawBoard (POSITION);
  TIME = GetClock();
  Mobility (POSITION);
  if (IN_CHECK)
    lm = EvasionMoves (POSITION, LM, 0xffffffffffffffff);
  else
    {
      lm = CaptureMoves (POSITION, LM, POSITION->OccupiedBW);
      lm = OrdinaryMoves (POSITION, lm);
    }
  for (i = 0; i < lm - LM; i++)
    {
      Make (POSITION, LM[i].move);
      Mobility (POSITION);
      if (!ILLEGAL)
	{
	  printf ("%s ",Notate (LM[i].move, STRING1[POSITION->cpu]));
	  PERFT (POSITION, n - 1);
	  TOTAL += CNT[n - 1];
	}
      Undo (POSITION, LM[i].move);
    }
  printf ("TOTAL %lld  moves %ld  time: %lld us\n",
	  TOTAL, lm - LM, GetClock() - TIME);
  return TOTAL;
}
void ImageGroundTruthPanelViewer::on_key_down(wxKeyEvent & event)
{
    if(event.ControlDown() && event.GetUnicodeKey() == 'O')
    {
        InitIO();
        return;
    }

    if(mp_ground_truth_manager->IsEmpty())
    {
        return ;
    }

    try
    {
        switch(event.GetKeyCode())
        {
            case WXK_PAGEUP: LoadNextImage(); break;
            case WXK_PAGEDOWN: LoadPreviousImage(); break;
        }
        if(event.ControlDown())
        {
            switch(event.GetUnicodeKey())
            {
                case 'S': Save(); break;
                case 'Z': Undo(); break;
                case 'Y': Redo(); break;
                case 'A': MarkAsBlind(); break;
                case 'I': MarkAsUnknown(); break;
                case 'R': Reject(); break;
            }
        }
    }
    JPB_wx_CATCH("échec de l'ajout d'une boîtes englobante d'occlusion");
}
Ejemplo n.º 6
0
/*	function :	rollBack ()
		UNDO all actions that occured after the last leap of faith.
		in other words : rollback until you reach a leap of faith action.
		if this action reaches a (BOARD_INITIALIZED) action before reaching
		a (LEAP_OF_FAITH) action, it considers that the initial  state of
		the board is an invalid state and impossible to solve.
		in the later case, this function sets the state flag (_BAD_INITIALIZATION).
		return type :
			-	if rolled back successfully	: true.
			-	otherwise					: false.
*/
bool actionCourse::rollBack()
{

	do
	{
		if( lastAction() . act == actionRecord::BOARD_INITIALIZED)
		{
			// if reached the BOARD_INITIALIZED action ...
			// set the state flag _BAD_INITIALIZATION
			dynamic_cast<sudokuBoard*>(this)->state |= sudokuState::_BAD_INITIALIZATION;
			return false;
		}
		else
			Undo();
	}
	// keep rolling back until you reach a LEAP_OF_FAITH action.
	while( Tracker.top() != actionRecord::LEAP_OF_FAITH );

	// signal the current value as faulty and shouldn't be used for future leaps.
		Tracker.top().faultyValues.push_back(*(lastAction().subject));

		if( Tracker.top().faultyValues.size() < (unsigned)Tracker.top().subject->countPossibilities() )
		//correct the value taken by the leap
			return Correct_LeapOfFaith();

		else if(Tracker.top().subject->countPossibilities() == Tracker.top().faultyValues.size() )
			return rollBack();	//if all the possibilities are tried, then a previuos leap is the mistake, roll back another time.

		else
			return false;	// report failure.
}
Ejemplo n.º 7
0
static void
RicochetNext (void)
{
    if (!Solved ())
        while (Undo());
    NextTarget ();
}
Ejemplo n.º 8
0
bool mitk::LimitedLinearUndo::Undo()
{
  if(m_UndoList.empty()) return false;

  int undoObjectEventId = m_UndoList.back()->GetObjectEventId();
  return Undo( undoObjectEventId );
}
Ejemplo n.º 9
0
void Application::renormalize(HiddenMarkovModel &hmm,
			      int state,
			      const TigrString &ngram,
			      int changedSymbol,
			      double changedP)
{
  throw "OBSOLETE";

  TigrString history=ngram.substr(1,ngram.length()-1);
  double sum=0;
  for(int base=0 ; base<alphabetSize ; ++base)
    {
      char c=alphabet.lookup(base);
      TigrString ngram=history+c;
      int symbol=hoa->lookup(ngram);
      double p=hmm.getEmissionProb(state,symbol);
      undoables.push_back(Undo(&hmm,state,symbol,p));
      if(symbol==changedSymbol) p=changedP;
      sum+=p;
    }
  for(int base=0 ; base<alphabetSize ; ++base)
    {
      char c=alphabet.lookup(base);
      TigrString ngram=history+c;
      int symbol=hoa->lookup(ngram);
      double p=
	(symbol==changedSymbol ?
	 changedP :
	 hmm.getEmissionProb(state,symbol));
      hmm.setEmissionProb(state,symbol,p/sum);
    }
}
Ejemplo n.º 10
0
 /**
  * Destroys the Memento and reverts the Recorder back to the remembered state.
  *
  * @note The undo action will not be done if you have released the Memento.
  */
 ~Memento()
 {
     if (m_needRollback)
     {
         Undo();
     }
 }
Ejemplo n.º 11
0
void CColorEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	// TODO: Add your message handler code here and/or call default
	switch (nChar)
	{
	case 0x01:// Ctrl-A => handle SELECT_ALL
		SetSel(0, -1);
		return;
	case 0x03:// Ctrl-C => handle WM_COPY
		Copy();
		return;
	case 0x16:// Ctrl-V => handle WM_PASTE
		Paste();
		return;
	case 0x18:// Ctrl-X => handle WM_CUT
		Cut();
		return;
	case 0x1A:// Ctrl-Z => handle ID_EDIT_UNDO (EM_UNDO)
		if(CanUndo())
			Undo();
		return;
	}

	CEdit::OnChar(nChar, nRepCnt, nFlags);
}
void
MainWindow::InitEditMenu()
///
/// Initializes the edit menu and it's associated actions
///
/// @return
///  Nothing
///
{
	mUndoAction = new QAction( tr("&Undo"), this);
	mRedoAction = new QAction( tr("&Redo"), this);

	mEditMenu = menuBar()->addMenu( tr("&Edit") );
	mEditMenu->addAction( mUndoAction );
	mEditMenu->addAction( mRedoAction );

	// Connect the menu actions to their respective slots
	connect( mUndoAction, SIGNAL( triggered() ), this, SLOT( Undo() ) );
	connect( mRedoAction, SIGNAL( triggered() ), this, SLOT( Redo() ) );

	// Disable the actions until the main window broadcasts for them to be active
	mUndoAction->setDisabled( true );
	mRedoAction->setDisabled( true );

	connect( this, SIGNAL( UndoIsActive(bool) ), mUndoAction, SLOT( setEnabled(bool) ) );
	connect( this, SIGNAL( RedoIsActive(bool) ), mRedoAction, SLOT( setEnabled(bool) ) );
}
Ejemplo n.º 13
0
void MainWindow::CreateProjectNew(bool newProjectFile)
{
	if (newProject)
		delete newProject;

	if (newProjectFile)
	{
		newProject = new Project_new(this);
	} else {
		QStringList selections;
		QFileDialog dialog(0, "Open an ADCIRC Subdomain Project", QDir::homePath());
		dialog.setModal(true);
		dialog.setNameFilter("ADCIRC Subdomain Projects (*.spf)");
		dialog.setFileMode(QFileDialog::ExistingFile);
		if (dialog.exec())
		{
			selections = dialog.selectedFiles();
			if (!selections.isEmpty())
			{
				newProject = new Project_new(selections.first(), this);
			}
		} else {
			return;
		}
	}

	newProject->SetOpenGLPanel(ui->GLPanel);
	newProject->SetProgressBar(ui->progressBar);
	newProject->SetProjectTree(ui->projectTree);

	/* Subdomain Creation */
	connect(ui->createSubdomainButton, SIGNAL(clicked()), newProject, SLOT(CreateNewSubdomain()));

	/* Selection Tools */
	connect(ui->selectNodesCircle, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainCircleElements()));
	connect(ui->selectElementSingle, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainClickElements()));
	connect(ui->selectNodeSingle, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainPolygonElements()));
	connect(ui->selectNodesSquare, SIGNAL(clicked()), newProject, SLOT(SelectFullDomainRectangleElements()));

	connect(ui->undoButton, SIGNAL(clicked()), newProject, SLOT(Undo()));
	connect(ui->redoButton, SIGNAL(clicked()), newProject, SLOT(Redo()));

	/* U/I Updates */
	connect(newProject, SIGNAL(mouseX(float)), this, SLOT(showMouseX(float)));
	connect(newProject, SIGNAL(mouseY(float)), this, SLOT(showMouseY(float)));
	connect(newProject, SIGNAL(undoAvailable(bool)), ui->undoButton, SLOT(setEnabled(bool)));
	connect(newProject, SIGNAL(redoAvailable(bool)), ui->redoButton, SLOT(setEnabled(bool)));
	connect(newProject, SIGNAL(numElements(int)), this, SLOT(showNumElements(int)));
	connect(newProject, SIGNAL(numNodes(int)), this, SLOT(showNumNodes(int)));
	connect(newProject, SIGNAL(numElementsSelected(int)), this, SLOT(showNumSelectedElements(int)));
	connect(newProject, SIGNAL(numNodesSelected(int)), this, SLOT(showNumSelectedNodes(int)));
	connect(newProject, SIGNAL(maxSelectedZ(float)), this, SLOT(showMaxSelectedZ(float)));
	connect(newProject, SIGNAL(minSelectedZ(float)), this, SLOT(showMinSelectedZ(float)));
	connect(newProject, SIGNAL(showProjectView()), this, SLOT(showProjectExplorerPane()));

	/* Running ADCIRC */
	connect(ui->actionFull_Domain, SIGNAL(triggered()), newProject, SLOT(RunFullDomain()));
}
Ejemplo n.º 14
0
void PaintArea::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::RightButton)
        _right = true;
    else
        _right = false;
    if (_tool != 0)
    {
        _redo.clear();
        emit noRedo();
    }
    if (_isselect)
    {
        Undo();
        _isselect = false;
        emit noCopy();
    }
    lastPoint = event->pos();
    if (_tool == 7)
    {
        _history.push_back(image);
        emit enableUndo();
        drawWord(lastPoint);
    }
    else if (_tool == 6)
    {
        _history.push_back(image);
        emit enableUndo();
        drawBucket(event->pos());
    }
    else if (_tool == 10)
    {
        _history.push_back(image);
        emit enableUndo();
        Paste(event->pos());
    }
    else if (_tool == 12)
    {
        if (event->button() == Qt::LeftButton)
            zoomIn();
        else
            zoomOut();
    }
    else
    {
        _history.push_back(image);
        emit enableUndo();
        _scroll = image;
        scribbling = true;
        if (_tool == 1)
            drawLineTo(event->pos());
        else if (_tool == 2)
            drawEraser(event->pos());
        else if (_tool == 11)
            drawSpray(event->pos());
    }
}
Ejemplo n.º 15
0
void PaintArea::Copy()
{
    QRect select(_select.x() + 1, _select.y() + 1, _select.width() - 1, _select.height() - 1);
    _copy = image.copy(select);
    Undo();
    _history.push_back(image);
    emit enableUndo();
    emit canPaste();
    emit noCopy();
}
Ejemplo n.º 16
0
void CEditWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CTextWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
	bool isAlt = (GetKeyState(VK_MENU) & 0xF0) != 0;
	bool isShift = (GetKeyState(VK_SHIFT) & 0xF0) != 0;
	bool isCtrl = (GetKeyState(VK_CONTROL) & 0xF0) != 0;
	if (nChar == VK_BACK && isShift && isAlt)
		Redo();
	if ((nChar == VK_BACK && isAlt)) 
		Undo();
}
Ejemplo n.º 17
0
JBoolean
CBCStyler::SlurpPPComment
	(
	JIndexRange* totalRange
	)
{
	const JString& text = GetText();
	const JString s     = text.GetSubstring((GetPPNameRange()).first, totalRange->last);
	if (!ppCommentPattern.Match(s))
		{
		return kJFalse;
		}

	Token token;
	JString ppCmd;
	JSize nestCount = 1;
	while (1)
		{
		token = NextToken();
		if (token.type == kEOF)
			{
			break;
			}
		else if (token.type == kPPDirective)
			{
			ppCmd = text.GetSubstring(GetPPNameRange());
			if (ppIfPattern.Match(ppCmd))
				{
				nestCount++;
				}
			else if (ppEndPattern.Match(ppCmd))
				{
				nestCount--;
				if (nestCount == 0)
					{
					break;
					}
				}
			else if (ppElsePattern.Match(ppCmd) && nestCount == 1)
				{
				Undo(token.range, text.GetSubstring(token.range));	// rescan
				token.range.last = token.range.first - 1;
				break;
				}
			}
		}

	totalRange->last = token.range.last;
	return kJTrue;
}
Ejemplo n.º 18
0
SInt32 CDXUndoStack::GoTo(SInt32 index, bool doUpdate)
{
	SInt32 result = -1;
	SInt32 amount = index - m_index;

	if (amount == 0)
		return m_index;

	for (UInt32 i = 0; i < abs(amount); i++) {
		result = amount < 0 ? Undo(doUpdate) : Redo(doUpdate);
	}
	
	return result;
}
Ejemplo n.º 19
0
 void NativeTextfieldWin::ExecuteCommand(int command_id)
 {
     ScopedFreeze freeze(this, GetTextObjectModel());
     OnBeforePossibleChange();
     switch(command_id)
     {
     case IDS_APP_UNDO:       Undo();       break;
     case IDS_APP_CUT:        Cut();        break;
     case IDS_APP_COPY:       Copy();       break;
     case IDS_APP_PASTE:      Paste();      break;
     case IDS_APP_SELECT_ALL: SelectAll();  break;
     default:                 NOTREACHED(); break;
     }
     OnAfterPossibleChange(true);
 }
Ejemplo n.º 20
0
void CBCGMaskEdit::OnUpdateR() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CEdit::OnInitDialog()
	// function to send the EM_SETEVENTMASK message to the control
	// with the ENM_UPDATE flag ORed into the lParam mask.
	
	// TODO: Add your control notification handler code here
	if (!m_bUpdateInProgress)
	{
		m_bUpdateInProgress = TRUE;

		CString str;
		CWnd::GetWindowText(str);

		if (m_str != str && !m_bPasteProcessing)
		{
			// work incorrect for Paste when m_bSetMaskedCharsOnly==TRUE
			if (!SetValue(str, TRUE/*!m_bSetMaskedCharsOnly*/))
			{
				Undo();
				EmptyUndoBuffer();
				MessageBeep((UINT)-1);
				CWnd::GetWindowText(str);
			}
			if (str != m_str) // str may be empty
			{
				CWnd::SetWindowText(m_str);

				if (m_bSelectByGroup)
				{
					int nBegin, nEnd;
					GetGroupBounds(nBegin, nEnd, 0, TRUE);

					CEdit::SetSel(nBegin, nEnd);
				}
				else
				{
					CEdit::SetSel(0, -1);
				}
			}
		}

		m_bUpdateInProgress = FALSE;
	}
}
	double MathematicaLib::DoTheMath(char const* equation){
		
		commandHistory.insert(commandHistory.end(), equation); // saves each inputted command into a vector
		try{
			if (strcmp("Help", equation) == 0) { Help(); return 0.0; }
			else if (strcmp("Undo", equation) == 0) { return Undo(); }
			else if (strcmp("ClearRestart", equation) == 0){ ClearRestart(); return 0.0; }
			else if (strcmp("History", equation) == 0){ History(commandHistory); return 0.0; }
			else if (strcmp("Load", equation) == 0){ Load(); return 0.0; }
			else if (strlen(equation) > 100) { cout << "Input enetered is too big" << endl; return 0.0; } // used to limit input
			else
			{
				return IsThisAnEquation(equation); 
			}
		}
		catch (exception e){ cout << "Invalid input" << endl;  return 0; }
		return 0.0; // when an equations was not inputted
	}// end of DoTheMath 
Ejemplo n.º 22
0
Undo movePartsTotheRight(unsigned int startTicks, int moveTicks, bool only_selected, set<Track*>* tracklist)
{
      if (moveTicks<=0)
            return Undo();

      Undo operations;
      TrackList* tracks = MusEGlobal::song->tracks();
      
      for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
            Track* track = *it;
            if ( (track == 0) ||
                 (only_selected && !track->selected()) ||
                 (tracklist && tracklist->find(track)==tracklist->end()) )
                  continue;
            PartList* pl = track->parts();
            for (riPart p = pl->rbegin(); p != pl->rend(); ++p) {
                  Part* part = p->second;
                  unsigned t = part->tick();
                  int l = part->lenTick();
                  if (t + l <= startTicks)
                        continue;
                  if (startTicks > t && startTicks < (t+l)) {
                        // split part to insert new space
                        Part* p1;
                        Part* p2;
                        part->splitPart(startTicks, p1, p2);
                        p2->setTick(startTicks+moveTicks);

                        MusEGlobal::song->informAboutNewParts(part,p1,p2);
                        operations.push_back(UndoOp(UndoOp::DeletePart, part));
                        operations.push_back(UndoOp(UndoOp::AddPart, p1));
                        operations.push_back(UndoOp(UndoOp::AddPart, p2));
                        }
                  else if (t >= startTicks) {
                        operations.push_back(UndoOp(UndoOp::ModifyPartTick, part, part->tick(), t + moveTicks));
                        }
                  }
            }

      adjustGlobalLists(operations, startTicks, moveTicks);

      return operations;
      }
Ejemplo n.º 23
0
bool DeleteMap::HandleAction(QString &action, uint64_t frame, uint64_t played)
{
    bool handled = true;
    if (action == ACTION_UP)
        UpdateSeekAmount(1);
    else if (action == ACTION_DOWN)
        UpdateSeekAmount(-1);
    else if (action == ACTION_CLEARMAP)
        Clear(tr("Clear Cuts"));
    else if (action == ACTION_INVERTMAP)
        ReverseAll();
    else if (action == "MOVEPREV")
        MoveRelative(frame, false);
    else if (action == "MOVENEXT")
        MoveRelative(frame, true);
    else if (action == "CUTTOBEGINNING")
    {
        Push(tr("Cut to Beginning"));
        AddMark(frame, MARK_CUT_END);
    }
    else if (action == "CUTTOEND")
    {
        Push(tr("Cut to End"));
        AddMark(frame, MARK_CUT_START);
        // If the recording is still in progress, add an explicit end
        // mark at the end.
        if (m_ctx->player && m_ctx->player->IsWatchingInprogress())
            AddMark(m_ctx->player->GetTotalFrameCount() - 1, MARK_CUT_END);
    }
    else if (action == "NEWCUT")
        NewCut(frame);
    else if (action == "DELETE")
        //: Delete the current cut or preserved region
        Delete(frame, tr("Delete"));
    else if (action == "UNDO")
        Undo();
    else if (action == "REDO")
        Redo();
    else
        handled = false;
    return handled;
}
Ejemplo n.º 24
0
int AskUndo(tGame * game, tUndo * undo)
{
	char input[MAX_COMMAND_LEN];
	char * pinput;

	int wasundo = FALSE;
	int wasquit = FALSE;

	PrintBoard(&game->visualboard);

	printf("%sPerdiste! ¿Hacer Undo? (Ingresar undo o quit)%s\n", KASK, KDEF);

	do{
		pinput = fgets(input, MAX_COMMAND_LEN, stdin);
		if (pinput != NULL)
		{
			wasundo = (strcmp(input,"undo\n") == 0);
			wasquit = (strcmp(input,"quit\n") == 0);
		}

		if (!wasundo && !wasquit)
			printf("%s%s%s\n", KERR, ASKUNDO_ERR, KDEF);
	}
	while ( (!wasundo && !wasquit) || (pinput == NULL));


	if (wasundo)
	{
		Undo(game, undo);
		game->undos--;
		if (game->gametype != GAMETYPE_INDIVIDUAL_NOLIMIT)
			game->moves--;
		return TRUE;
	}
	else
	{
		game->gamestate = GAMESTATE_LOSE;
		return FALSE;
	}

}
Ejemplo n.º 25
0
void MainWindow::HandleMessage( os::Message * pcMessage )
{
	// Get message code and act on it
	switch ( pcMessage->GetCode() )
	{
	case M_MW_INPUT:
		InputChange();
		break;
	case M_MW_VIDEOOUTPUT:
		VideoOutputChange();
		break;
	case M_MW_AUDIOOUTPUT:
		AudioOutputChange();
		break;
		
	case M_MW_APPLY:
		Apply();
		break;

	case M_MW_DEFAULT:
		Default();
		break;

	case M_MW_UNDO:
		Undo();
		break;

	case M_MW_DEVICE:
		DeviceChanged();
		break;
	
	case M_MW_CONTROLS:
		os::MediaManager::GetInstance()->GetServerLink().SendMessage( os::MEDIA_SERVER_SHOW_CONTROLS );
		break;

	default:
		os::Window::HandleMessage( pcMessage );
		break;
	}

}
Ejemplo n.º 26
0
void  Engine::input(sf::Event *event)
{
    bool a = sf::Keyboard::isKeyPressed(sf::Keyboard::A);
    bool b = sf::Keyboard::isKeyPressed(sf::Keyboard::S);
    if (a && !b) setMode(EDITOR_1);
    else if (!a && b) setMode(EDITOR_2);
    else
        setMode(DEFAULT);

    bool n1 = false;
    bool n2 = false;
    if (event->type == sf::Event::KeyReleased)
    {
        if (event->key.code == sf::Keyboard::Num1) n1 = true;
        if (event->key.code == sf::Keyboard::Num2) n2 = true;

        if (event->key.code == sf::Keyboard::Z) Undo();
        if (event->key.code == sf::Keyboard::Y) Redo();
        if (event->key.code == sf::Keyboard::Space) saveConfig();

        if (event->key.code == sf::Keyboard::Return) renderToFile();

        if (event->key.code == sf::Keyboard::P)  fullOrWindowScreen();
    }


    if (a && !b) setMode(EDITOR_1);
    else if (!a && b) setMode(EDITOR_2);
    else
        setMode(DEFAULT);

    if (n1 && !n2) setTool(LINE);
    else if (!n1 && n2) setTool(CIRCLE);


    if (mode == EDITOR_1)
        editor1->input(event, window);

    if (mode == EDITOR_2)
        editor2->input(event, window);
}
void CommandManager::DoCommand(Command* pCommand, std::string& feedback){
	if(pCommand->getType() == UNDO){
		Undo(feedback);
	} else if(pCommand->getType() == REDO){
		Redo();
	} else {
		// Clear redo list
		if(pCommand->getType() != DISPLAY){
			ClearRedoList();
		}
		// Execute the command and add it to undo list if succeeded
		if (pCommand->execute(_taskList,feedback)){
			if(undoable(pCommand)){
				AddUndo(pCommand);
			} else {
				delete pCommand;
				pCommand = NULL;
			}
		}
	}
}
Ejemplo n.º 28
0
void SceneStructureWindow::SetShownScene(const ScenePtr &newScene)
{
    if (!scene.expired() && newScene == scene.lock())
        return;

    ScenePtr previous = ShownScene();
    if (previous)
    {
        disconnect(previous.get());
        Clear();
    }

    scene = newScene;
    treeWidget->SetScene(newScene);

    if (newScene)
    {
        // Now that treeWidget has scene, it also has UndoManager.
        UndoManager *undoMgr = treeWidget->GetUndoManager();
        undoButton_->setMenu(undoMgr->UndoMenu());
        redoButton_->setMenu(undoMgr->RedoMenu());
        connect(undoMgr, SIGNAL(CanUndoChanged(bool)), this, SLOT(SetUndoEnabled(bool)), Qt::UniqueConnection);
        connect(undoMgr, SIGNAL(CanRedoChanged(bool)), this, SLOT(SetRedoEnabled(bool)), Qt::UniqueConnection);
        connect(undoButton_, SIGNAL(clicked()), undoMgr, SLOT(Undo()), Qt::UniqueConnection);
        connect(redoButton_, SIGNAL(clicked()), undoMgr, SLOT(Redo()), Qt::UniqueConnection);

        Scene* s = ShownScene().get();
        connect(s, SIGNAL(EntityAcked(Entity *, entity_id_t)), SLOT(AckEntity(Entity *, entity_id_t)));
        connect(s, SIGNAL(EntityCreated(Entity *, AttributeChange::Type)), SLOT(AddEntity(Entity *)));
        connect(s, SIGNAL(EntityTemporaryStateToggled(Entity *, AttributeChange::Type)), SLOT(UpdateEntityTemporaryState(Entity *)));
        connect(s, SIGNAL(EntityRemoved(Entity *, AttributeChange::Type)), SLOT(RemoveEntity(Entity *)));
        connect(s, SIGNAL(ComponentAdded(Entity *, IComponent *, AttributeChange::Type)), SLOT(AddComponent(Entity *, IComponent *)));
        connect(s, SIGNAL(ComponentRemoved(Entity *, IComponent *, AttributeChange::Type)), SLOT(RemoveComponent(Entity *, IComponent *)));
        connect(s, SIGNAL(SceneCleared(Scene*)), SLOT(Clear()));

        Populate();
    }
}
Ejemplo n.º 29
0
/*----------------------------------------------------------------------------------------------
	${IActionHandler#Rollback}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::Rollback(int nDepth)
{
	BEGIN_COM_METHOD;
	if (m_nDepth > 0)
	{
		CheckHr(EndUndoTask());
		m_nDepth = nDepth;
		// make sure we have something to undo
		if (m_iCurrSeq >= 0 && m_fDataChangeAction)
		{
			UndoResult ures;
			CheckHr(Undo(&ures));
			// REVIEW (TimS): What should we do if the undo fails?
			if (ures == kuresError || ures == kuresFailed)
			{
				return E_FAIL;
			}
			CleanUpRedoActions(true);
		}
	}
	return S_OK;
	END_COM_METHOD(g_factActh, IID_IActionHandler);
}
void
JXExprEditor::HandleEditMenu
	(
	const JIndex item
	)
{
	CmdIndex cmd;
	if (!EditMenuIndexToCmd(item, &cmd))
		{
		return;
		}

	if (cmd == kUndoCmd)
		{
		Undo();
		}
	else if (cmd == kCutCmd)
		{
		Cut();
		}
	else if (cmd == kCopyCmd)
		{
		Copy();
		}
	else if (cmd == kPasteCmd)
		{
		Paste();
		}
	else if (cmd == kDeleteSelCmd)
		{
		DeleteSelection();
		}
	else if (cmd == kSelectAllCmd)
		{
		SelectAll();
		}
}