本文整理汇总了C++中gui::ViewProvider类的典型用法代码示例。如果您正苦于以下问题:C++ ViewProvider类的具体用法?C++ ViewProvider怎么用?C++ ViewProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: findShapes
void SweepWidget::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
d->document = activeDoc->getName();
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;
if (shape.ShapeType() == TopAbs_FACE ||
shape.ShapeType() == TopAbs_WIRE ||
shape.ShapeType() == TopAbs_EDGE ||
shape.ShapeType() == TopAbs_VERTEX) {
QString label = QString::fromUtf8((*it)->Label.getValue());
QString name = QString::fromAscii((*it)->getNameInDocument());
QTreeWidgetItem* child = new QTreeWidgetItem();
child->setText(0, label);
child->setToolTip(0, label);
child->setData(0, Qt::UserRole, name);
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
if (vp) child->setIcon(0, vp->getIcon());
d->ui.selector->availableTreeWidget()->addTopLevelItem(child);
}
}
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:30,代码来源:TaskSweep.cpp
示例2: applyColors
void applyColors(Part::Feature* part, const std::vector<App::Color>& colors)
{
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) {
static_cast<PartGui::ViewProviderPartExt*>(vp)->DiffuseColor.setValues(colors);
}
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:7,代码来源:AppImportGuiPy.cpp
示例3: addRootObjectsToGroup
void Document::addRootObjectsToGroup(const std::vector<App::DocumentObject*>& obj, App::DocumentObjectGroup* grp)
{
std::map<App::DocumentObject*, bool> rootMap;
for (std::vector<App::DocumentObject*>::const_iterator it = obj.begin(); it != obj.end(); ++it) {
rootMap[*it] = true;
}
// get the view providers and check which objects are children
for (std::vector<App::DocumentObject*>::const_iterator it = obj.begin(); it != obj.end(); ++it) {
Gui::ViewProvider* vp = getViewProvider(*it);
if (vp) {
std::vector<App::DocumentObject*> child = vp->claimChildren();
for (std::vector<App::DocumentObject*>::iterator jt = child.begin(); jt != child.end(); ++jt) {
std::map<App::DocumentObject*, bool>::iterator kt = rootMap.find(*jt);
if (kt != rootMap.end()) {
kt->second = false;
}
}
}
}
// all objects that are not children of other objects can be added to the group
for (std::map<App::DocumentObject*, bool>::iterator it = rootMap.begin(); it != rootMap.end(); ++it) {
if (it->second)
grp->addObject(it->first);
}
}
开发者ID:microelly2,项目名称:FreeCAD,代码行数:26,代码来源:Document.cpp
示例4: applyPlacement
void Placement::applyPlacement(const Base::Placement& p, bool incremental)
{
Gui::Document* document = Application::Instance->activeDocument();
if (!document) return;
std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType
(App::DocumentObject::getClassTypeId(), document->getDocument()->getName());
if (!sel.empty()) {
// apply transformation only on view matrix not on placement property
for (std::vector<App::DocumentObject*>::iterator it=sel.begin();it!=sel.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();
if (incremental)
cur = p * cur;
else
cur = p;
Gui::ViewProvider* vp = document->getViewProvider(*it);
if (vp) vp->setTransformation(cur.toMatrix());
}
}
}
else {
Base::Console().Warning("No object selected.\n");
}
}
开发者ID:aromis,项目名称:FreeCAD_sf_master,代码行数:31,代码来源:Placement.cpp
示例5: findShapes
void DlgRevolution::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
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 (shape.IsNull()) continue;
TopExp_Explorer xp;
xp.Init(shape,TopAbs_SOLID);
if (xp.More()) continue; // solids not allowed
xp.Init(shape,TopAbs_COMPSOLID);
if (xp.More()) continue; // compound solids not allowed
// So allowed are: vertex, edge, wire, face, shell and compound
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, QString::fromUtf8((*it)->Label.getValue()));
item->setData(0, Qt::UserRole, QString::fromAscii((*it)->getNameInDocument()));
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
if (vp) item->setIcon(0, vp->getIcon());
}
}
开发者ID:andrewjrobinson,项目名称:FreeCAD_sf_master,代码行数:25,代码来源:DlgRevolution.cpp
示例6: acceptDataTransform
void TransformStrategy::acceptDataTransform(const Base::Matrix4D& mat, App::DocumentObject* obj)
{
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
std::map<std::string,App::Property*> props;
obj->getPropertyMap(props);
// search for the placement property
std::map<std::string,App::Property*>::iterator jt;
jt = std::find_if(props.begin(), props.end(), find_transform());
if (jt != props.end()) {
Base::Placement local = static_cast<App::PropertyPlacement*>(jt->second)->getValue();
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if (vp) vp->setTransformation(local.toMatrix());
}
else {
// No placement found
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if (vp) vp->setTransformation(Base::Matrix4D());
}
// Apply the transformation
jt = std::find_if(props.begin(), props.end(), find_geometry_data());
if (jt != props.end()) {
static_cast<App::PropertyGeometry*>(jt->second)->transformGeometry(mat);
}
}
开发者ID:5263,项目名称:FreeCAD,代码行数:25,代码来源:Transform.cpp
示例7: getObject
std::vector<App::DocumentObject*> ViewProviderBody::claimChildren(void)const
{
PartDesign::Body* body= static_cast<PartDesign::Body*> ( getObject () );
const std::vector<App::DocumentObject*> &model = body->Model.getValues ();
std::set<App::DocumentObject*> outSet; //< set of objects not to claim (childrens of childrens)
// search for objects handled (claimed) by the features
for( auto obj: model){
if (!obj) { continue; }
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider ( obj );
if (!vp) { continue; }
auto children = vp->claimChildren();
std::remove_copy ( children.begin (), children.end (), std::inserter (outSet, outSet.begin () ), nullptr);
}
// remove the otherwise handled objects, preserving their order so the order in the TreeWidget is correct
std::vector<App::DocumentObject*> Result;
if (body->Origin.getValue()) { // Clame for the Origin
Result.push_back (body->Origin.getValue());
}
if (body->BaseFeature.getValue()) { // Clame for the base feature
Result.push_back (body->BaseFeature.getValue());
}
// claim for rest content not claimed by any other features
std::remove_copy_if (model.begin(), model.end(), std::back_inserter (Result),
[outSet] (App::DocumentObject* obj) {
return outSet.find (obj) != outSet.end();
} );
return Result;
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:34,代码来源:ViewProviderBody.cpp
示例8: openTask
void PropertyEnumAttacherItem::openTask()
{
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
TaskDlgAttacher* task;
task = qobject_cast<TaskDlgAttacher*>(dlg);
if (dlg && !task) {
// there is already another task dialog which must be closed first
Gui::Control().showDialog(dlg);
return;
}
if (!task) {
const App::Property* prop = getFirstProperty();
if (prop) {
App::PropertyContainer* parent = prop->getContainer();
if (parent->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())) {
App::DocumentObject* obj = static_cast<App::DocumentObject*>(parent);
Gui::ViewProvider* view = Gui::Application::Instance->getViewProvider(obj);
if (view->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
task = new TaskDlgAttacher(static_cast<Gui::ViewProviderDocumentObject*>(view));
}
}
}
if (!task) {
return;
}
}
Gui::Control().showDialog(task);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:32,代码来源:PropertyEnumAttacherItem.cpp
示例9: findShapes
void Mirroring::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
this->document = QString::fromLatin1(activeDoc->getName());
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 (!shape.IsNull()) {
QString label = QString::fromUtf8((*it)->Label.getValue());
QString name = QString::fromLatin1((*it)->getNameInDocument());
QTreeWidgetItem* child = new QTreeWidgetItem();
child->setText(0, label);
child->setToolTip(0, label);
child->setData(0, Qt::UserRole, name);
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
if (vp) child->setIcon(0, vp->getIcon());
ui->shapes->addTopLevelItem(child);
}
}
}
开发者ID:AllenBootung,项目名称:FreeCAD,代码行数:27,代码来源:Mirroring.cpp
示例10: setupFillet
void DlgFilletEdges::setupFillet(const std::vector<App::DocumentObject*>& objs)
{
App::DocumentObject* base = d->fillet->Base.getValue();
const std::vector<Part::FilletElement>& e = d->fillet->Edges.getValues();
std::vector<App::DocumentObject*>::const_iterator it = std::find(objs.begin(), objs.end(), base);
if (it != objs.end()) {
// toggle visibility
Gui::ViewProvider* vp;
vp = Gui::Application::Instance->getViewProvider(d->fillet);
if (vp) vp->hide();
vp = Gui::Application::Instance->getViewProvider(base);
if (vp) vp->show();
int current_index = (it - objs.begin()) + 1;
ui->shapeObject->setCurrentIndex(current_index);
on_shapeObject_activated(current_index);
ui->shapeObject->setEnabled(false);
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
for (std::vector<Part::FilletElement>::const_iterator et = e.begin(); et != e.end(); ++et) {
std::vector<int>::iterator it = std::find(d->edge_ids.begin(), d->edge_ids.end(), et->edgeid);
if (it != d->edge_ids.end()) {
int index = it - d->edge_ids.begin();
model->setData(model->index(index, 0), Qt::Checked, Qt::CheckStateRole);
model->setData(model->index(index, 1), QVariant(QLocale::system().toString(et->radius1,'f',2)));
model->setData(model->index(index, 2), QVariant(QLocale::system().toString(et->radius2,'f',2)));
}
}
}
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:29,代码来源:DlgFilletEdges.cpp
示例11: findShapes
void Tessellation::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
this->document = QString::fromAscii(activeDoc->getName());
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;
bool hasfaces = false;
TopExp_Explorer xp(shape,TopAbs_FACE);
while (xp.More()) {
hasfaces = true;
break;
}
if (hasfaces) {
QString label = QString::fromUtf8((*it)->Label.getValue());
QString name = QString::fromAscii((*it)->getNameInDocument());
QTreeWidgetItem* child = new QTreeWidgetItem();
child->setText(0, label);
child->setToolTip(0, label);
child->setData(0, Qt::UserRole, name);
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
if (vp) child->setIcon(0, vp->getIcon());
ui->treeWidget->addTopLevelItem(child);
}
}
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:34,代码来源:Tessellation.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::WFlags 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->prefFloatSpinBox2->hide();
ui->prefFloatSpinBox1->setDecimals(Base::UnitsApi::getDecimals());
ui->prefFloatSpinBox2->setDecimals(Base::UnitsApi::getDecimals());
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::fromAscii((*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::fromAscii((*it)->getNameInDocument()));
item2->setCheckState(0, Qt::Unchecked);
item2->setIcon(0, px);
item1->setCompetitiveItem(item2);
item2->setCompetitiveItem(item1);
}
}
loadSettings();
}
开发者ID:5263,项目名称:FreeCAD,代码行数:63,代码来源:VisualInspection.cpp
示例13: hidePoints
void SketcherValidation::hidePoints()
{
if (coincidenceRoot) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(sketch);
vp->getRoot()->removeChild(coincidenceRoot);
coincidenceRoot = 0;
}
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:8,代码来源:TaskSketcherValidation.cpp
示例14: activated
void StdCmdDuplicateSelection::activated(int iMsg)
{
App::Document* act = App::GetApplication().getActiveDocument();
if (!act)
return; // no active document found
Gui::Document* doc = Gui::Application::Instance->getDocument(act);
std::vector<Gui::SelectionSingleton::SelObj> sel = Gui::Selection().getCompleteSelection();
for (std::vector<SelectionSingleton::SelObj>::iterator it = sel.begin(); it != sel.end(); ++it) {
if (!it->pObject)
continue; // should actually not happen
// create a copy of the object
App::DocumentObject* copy = act->copyObject(it->pObject, false);
if (!copy) // continue if no copy could be created
continue;
// mark all properties of the copy as "touched" which are touched in the original object
std::map<std::string,App::Property*> props;
it->pObject->getPropertyMap(props);
std::map<std::string,App::Property*> copy_props;
copy->getPropertyMap(copy_props);
for (std::map<std::string,App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
if (jt->second->isTouched()) {
std::map<std::string,App::Property*>::iterator kt;
kt = copy_props.find(jt->first);
if (kt != copy_props.end()) {
kt->second->touch();
}
}
}
Gui::Document* parent = Gui::Application::Instance->getDocument(it->pObject->getDocument());
if (!parent || !doc)
continue; // should not happen
// copy the properties of the associated view providers
Gui::ViewProvider* view = parent->getViewProvider(it->pObject);
Gui::ViewProvider* copy_view = doc->getViewProvider(copy);
copy_view->addDynamicProperties(view);
if (!view || !copy_view)
continue; // should not happen
// get the properties of the view provider
props.clear();
view->getPropertyMap(props);
copy_props.clear();
copy_view->getPropertyMap(copy_props);
for (std::map<std::string,App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
std::map<std::string,App::Property*>::iterator kt;
kt = copy_props.find(jt->first);
if (kt != copy_props.end()) {
std::auto_ptr<App::Property> data(jt->second->Copy());
if (data.get()) {
kt->second->Paste(*data);
}
}
}
}
}
开发者ID:pedrocalderon,项目名称:FreeCAD_sf_master,代码行数:56,代码来源:CommandDoc.cpp
示例15: activated
void CmdRaytracingWriteView::activated(int iMsg)
{
const char* ppReturn=0;
Gui::Application::Instance->sendMsgToActiveView("GetCamera",&ppReturn);
if (ppReturn) {
std::string str(ppReturn);
if (str.find("PerspectiveCamera") == std::string::npos) {
int ret = QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdRaytracingWriteView","No perspective camera"),
qApp->translate("CmdRaytracingWriteView","The current view camera is not perspective"
" and thus the result of the povray image later might look different to"
" what you expect.\nDo you want to continue?"),
QMessageBox::Yes|QMessageBox::No);
if (ret != QMessageBox::Yes)
return;
}
}
QStringList filter;
filter << QObject::tr("Povray(*.pov)");
filter << QObject::tr("All Files (*.*)");
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(),
QObject::tr("Export page"), QString(), filter.join(QLatin1String(";;")));
if (fn.isEmpty())
return;
std::string cFullName = (const char*)fn.toUtf8();
// get all objects of the active document
std::vector<Part::Feature*> DocObjects = getActiveGuiDocument()->getDocument()->
getObjectsOfType<Part::Feature>();
openCommand("Write view");
doCommand(Doc,"import Raytracing,RaytracingGui");
doCommand(Doc,"OutFile = open(unicode('%s','utf-8'),'w')",cFullName.c_str());
doCommand(Doc,"OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read())");
doCommand(Doc,"OutFile.write(RaytracingGui.povViewCamera())");
// go through all document objects
for (std::vector<Part::Feature*>::const_iterator it=DocObjects.begin();it!=DocObjects.end();++it) {
Gui::ViewProvider* vp = getActiveGuiDocument()->getViewProvider(*it);
if (vp && vp->isVisible()) {
App::PropertyColor *pcColor = dynamic_cast<App::PropertyColor *>(vp->getPropertyByName("ShapeColor"));
App::Color col = pcColor->getValue();
doCommand(Doc,"OutFile.write(Raytracing.getPartAsPovray('%s',App.activeDocument().%s.Shape,%f,%f,%f))",
(*it)->getNameInDocument(),(*it)->getNameInDocument(),col.r,col.g,col.b);
}
}
doCommand(Doc,"OutFile.close()");
doCommand(Doc,"del OutFile");
updateActive();
commitCommand();
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:54,代码来源:Command.cpp
示例16: importObject
void MergeDocuments::importObject(const std::vector<App::DocumentObject*>& o, Base::XMLReader & r)
{
objects = o;
for (std::vector<App::DocumentObject*>::iterator it = objects.begin(); it != objects.end(); ++it) {
Gui::ViewProvider* vp = document->getViewProvider(*it);
if (vp) vp->hide();
}
Restore(r);
r.readFiles(*this->stream);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:11,代码来源:MergeDocuments.cpp
示例17: getObjects
std::list<ViewProviderMesh*> MeshSelection::getViewProviders() const
{
std::vector<App::DocumentObject*> objs = getObjects();
std::list<ViewProviderMesh*> vps;
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
if ((*it)->isDerivedFrom(Mesh::Feature::getClassTypeId())) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(*it);
if (vp->isVisible())
vps.push_back(static_cast<ViewProviderMesh*>(vp));
}
}
return vps;
}
开发者ID:5263,项目名称:FreeCAD,代码行数:14,代码来源:MeshSelection.cpp
示例18: deleteSelectedItems
void ConstraintView::deleteSelectedItems()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc) return;
doc->openTransaction("Delete");
std::vector<Gui::SelectionObject> sel = Gui::Selection().getSelectionEx(doc->getName());
for (std::vector<Gui::SelectionObject>::iterator ft = sel.begin(); ft != sel.end(); ++ft) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(ft->getObject());
if (vp) {
vp->onDelete(ft->getSubNames());
}
}
doc->commitTransaction();
}
开发者ID:huanyingtianhe,项目名称:FreeCAD,代码行数:15,代码来源:TaskSketcherConstrains.cpp
示例19: findShapes
void Tessellation::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
this->document = QString::fromAscii(activeDoc->getName());
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();
double edgeLen = 0;
bool foundSelection = false;
for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;
bool hasfaces = false;
TopExp_Explorer xp(shape,TopAbs_FACE);
while (xp.More()) {
hasfaces = true;
break;
}
if (hasfaces) {
Base::BoundBox3d bbox = (*it)->Shape.getBoundingBox();
edgeLen = std::max<double>(edgeLen, bbox.LengthX());
edgeLen = std::max<double>(edgeLen, bbox.LengthY());
edgeLen = std::max<double>(edgeLen, bbox.LengthZ());
QString label = QString::fromUtf8((*it)->Label.getValue());
QString name = QString::fromAscii((*it)->getNameInDocument());
QTreeWidgetItem* child = new QTreeWidgetItem();
child->setText(0, label);
child->setToolTip(0, label);
child->setData(0, Qt::UserRole, name);
Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
if (vp) child->setIcon(0, vp->getIcon());
ui->treeWidget->addTopLevelItem(child);
if (Gui::Selection().isSelected(*it)) {
child->setSelected(true);
foundSelection = true;
}
}
}
ui->spinMaximumEdgeLength->setValue(edgeLen/10);
if (foundSelection)
ui->treeWidget->hide();
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:48,代码来源:Tessellation.cpp
示例20: pickFaceCallback
void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n)
{
// handle only mouse button events
if (n->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId())) {
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent*>(n->getEvent());
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
n->getAction()->setHandled();
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
const SoPickedPoint * point = n->getPickedPoint();
if (point == NULL) {
Base::Console().Message("No facet picked.\n");
return;
}
n->setHandled();
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
// really from the mesh we render and not from any other geometry
Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId()))
return;
ViewProviderMesh* mesh = static_cast<ViewProviderMesh*>(vp);
MeshSelection* self = reinterpret_cast<MeshSelection*>(ud);
std::list<ViewProviderMesh*> views = self->getViewProviders();
if (std::find(views.begin(), views.end(), mesh) == views.end())
return;
const SoDetail* detail = point->getDetail(/*mesh->getShapeNode()*/);
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
// get the boundary to the picked facet
unsigned long uFacet = static_cast<const SoFaceDetail*>(detail)->getFaceIndex();
if (self->addToSelection) {
if (self->addComponent)
mesh->selectComponent(uFacet);
else
mesh->selectFacet(uFacet);
}
else {
if (self->removeComponent)
mesh->deselectComponent(uFacet);
else
mesh->deselectFacet(uFacet);
}
}
}
}
}
开发者ID:5263,项目名称:FreeCAD,代码行数:48,代码来源:MeshSelection.cpp
注:本文中的gui::ViewProvider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论