本文整理汇总了C++中SimpleState类的典型用法代码示例。如果您正苦于以下问题:C++ SimpleState类的具体用法?C++ SimpleState怎么用?C++ SimpleState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void GuideManagerCore::clearVerticals(GuideType type)
{
switch (type)
{
case Standard:
if (m_undoManager->undoEnabled())
{
for (int i = 0; i < m_verticalStdG.count(); ++i)
{
SimpleState* ss = new SimpleState(Um::DelVGuide, nullptr, Um::IGuides);
ss->set("REMOVE_V", m_verticalStdG[i]);
m_undoManager->action(m_page, ss);
}
}
m_verticalStdG.clear();
break;
case Auto:
if (m_undoManager->undoEnabled())
{
SimpleState * ss = new SimpleState(Um::DelVAGuide, nullptr, Um::IGuides);
ss->set("REMOVE_VA_GAP", m_verticalAutoGap);
ss->set("REMOVE_VA_COUNT", m_verticalAutoCount);
ss->set("REMOVE_VA_REFER", m_verticalAutoRefer);
m_undoManager->action(m_page, ss);
}
m_verticalAutoGap = 0.0;
m_verticalAutoCount = 0;
m_verticalAutoRefer = 0;
m_verticalAutoG.clear();
break;
}
}
示例2: switch
void GuideManagerCore::clearHorizontals(GuideType type)
{
switch (type)
{
case Standard:
if (undoManager->undoEnabled())
{
for (int i = 0; i < horizontalStdG.count(); ++i)
{
SimpleState* ss = new SimpleState(Um::DelVGuide, 0, Um::IGuides);
ss->set("REMOVE_H", horizontalStdG[i]);
undoManager->action(m_page, ss);
}
}
horizontalStdG.clear();
break;
case Auto:
if (undoManager->undoEnabled())
{
SimpleState * ss = new SimpleState(Um::DelHAGuide, 0, Um::IGuides);
ss->set("REMOVE_HA_GAP", m_horizontalAutoGap);
ss->set("REMOVE_HA_COUNT", m_horizontalAutoCount);
ss->set("REMOVE_HA_REFER", m_horizontalAutoRefer);
undoManager->action(m_page, ss);
}
m_horizontalAutoGap = 0.0;
m_horizontalAutoCount= 0;
m_horizontalAutoRefer = 0;
horizontalAutoG.clear();
break;
}
}
示例3: UndoTransaction
void gtAction::writeUnstyled(const QString& text)
{
UndoTransaction* activeTransaction = NULL;
if (isFirstWrite)
{
if (!doAppend)
{
if (UndoManager::undoEnabled())
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ImportText, "", Um::IDelete));
if (it->nextInChain() != 0)
{
PageItem *nextItem = it->nextInChain();
while (nextItem != 0)
{
nextItem->itemText.selectAll();
nextItem->asTextFrame()->deleteSelectedTextFromFrame();
nextItem = nextItem->nextInChain();
}
}
it->itemText.selectAll();
it->asTextFrame()->deleteSelectedTextFromFrame();
}
}
QChar ch0(0), ch5(5), ch10(10), ch13(13);
QString textStr = text;
textStr.remove(ch0);
textStr.remove(ch13);
textStr.replace(ch10,ch13);
textStr.replace(ch5,ch13);
textStr.replace(QString(0x2028),SpecialChars::LINEBREAK);
textStr.replace(QString(0x2029),SpecialChars::PARSEP);
int pos = it->itemText.length();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::AppendText,"",Um::ICreate);
ss->set("INSERT_FRAMETEXT", "insert_frametext");
ss->set("TEXT_STR",textStr);
ss->set("START", pos);
undoManager->action(it, ss);
}
it->itemText.insertChars(pos, textStr);
lastCharWasLineChange = text.right(1) == "\n";
isFirstWrite = false;
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
示例4: SimpleState
void CanvasMode_EditSpiral::applyValues(double start, double end, double factor)
{
PageItem *currItem = m_doc->m_Selection->itemAt(0);
PageItem_Spiral *item = currItem->asSpiral();
SimpleState *ss = new SimpleState(Um::EditSpiral, "", Um::IPolygon);
ss->set("SPIRAL","spiral");
ss->set("OLD_START",item->spiralStartAngle);
ss->set("OLD_END",item->spiralEndAngle);
ss->set("OLD_FACTOR",item->spiralFactor);
item->spiralStartAngle = computeRealAngle(start, true);
item->spiralEndAngle = computeRealAngle(end, true);
item->spiralFactor = factor;
ss->set("NEW_START",item->spiralStartAngle);
ss->set("NEW_END",item->spiralEndAngle);
ss->set("NEW_FACTOR",item->spiralFactor);
undoManager->action(item,ss);
item->recalcPath();
m_startPoint = currItem->PoLine.pointQF(0);
m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
m_startAngle = item->spiralStartAngle;
m_endAngle = item->spiralEndAngle;
QTransform itemMatrix = currItem->getTransform();
m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
}
示例5: while
void gtAction::writeUnstyled(const QString& text, bool isNote)
{
UndoTransaction activeTransaction;
if (isFirstWrite && it->itemText.length() > 0)
{
if (!doAppend)
{
if (UndoManager::undoEnabled())
activeTransaction = undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ImportText, "", Um::IDelete);
if (it->nextInChain() != 0)
{
PageItem *nextItem = it->nextInChain();
while (nextItem != 0)
{
nextItem->itemText.selectAll();
nextItem->asTextFrame()->deleteSelectedTextFromFrame();
nextItem = nextItem->nextInChain();
}
}
it->itemText.selectAll();
it->asTextFrame()->deleteSelectedTextFromFrame();
}
}
QChar ch0(0), ch5(5), ch10(10), ch13(13);
QString textStr = text;
textStr.remove(ch0);
textStr.remove(ch13);
textStr.replace(ch10,ch13);
textStr.replace(ch5,ch13);
textStr.replace(QString(0x2028),SpecialChars::LINEBREAK);
textStr.replace(QString(0x2029),SpecialChars::PARSEP);
if (isNote)
{
if (note == NULL)
{
note = it->m_Doc->newNote(it->m_Doc->m_docNotesStylesList.at(0));
Q_ASSERT(noteStory == NULL);
noteStory = new StoryText(it->m_Doc);
}
if (textStr == SpecialChars::OBJECT)
{
NotesStyle* nStyle = note->notesStyle();
QString label = "NoteMark_" + nStyle->name();
if (nStyle->range() == NSRsection)
label += " in section " + it->m_Doc->getSectionNameForPageIndex(it->OwnPage) + " page " + QString::number(it->OwnPage +1);
else if (nStyle->range() == NSRpage)
label += " on page " + QString::number(it->OwnPage +1);
else if (nStyle->range() == NSRstory)
label += " in " + it->firstInChain()->itemName();
else if (nStyle->range() == NSRframe)
label += " in frame" + it->itemName();
if (it->m_Doc->getMark(label + "_1", MARKNoteMasterType) != NULL)
getUniqueName(label,it->m_Doc->marksLabelsList(MARKNoteMasterType), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
else
label = label + "_1";
Mark* mrk = it->m_Doc->newMark();
mrk->label = label;
mrk->setType(MARKNoteMasterType);
mrk->setNotePtr(note);
note->setMasterMark(mrk);
if (noteStory->text(noteStory->length() -1) == SpecialChars::PARSEP)
noteStory->removeChars(noteStory->length() -1, 1);
note->setSaxedText(saxedText(noteStory));
mrk->setString("");
mrk->OwnPage = it->OwnPage;
it->itemText.insertMark(mrk);
if (UndoManager::undoEnabled())
{
ScItemsState* is = new ScItemsState(UndoManager::InsertNote);
is->set("ETEA", mrk->label);
is->set("MARK", QString("new"));
is->set("label", mrk->label);
is->set("type", (int) MARKNoteMasterType);
is->set("strtxt", QString(""));
is->set("nStyle", nStyle->name());
is->set("at", it->itemText.cursorPosition() -1);
is->insertItem("inItem", it);
undoManager->action(it->m_Doc, is);
}
note = NULL;
delete noteStory;
}
else
noteStory->insertChars(noteStory->length(), textStr);
}
else
{
int pos = it->itemText.length();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::AppendText,"",Um::ICreate);
ss->set("INSERT_FRAMETEXT", "insert_frametext");
ss->set("TEXT_STR",textStr);
ss->set("START", pos);
undoManager->action(it, ss);
}
it->itemText.insertChars(pos, textStr);
}
lastCharWasLineChange = text.right(1) == "\n";
//.........这里部分代码省略.........
示例6: restore
void ScPage::restore(UndoState* state, bool isUndo)
{
SimpleState* ss = dynamic_cast<SimpleState*>(state);
if (ss)
{
// int stateCode = ss->transactionCode;
if (ss->contains("ADD_V"))
{
double position = ss->getDouble("ADD_V");
if (isUndo)
guides.deleteVertical(position, GuideManagerCore::Standard);//removeXGuide(position);
else
guides.addVertical(position, GuideManagerCore::Standard);//addXGuide(position);
m_Doc->scMW()->guidePalette->setupGui();
}
else if (ss->contains("ADD_H"))
{
double position = ss->getDouble("ADD_H");
if (isUndo)
guides.deleteHorizontal(position, GuideManagerCore::Standard);//removeYGuide(position);
else
guides.addHorizontal(position, GuideManagerCore::Standard);//addYGuide(position);
m_Doc->scMW()->guidePalette->setupGui();
}
else if (ss->contains("REMOVE_V"))
{
double position = ss->getDouble("REMOVE_V");
if (isUndo)
guides.addVertical(position, GuideManagerCore::Standard);//addXGuide(position);
else
guides.deleteVertical(position, GuideManagerCore::Standard);//removeXGuide(position);
m_Doc->scMW()->guidePalette->setupGui();
}
else if (ss->contains("REMOVE_H"))
{
double position = ss->getDouble("REMOVE_H");
if (isUndo)
guides.addHorizontal(position, GuideManagerCore::Standard);//addYGuide(position);
else
guides.deleteHorizontal(position, GuideManagerCore::Standard);//removeYGuide(position);
m_Doc->scMW()->guidePalette->setupGui();
}
else if (ss->contains("MOVE_H_FROM"))
{
double from = ss->getDouble("MOVE_H_FROM");
double to = ss->getDouble("MOVE_H_TO");
if (isUndo)
{
guides.deleteHorizontal(to, GuideManagerCore::Standard);//removeYGuide(position);
guides.addHorizontal(from, GuideManagerCore::Standard);//addYGuide(position);
}
else
{
guides.deleteHorizontal(from, GuideManagerCore::Standard);//removeYGuide(position);
guides.addHorizontal(to, GuideManagerCore::Standard);//addYGuide(position);
}
m_Doc->scMW()->guidePalette->setupGui();
}
else if (ss->contains("MOVE_V_FROM"))
{
double from = ss->getDouble("MOVE_V_FROM");
double to = ss->getDouble("MOVE_V_TO");
if (isUndo)
{
guides.deleteVertical(to, GuideManagerCore::Standard);//removeXGuide(position);
guides.addVertical(from, GuideManagerCore::Standard);//removeXGuide(position);
}
else
{
guides.deleteVertical(from, GuideManagerCore::Standard);//removeXGuide(position);
guides.addVertical(to, GuideManagerCore::Standard);//removeXGuide(position);
}
m_Doc->scMW()->guidePalette->setupGui();
}
// automatic guides
else if (ss->contains("REMOVE_HA_GAP"))
{
if (isUndo)
{
guides.setHorizontalAutoCount(ss->getInt("REMOVE_HA_COUNT"));
guides.setHorizontalAutoGap(ss->getDouble("REMOVE_HA_GAP"));
guides.setHorizontalAutoRefer(ss->getInt("REMOVE_HA_REFER"));
}
else
{
guides.setHorizontalAutoCount(0);
guides.setHorizontalAutoGap(0.0);
guides.setHorizontalAutoRefer(0);
}
m_Doc->scMW()->guidePalette->setupGui();
}
else if (ss->contains("REMOVE_VA_GAP"))
{
if (isUndo)
{
guides.setVerticalAutoCount(ss->getInt("REMOVE_VA_COUNT"));
guides.setVerticalAutoGap(ss->getDouble("REMOVE_VA_GAP"));
guides.setVerticalAutoRefer(ss->getInt("REMOVE_VA_REFER"));
}
else
//.........这里部分代码省略.........
示例7: SimpleState
void CanvasMode_EditPolygon::applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur)
{
PageItem *currItem = m_doc->m_Selection->itemAt(0);
PageItem_RegularPolygon* item = currItem->asRegularPolygon();
QRectF oldRect = item->getBoundingRect();
polyCorners = polyC;
polyFactor = polyF;
polyRotation = polyR;
polyCurvature = polyCur;
polyInnerRot = polyIRot;
polyOuterCurvature = polyOCur;
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::EditPolygon,"",Um::IPolygon);
ss->set("POLYGON","polygon");
ss->set("NEW_CORNER",polyC);
ss->set("NEW_USEFACTOR",polyUseCF);
ss->set("NEW_FACTOR",polyFactor);
ss->set("NEW_ROTATION",polyRotation);
ss->set("NEW_CURV",polyCurvature);
ss->set("NEW_INNER",polyInnerRot);
ss->set("NEW_OUTER",polyOuterCurvature);
ss->set("OLD_CORNER",item->polyCorners);
ss->set("OLD_USEFACTOR",item->polyUseFactor);
ss->set("OLD_FACTOR",item->polyFactor);
ss->set("OLD_ROTATION",item->polyRotation);
ss->set("OLD_CURV",item->polyCurvature);
ss->set("OLD_INNER",item->polyInnerRot);
ss->set("OLD_OUTER",item->polyOuterCurvature);
undoManager->action(currItem,ss);
}
item->polyCorners = polyC;
item->polyUseFactor = polyUseCF;
item->polyFactor = polyFactor;
item->polyRotation = polyRotation;
item->polyCurvature = polyCurvature;
item->polyInnerRot = polyInnerRot;
item->polyOuterCurvature = polyOuterCurvature;
item->recalcPath();
updateFromItem();
QTransform itemMatrix = currItem->getTransform();
QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
QRectF updateRect = oldRect.united(path.boundingRect());
m_doc->regionsChanged()->update(updateRect.adjusted(-5, -5, 10, 10));
}
示例8: update
virtual void update()override
{
for (auto& uni : m_units)
{
uni.update();
}
switch (m_state.m_state)
{
case 0:
{
const bool finish = AllOf(m_units, [](const BossUnitBase& unit){ return unit.m_shot->isFinished(); });
if (finish)
{
m_state.nextState(120);
}
break;
}
case 1:
if (m_state.isFinished())
{
m_isFinish = true;
}
break;
case 2:
break;
default:
break;
}
m_state.update();
}
示例9: update
void update()
{
const double progressRate = Saturate(1.0*m_state.m_timer / (1.0*m_state.m_stateLimit));
const Vec2 focusPos = Vec2(3904, 4082);
switch (m_state.m_state)
{
case 0:
D2Camera::I()->m_pos = EaseInOut(m_startPos, focusPos, Easing::Cubic, progressRate);
m_state.checkTimerAndGoNextState(150);
break;
case 1:
D2Camera::I()->m_pos = focusPos;
m_state.checkTimerAndGoNextState(60);
break;
case 2:
D2Camera::I()->m_pos = EaseInOut(focusPos, m_startPos, Easing::Cubic, progressRate);
m_state.checkTimerAndGoNextState(60);
break;
case 3:
break;
}
m_state.update();
}