本文整理汇总了C++中gui::Document类的典型用法代码示例。如果您正苦于以下问题:C++ Document类的具体用法?C++ Document怎么用?C++ Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Document类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: onButtonFace
void TaskPadParameters::onButtonFace(const bool pressed) {
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
Part::Feature* support = pcPad->getSupport();
if (support == NULL) {
// There is no support, so we can't select from it...
return;
}
if (pressed) {
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
doc->setHide(PadView->getObject()->getNameInDocument());
doc->setShow(support->getNameInDocument());
}
Gui::Selection().clearSelection();
Gui::Selection().addSelectionGate
(new ReferenceSelection(support, false, true, false));
} else {
Gui::Selection().rmvSelectionGate();
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
doc->setShow(PadView->getObject()->getNameInDocument());
doc->setHide(support->getNameInDocument());
}
}
// Update button if onButtonFace() is called explicitly
ui->buttonFace->setChecked(pressed);
}
开发者ID:microelly2,项目名称:FreeCAD,代码行数:29,代码来源:TaskPadParameters.cpp
示例2: findShapes
void DlgExtrusion::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
this->document = activeDoc->getName();
this->label = activeDoc->Label.getValue();
std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType
(Part::Feature::getClassTypeId());
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
if (canExtrude(shape)) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, QString::fromUtf8((*it)->Label.getValue()));
item->setData(0, Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument()));
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
if (vp)
item->setIcon(0, vp->getIcon());
}
}
}
开发者ID:KimK,项目名称:FreeCAD,代码行数:22,代码来源:DlgExtrusion.cpp
示例3: activated
void CmdPointsPolyCut::activated(int iMsg)
{
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end(); ++it) {
if (it == docObj.begin()) {
Gui::Document* doc = getActiveGuiDocument();
Gui::MDIView* view = doc->getActiveView();
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
viewer->setEditing(true);
viewer->startSelection(Gui::View3DInventorViewer::Lasso);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), PointsGui::ViewProviderPoints::clipPointsCallback);
}
else {
return;
}
}
Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider( *it );
pVP->startEditing();
}
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:22,代码来源:Command.cpp
示例4: activated
void StdCmdDelete::activated(int iMsg)
{
// go through all documents
const SelectionSingleton& rSel = Selection();
const std::vector<App::Document*> docs = App::GetApplication().getDocuments();
for (std::vector<App::Document*>::const_iterator it = docs.begin(); it != docs.end(); ++it) {
Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(*it);
std::vector<Gui::SelectionObject> sel = rSel.getSelectionEx((*it)->getName());
if (!sel.empty()) {
(*it)->openTransaction("Delete");
for (std::vector<Gui::SelectionObject>::iterator ft = sel.begin(); ft != sel.end(); ++ft) {
Gui::ViewProvider* vp = pGuiDoc->getViewProvider(ft->getObject());
if (vp) {
// ask the ViewProvider if its want to do some clean up
if (vp->onDelete(ft->getSubNames()))
doCommand(Doc,"App.getDocument(\"%s\").removeObject(\"%s\")"
,(*it)->getName(), ft->getFeatName());
}
}
(*it)->commitTransaction();
}
}
}
开发者ID:pedrocalderon,项目名称:FreeCAD_sf_master,代码行数:23,代码来源:CommandDoc.cpp
示例5: interactiveFilletArc
Py::Object interactiveFilletArc(const Py::Tuple& args)
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
SoSeparator* scene = static_cast<SoSeparator*>(viewer->getSceneGraph());
SoSeparator* node = new SoSeparator();
SoBaseColor* rgb = new SoBaseColor();
rgb->rgb.setValue(1,1,0);
node->addChild(rgb);
SoCoordinate3* coords = new SoCoordinate3();
node->addChild(coords);
node->addChild(new SoLineSet());
scene->addChild(node);
ObjectObserver* obs = new ObjectObserver(doc->getDocument()->getActiveObject(), coords);
obs->attachDocument(doc->getDocument());
}
}
return Py::None();
}
开发者ID:neuroidss,项目名称:FreeCAD,代码行数:23,代码来源:AppSandboxGui.cpp
示例6: activated
void CmdFemDefineNodesSet::activated(int iMsg)
{
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId());
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end(); ++it) {
if (it == docObj.begin()) {
Gui::Document* doc = getActiveGuiDocument();
Gui::MDIView* view = doc->getActiveView();
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
viewer->setEditing(true);
viewer->startSelection(Gui::View3DInventorViewer::Clip);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback);
}
else {
return;
}
}
//Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider(*it);
//if (pVP->isVisible())
// pVP->startEditing();
}
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:24,代码来源:Command.cpp
示例7: revertTransformation
void Placement::revertTransformation()
{
for (std::set<std::string>::iterator it = documents.begin(); it != documents.end(); ++it) {
Gui::Document* document = Application::Instance->getDocument(it->c_str());
if (!document) continue;
std::vector<App::DocumentObject*> obj = document->getDocument()->
getObjectsOfType(App::DocumentObject::getClassTypeId());
if (!obj.empty()) {
for (std::vector<App::DocumentObject*>::iterator it=obj.begin();it!=obj.end();++it) {
std::map<std::string,App::Property*> props;
(*it)->getPropertyMap(props);
// search for the placement property
std::map<std::string,App::Property*>::iterator jt;
jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName));
if (jt != props.end()) {
Base::Placement cur = static_cast<App::PropertyPlacement*>(jt->second)->getValue();
Gui::ViewProvider* vp = document->getViewProvider(*it);
if (vp) vp->setTransformation(cur.toMatrix());
}
}
}
}
}
开发者ID:aromis,项目名称:FreeCAD_sf_master,代码行数:24,代码来源:Placement.cpp
示例8: on_repairDuplicatedPointsButton_clicked
void DlgEvaluateMeshImp::on_repairDuplicatedPointsButton_clicked()
{
if (d->meshFeature) {
const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument());
const char* objName = d->meshFeature->getNameInDocument();
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Remove duplicated points");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()"
, docName, objName);
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Duplicated points"), QString::fromLatin1(e.what()));
}
doc->commitCommand();
doc->getDocument()->recompute();
repairDuplicatedPointsButton->setEnabled(false);
checkDuplicatedPointsButton->setChecked(false);
removeViewProvider("MeshGui::ViewProviderMeshDuplicatedPoints");
}
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:24,代码来源:DlgEvaluateMeshImp.cpp
示例9: activated
void CmdSketcherLeaveSketch::activated(int iMsg)
{
Gui::Document *doc = getActiveGuiDocument();
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
if (vp && vp->getSketchMode() != ViewProviderSketch::STATUS_NONE)
vp->purgeHandler();
}
openCommand("Sketch changed");
doCommand(Gui,"Gui.activeDocument().resetEdit()");
doCommand(Doc,"App.ActiveDocument.recompute()");
commitCommand();
}
开发者ID:Freemydog,项目名称:FreeCAD,代码行数:17,代码来源:Command.cpp
示例10: onMsg
bool DrawingView::onMsg(const char* pMsg, const char** ppReturn)
{
if (strcmp("ViewFit",pMsg) == 0) {
viewAll();
return true;
}
else if (strcmp("Save",pMsg) == 0) {
Gui::Document *doc = getGuiDocument();
if (doc) {
doc->save();
return true;
}
}
else if (strcmp("SaveAs",pMsg) == 0) {
Gui::Document *doc = getGuiDocument();
if (doc) {
doc->saveAs();
return true;
}
}
else if(strcmp("Undo",pMsg) == 0 ) {
Gui::Document *doc = getGuiDocument();
if (doc) {
doc->undo(1);
return true;
}
}
else if(strcmp("Redo",pMsg) == 0 ) {
Gui::Document *doc = getGuiDocument();
if (doc) {
doc->redo(1);
return true;
}
}
return false;
}
开发者ID:5263,项目名称:FreeCAD,代码行数:36,代码来源:DrawingView.cpp
示例11: accept
bool SweepWidget::accept()
{
if (d->loop.isRunning())
return false;
Gui::SelectionFilter edgeFilter ("SELECT Part::Feature SUBELEMENT Edge COUNT 1..");
Gui::SelectionFilter partFilter ("SELECT Part::Feature COUNT 1");
bool matchEdge = edgeFilter.match();
bool matchPart = partFilter.match();
if (!matchEdge && !matchPart) {
QMessageBox::critical(this, tr("Sweep path"), tr("Select one or more connected edges you want to sweep along."));
return false;
}
// get the selected object
std::string selection;
std::string spineObject, spineLabel;
const std::vector<Gui::SelectionObject>& result = matchEdge
? edgeFilter.Result[0] : partFilter.Result[0];
selection = result.front().getAsPropertyLinkSubString();
spineObject = result.front().getFeatName();
spineLabel = result.front().getObject()->Label.getValue();
QString list, solid, frenet;
if (d->ui.checkSolid->isChecked())
solid = QString::fromLatin1("True");
else
solid = QString::fromLatin1("False");
if (d->ui.checkFrenet->isChecked())
frenet = QString::fromLatin1("True");
else
frenet = QString::fromLatin1("False");
QTextStream str(&list);
int count = d->ui.selector->selectedTreeWidget()->topLevelItemCount();
if (count < 1) {
QMessageBox::critical(this, tr("Too few elements"), tr("At least one edge or wire is required."));
return false;
}
for (int i=0; i<count; i++) {
QTreeWidgetItem* child = d->ui.selector->selectedTreeWidget()->topLevelItem(i);
QString name = child->data(0, Qt::UserRole).toString();
if (name == QLatin1String(spineObject.c_str())) {
QMessageBox::critical(this, tr("Wrong selection"), tr("'%1' cannot be used as profile and path.")
.arg(QString::fromUtf8(spineLabel.c_str())));
return false;
}
str << "App.getDocument('" << d->document.c_str() << "')." << name << ", ";
}
try {
Gui::WaitCursor wc;
QString cmd;
cmd = QString::fromLatin1(
"App.getDocument('%5').addObject('Part::Sweep','Sweep')\n"
"App.getDocument('%5').ActiveObject.Sections=[%1]\n"
"App.getDocument('%5').ActiveObject.Spine=%2\n"
"App.getDocument('%5').ActiveObject.Solid=%3\n"
"App.getDocument('%5').ActiveObject.Frenet=%4\n"
)
.arg(list)
.arg(QLatin1String(selection.c_str()))
.arg(solid)
.arg(frenet)
.arg(QString::fromLatin1(d->document.c_str()));
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
if (!doc) throw Base::Exception("Document doesn't exist anymore");
doc->openCommand("Sweep");
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
doc->getDocument()->recompute();
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
if (obj && !obj->isValid()) {
std::string msg = obj->getStatusString();
doc->abortCommand();
throw Base::Exception(msg);
}
doc->commitCommand();
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Input error"), QString::fromLatin1(e.what()));
return false;
}
return true;
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:87,代码来源:TaskSweep.cpp
示例12: QDialog
/**
* Constructs a VisualInspection as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
VisualInspection::VisualInspection(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl), ui(new Ui_VisualInspection)
{
ui->setupUi(this);
connect(ui->treeWidgetActual, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
this, SLOT(onActivateItem(QTreeWidgetItem*)));
connect(ui->treeWidgetNominal, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
this, SLOT(onActivateItem(QTreeWidgetItem*)));
connect(ui->buttonBox, SIGNAL(helpRequested()),
Gui::getMainWindow(), SLOT(whatsThis()));
//FIXME: Not used yet
ui->textLabel2->hide();
ui->thickness->hide();
ui->searchRadius->setUnit(Base::Unit::Length);
ui->searchRadius->setRange(0, DBL_MAX);
ui->thickness->setUnit(Base::Unit::Length);
ui->thickness->setRange(0, DBL_MAX);
App::Document* doc = App::GetApplication().getActiveDocument();
// disable Ok button and enable of at least one item in each view is on
buttonOk = ui->buttonBox->button(QDialogButtonBox::Ok);
buttonOk->setDisabled(true);
if (!doc) {
ui->treeWidgetActual->setDisabled(true);
ui->treeWidgetNominal->setDisabled(true);
return;
}
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
std::vector<App::DocumentObject*> obj = doc->getObjects();
Base::Type point = Base::Type::fromName("Points::Feature");
Base::Type mesh = Base::Type::fromName("Mesh::Feature");
Base::Type shape = Base::Type::fromName("Part::Feature");
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(point) ||
(*it)->getTypeId().isDerivedFrom(mesh) ||
(*it)->getTypeId().isDerivedFrom(shape)) {
Gui::ViewProvider* view = gui->getViewProvider(*it);
QIcon px = view->getIcon();
SingleSelectionItem* item1 = new SingleSelectionItem(ui->treeWidgetActual);
item1->setText(0, QString::fromUtf8((*it)->Label.getValue()));
item1->setData(0, Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument()));
item1->setCheckState(0, Qt::Unchecked);
item1->setIcon(0, px);
SingleSelectionItem* item2 = new SingleSelectionItem(ui->treeWidgetNominal);
item2->setText(0, QString::fromUtf8((*it)->Label.getValue()));
item2->setData(0, Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument()));
item2->setCheckState(0, Qt::Unchecked);
item2->setIcon(0, px);
item1->setCompetitiveItem(item2);
item2->setCompetitiveItem(item1);
}
}
loadSettings();
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:65,代码来源:VisualInspection.cpp
示例13: slotActiveDocument
void Placement::slotActiveDocument(const Gui::Document& doc)
{
documents.insert(doc.getDocument()->getName());
}
开发者ID:aromis,项目名称:FreeCAD_sf_master,代码行数:4,代码来源:Placement.cpp
示例14: getViewOfNode
Gui::MDIView* ViewProviderDocumentObject::getViewOfNode(SoNode* node) const
{
App::Document* pAppDoc = pcObject->getDocument();
Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc);
return pGuiDoc->getViewOfNode(node);
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:6,代码来源:ViewProviderDocumentObject.cpp
示例15: getEditingView
Gui::MDIView* ViewProviderDocumentObject::getEditingView() const
{
App::Document* pAppDoc = pcObject->getDocument();
Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc);
return pGuiDoc->getEditingViewOfViewProvider(const_cast<ViewProviderDocumentObject*>(this));
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:6,代码来源:ViewProviderDocumentObject.cpp
示例16: onSelectionChanged
void PropertyView::onSelectionChanged(const SelectionChanges& msg)
{
if (msg.Type != SelectionChanges::AddSelection &&
msg.Type != SelectionChanges::RmvSelection &&
msg.Type != SelectionChanges::SetSelection &&
msg.Type != SelectionChanges::ClrSelection)
return;
// group the properties by <name,id>
std::map<std::pair<std::string, int>, std::vector<App::Property*> > propDataMap;
std::map<std::pair<std::string, int>, std::vector<App::Property*> > propViewMap;
std::vector<SelectionSingleton::SelObj> array = Gui::Selection().getCompleteSelection();
for (std::vector<SelectionSingleton::SelObj>::const_iterator it = array.begin(); it != array.end(); ++it) {
App::DocumentObject *ob=0;
ViewProvider *vp=0;
std::map<std::string,App::Property*> dataMap;
std::map<std::string,App::Property*> viewMap;
if ((*it).pObject) {
(*it).pObject->getPropertyMap(dataMap);
ob = (*it).pObject;
// get also the properties of the associated view provider
Gui::Document* doc = Gui::Application::Instance->getDocument(it->pDoc);
vp = doc->getViewProvider((*it).pObject);
if(!vp) continue;
vp->getPropertyMap(viewMap);
}
// store the properties with <name,id> as key in a map
std::map<std::string,App::Property*>::iterator pt;
if (ob) {
for (pt = dataMap.begin(); pt != dataMap.end(); ++pt) {
std::pair<std::string, int> nameType = std::make_pair
<std::string, int>(pt->first, pt->second->getTypeId().getKey());
if (!ob->isHidden(pt->second) && !pt->second->StatusBits.test(3))
propDataMap[nameType].push_back(pt->second);
}
}
// the same for the view properties
if (vp) {
for(pt = viewMap.begin(); pt != viewMap.end(); ++pt) {
std::pair<std::string, int> nameType = std::make_pair
<std::string, int>( pt->first, pt->second->getTypeId().getKey());
if (!vp->isHidden(pt->second) && !pt->second->StatusBits.test(3))
propViewMap[nameType].push_back(pt->second);
}
}
}
// the property must be part of each selected object, i.e. the number
// of selected objects is equal to the number of properties with same
// name and id
std::map<std::pair<std::string, int>, std::vector<App::Property*> >
::const_iterator it;
std::map<std::string, std::vector<App::Property*> > dataProps;
for (it = propDataMap.begin(); it != propDataMap.end(); ++it) {
if (it->second.size() == array.size()) {
dataProps[it->first.first] = it->second;
}
}
propertyEditorData->buildUp(dataProps);
std::map<std::string, std::vector<App::Property*> > viewProps;
for (it = propViewMap.begin(); it != propViewMap.end(); ++it) {
if (it->second.size() == array.size()) {
viewProps[it->first.first] = it->second;
}
}
propertyEditorView->buildUp(viewProps);
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:70,代码来源:PropertyView.cpp
示例17: accept
void VisualInspection::accept()
{
onActivateItem(0);
if (buttonOk->isEnabled()) {
QDialog::accept();
saveSettings();
// collect all nominal geometries
QStringList nominalNames;
for (QTreeWidgetItemIterator it(ui->treeWidgetNominal); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked)
nominalNames << sel->data(0, Qt::UserRole).toString();
}
double searchRadius = ui->searchRadius->value().getValue();
double thickness = ui->thickness->value().getValue();
// open a new command
Gui::Document* doc = Gui::Application::Instance->activeDocument();
doc->openCommand("Visual Inspection");
// create a group
Gui::Command::runCommand(
Gui::Command::App, "App_activeDocument___InspectionGroup=App.ActiveDocument.addObject(\"Inspection::Group\",\"Inspection\")");
// for each actual geometry create an inspection feature
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
QString actualName = sel->data(0, Qt::UserRole).toString();
Gui::Command::doCommand(Gui::Command::App,
"App_activeDocument___InspectionGroup.newObject(\"Inspection::Feature\",\"%s_Inspect\")", (const char*)actualName.toLatin1());
Gui::Command::doCommand(Gui::Command::App,
"App.ActiveDocument.ActiveObject.Actual=App.ActiveDocument.%s\n"
"App_activeDocument___activeObject___Nominals=list()\n"
"App.ActiveDocument.ActiveObject.SearchRadius=%.3f\n"
"App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toLatin1(), searchRadius, thickness);
for (QStringList::Iterator it = nominalNames.begin(); it != nominalNames.end(); ++it) {
Gui::Command::doCommand(Gui::Command::App,
"App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toLatin1());
}
Gui::Command::doCommand(Gui::Command::App,
"App.ActiveDocument.ActiveObject.Nominals=App_activeDocument___activeObject___Nominals\n"
"del App_activeDocument___activeObject___Nominals\n");
}
}
Gui::Command::runCommand(Gui::Command::App,
"del App_activeDocument___InspectionGroup\n");
doc->commitCommand();
doc->getDocument()->recompute();
// hide the checked features
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
Gui::Command::doCommand(Gui::Command::App
, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
}
}
for (QTreeWidgetItemIterator it(ui->treeWidgetNominal); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
Gui::Command::doCommand(Gui::Command::App
, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
}
}
}
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:74,代码来源:VisualInspection.cpp
示例18: activated
void CmdPartDesignBody::activated(int iMsg)
{
Q_UNUSED(iMsg);
if ( !PartDesignGui::assureModernWorkflow( getDocument() ) )
return;
App::Part *actPart = PartDesignGui::getActivePart ();
App::Part* partOfBaseFeature = nullptr;
std::vector<App::DocumentObject*> features =
getSelection().getObjectsOfType(Part::Feature::getClassTypeId());
App::DocumentObject* baseFeature = nullptr;
bool viewAll = features.empty();
if (!features.empty()) {
if (features.size() == 1) {
baseFeature = features[0];
if ( baseFeature->isDerivedFrom ( PartDesign::Feature::getClassTypeId() ) &&
PartDesign::Body::findBodyOf ( baseFeature ) ) {
// Prevent creating bodies based on features already belonging to other bodies
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Body can't be based on a PartDesign feature."));
baseFeature = nullptr;
}
else if (PartDesign::Body::findBodyOf ( baseFeature )){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("%1 already belongs to a body, can't use it as base feature for another body.")
.arg(QString::fromUtf8(baseFeature->Label.getValue())));
baseFeature = nullptr;
}
else if ( baseFeature->isDerivedFrom ( Part::BodyBase::getClassTypeId() ) ) {
// Prevent creating bodies based on bodies
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Body can't be based on another body."));
baseFeature = nullptr;
}
else {
partOfBaseFeature = App::Part::getPartOfObject(baseFeature);
if (partOfBaseFeature != 0 && partOfBaseFeature != actPart){
//prevent cross-part mess
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Base feature (%1) belongs to other part.")
.arg(QString::fromUtf8(baseFeature->Label.getValue())));
baseFeature = nullptr;
};
}
} else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Bad base feature"),
QObject::tr("Body may be based no more than on one feature."));
return;
}
}
openCommand("Add a Body");
std::string bodyName = getUniqueObjectName("Body");
// add the Body feature itself, and make it active
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')", bodyName.c_str());
if (baseFeature) {
if (partOfBaseFeature){
//withdraw base feature from Part, otherwise visibility mandess results
doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)",
partOfBaseFeature->getNameInDocument(), baseFeature->getNameInDocument());
}
doCommand(Doc,"App.activeDocument().%s.BaseFeature = App.activeDocument().%s",
bodyName.c_str(), baseFeature->getNameInDocument());
}
addModule(Gui,"PartDesignGui"); // import the Gui module only once a session
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)",
PDBODYKEY, bodyName.c_str());
// Make the "Create sketch" prompt appear in the task panel
doCommand(Gui,"Gui.Selection.clearSelection()");
doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", bodyName.c_str());
if (actPart) {
doCommand(Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)",
actPart->getNameInDocument(), bodyName.c_str());
}
// The method 'SoCamera::viewBoundingBox' is still declared as protected in Coin3d versions
// older than 4.0.
#if COIN_MAJOR_VERSION >= 4
// if no part feature was there then auto-adjust the camera
if (viewAll) {
Gui::Document* doc = Gui::Application::Instance->getDocument(getDocument());
Gui::View3DInventor* view = doc ? qobject_cast<Gui::View3DInventor*>(doc->getActiveView()) : nullptr;
if (view) {
SoCamera* camera = view->getViewer()->getCamera();
SbViewportRegion vpregion = view->getViewer()->getViewportRegion();
float aspectratio = vpregion.getViewportAspectRatio();
float size = Gui::ViewProviderOrigin::defaultSize();
SbBox3f bbox;
bbox.setBounds(-size,-size,-size,size,size,size);
camera->viewBoundingBox(bbox, aspectratio, 1.0f);
}
}
//.........这里部分代码省略.........
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:101,代码来源:CommandBody.cpp
示例19: slotActiveDocument
void Workbench::slotActiveDocument(const Gui::Document& Doc)
{
switchToDocument(Doc.getDocument());
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:4,代码来源:Workbench.cpp
示例20: updateOriginDatumSize
void ViewProviderBody::updateOriginDatumSize () {
PartDesign::Body *body = static_cast<PartDesign::Body *> ( getObject() );
// Use different bounding boxes for datums and for origins:
Gui::Document* gdoc = Gui::Application::Instance->getDocument(getObject()->getDocument());
if(!gdoc)
return;
Gui::MDIView* view = gdoc->getViewOfViewProvider(this);
if(!view)
return;
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());
const auto & model = body->getFullModel ();
// BBox for Datums is calculated from all visible objects but treating datums as their basepoints only
SbBox3f bboxDatums = ViewProviderDatum::getRelevantBoundBox ( bboxAction, model );
// BBox for origin should take into account datums size also
SbBox3f bboxOrigins = bboxDatums;
for(App::DocumentObject* obj : model) {
if ( obj->isDerivedFrom ( Part::Datum::getClassTypeId () ) ) {
ViewProvider *vp = Gui::Application::Instance->getViewProvider(obj);
if (!vp) { continue; }
ViewProviderDatum *vpDatum = static_cast <ViewProviderDatum *> (vp) ;
vpDatum->setExtents ( bboxDatums );
bboxAction.apply ( vp->getRoot () );
bboxOrigins.extendBy ( bboxAction.getBoundingBox () );
}
}
// get the bounding box values
SbVec3f max = bboxOrigins.getMax();
SbVec3f min = bboxOrigins.getMin();
// obtain an Origin and it's ViewProvider
App::Origin* origin = 0;
Gui::ViewProviderOrigin* vpOrigin = 0;
try {
origin = body->getOrigin ();
assert (origin);
Gui::ViewProvider *vp = Gui::Application::Instance->getViewProvider(origin);
if (!vp) {
throw Base::Exception ("No view provider linked to the Origin");
}
assert ( vp->isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) );
vpOrigin = static_cast <Gui::ViewProviderOrigin *> ( vp );
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what() );
return;
}
// calculate the desired origin size
Base::Vector3d size;
for (uint_fast8_t i=0; i<3; i++) {
size[i] = std::max ( fabs ( max[i] ), fabs ( min[i] ) );
if (size[i] < Precision::Confusion() ) {
size[i] = Gui::ViewProviderOrigin::defaultSize();
}
}
vpOrigin->Size.setValue ( size*1.2 );
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:70,代码来源:ViewProviderBody.cpp
注:本文中的gui::Document类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论