本文整理汇总了C++中app::DocumentObject::getOutList方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject::getOutList方法的具体用法?C++ DocumentObject::getOutList怎么用?C++ DocumentObject::getOutList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::DocumentObject
的用法示例。
在下文中一共展示了DocumentObject::getOutList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activated
void CmdSketcherMapSketch::activated(int iMsg)
{
QString msg_str;
try{
Attacher::eMapMode suggMapMode;
std::vector<Attacher::eMapMode> validModes;
//check that selection is valid for at least some mapping mode.
Attacher::SuggestResult::eSuggestResult msgid = Attacher::SuggestResult::srOK;
suggMapMode = SuggestAutoMapMode(&msgid, &msg_str, &validModes);
App::Document* doc = App::GetApplication().getActiveDocument();
std::vector<App::DocumentObject*> sketches = doc->getObjectsOfType(Part::Part2DObject::getClassTypeId());
if (sketches.empty()) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate(className(), "No sketch found"),
qApp->translate(className(), "The document doesn't have a sketch"));
return;
}
bool ok;
QStringList items;
for (std::vector<App::DocumentObject*>::iterator it = sketches.begin(); it != sketches.end(); ++it)
items.push_back(QString::fromUtf8((*it)->Label.getValue()));
QString text = QInputDialog::getItem(Gui::getMainWindow(),
qApp->translate(className(), "Select sketch"),
qApp->translate(className(), "Select a sketch from the list"),
items, 0, false, &ok);
if (!ok) return;
int index = items.indexOf(text);
Part2DObject &sketch = *(static_cast<Part2DObject*>(sketches[index]));
// check circular dependency
std::vector<Gui::SelectionObject> selobjs = Gui::Selection().getSelectionEx();
for (size_t i = 0 ; i < selobjs.size() ; ++i){
App::DocumentObject* part = static_cast<Part::Feature*>(selobjs[i].getObject());
if (!part) {
assert(0);
throw Base::Exception("Unexpected null pointer in CmdSketcherMapSketch::activated");
}
std::vector<App::DocumentObject*> input = part->getOutList();
if (std::find(input.begin(), input.end(), &sketch) != input.end()) {
throw ExceptionWrongInput(QT_TR_NOOP("Some of the selected objects depend on the sketch to be mapped. Circular dependencies are not allowed!"));
}
}
//Ask for a new mode.
//outline:
// * find out the modes that are compatible with selection.
// * Test if current mode is OK.
// * fill in the dialog
// * execute the dialog
// * collect dialog result
// * action
bool bAttach = true;
bool bCurIncompatible = false;
// * find out the modes that are compatible with selection.
eMapMode curMapMode = eMapMode(sketch.MapMode.getValue());
// * Test if current mode is OK.
if (std::find(validModes.begin(), validModes.end(), curMapMode) == validModes.end())
bCurIncompatible = true;
// * fill in the dialog
validModes.insert(validModes.begin(), Attacher::mmDeactivated);
if(bCurIncompatible)
validModes.push_back(curMapMode);
//bool ok; //already defined
//QStringList items; //already defined
items.clear();
items.push_back(QObject::tr("Don't attach"));
int iSugg = 0;//index of the auto-suggested mode in the list of valid modes
int iCurr = 0;//index of current mode in the list of valid modes
for (size_t i = 0 ; i < validModes.size() ; ++i){
items.push_back(QString::fromLatin1(AttachEngine::getModeName(validModes[i]).c_str()));
if (validModes[i] == curMapMode) {
iCurr = items.size() - 1;
items.back().append(bCurIncompatible?
qApp->translate(className()," (incompatible with selection)")
:
qApp->translate(className()," (current)") );
}
if (validModes[i] == suggMapMode){
iSugg = items.size() - 1;
if(iSugg == 1){
iSugg = 0;//redirect deactivate to detach
} else {
items.back().append(qApp->translate(className()," (suggested)"));
}
}
}
// * execute the dialog
text = QInputDialog::getItem(Gui::getMainWindow()
,qApp->translate(className(), "Sketch attachment")
,bCurIncompatible?
qApp->translate(className(), "Current attachment mode is incompatible with the new selection. Select the method to attach this sketch to selected objects.")
:
qApp->translate(className(), "Select the method to attach this sketch to selected objects.")
,items
//.........这里部分代码省略.........