本文整理汇总了C++中ViewProvider类的典型用法代码示例。如果您正苦于以下问题:C++ ViewProvider类的具体用法?C++ ViewProvider怎么用?C++ ViewProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewProvider类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getViewProviderByName
/// set the feature in Noshow
void Document::setPos(const char* name, const Base::Matrix4D& rclMtrx)
{
ViewProvider* pcProv = getViewProviderByName(name);
if (pcProv)
pcProv->setTransformation(rclMtrx);
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:8,代码来源:Document.cpp
示例2: getViewProvider
void Document::slotActivatedObject(const App::DocumentObject& Obj)
{
ViewProvider* viewProvider = getViewProvider(&Obj);
if (viewProvider && viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) {
signalActivatedObject(*(static_cast<ViewProviderDocumentObject*>(viewProvider)));
}
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:7,代码来源:Document.cpp
示例3: bbox
SbBox3f ViewProviderDatum::getRelevantBoundBox (
SoGetBoundingBoxAction &bboxAction, const std::vector <App::DocumentObject *> &objs )
{
SbBox3f bbox(0,0,0, 0,0,0);
// Adds the bbox of given feature to the output
for (auto obj :objs) {
ViewProvider *vp = Gui::Application::Instance->getViewProvider(obj);
if (!vp) {
continue;
}
if (!vp->isVisible ()) {
continue;
}
if (obj->isDerivedFrom (Part::Datum::getClassTypeId() ) ) {
// Treat datums only as their basepoint
// I hope it's ok to take FreeCAD's point here
Base::Vector3d basePoint = static_cast<Part::Datum *> ( obj )->getBasePoint ();
bbox.extendBy (SbVec3f(basePoint.x, basePoint.y, basePoint.z ));
} else {
bboxAction.apply ( vp->getRoot () );
SbBox3f obj_bbox = bboxAction.getBoundingBox ();
if ( obj_bbox.getVolume () < Precision::Infinite () ) {
bbox.extendBy ( obj_bbox );
}
}
}
return bbox;
}
开发者ID:sanguinariojoe,项目名称:FreeCAD,代码行数:32,代码来源:ViewProviderDatum.cpp
示例4: setModified
void Document::slotDeletedObject(const App::DocumentObject& Obj)
{
std::list<Gui::BaseView*>::iterator vIt;
setModified(true);
//Base::Console().Log("Document::slotDeleteObject() called\n");
// cycling to all views of the document
ViewProvider* viewProvider = getViewProvider(&Obj);
#if 0 // With this we can show child objects again if this method was called by undo
viewProvider->onDelete(std::vector<std::string>());
#endif
if (viewProvider && viewProvider->getTypeId().isDerivedFrom
(ViewProviderDocumentObject::getClassTypeId())) {
// go through the views
for (vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) {
View3DInventor *activeView = dynamic_cast<View3DInventor *>(*vIt);
if (activeView) {
if (d->_pcInEdit == viewProvider)
resetEdit();
activeView->getViewer()->removeViewProvider(viewProvider);
}
}
// removing from tree
signalDeletedObject(*(static_cast<ViewProviderDocumentObject*>(viewProvider)));
delete viewProvider;
d->_ViewProviderMap.erase(&Obj);
}
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:30,代码来源:Document.cpp
示例5: assert
void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
{
const SoEvent * ev = node->getEvent();
Gui::View3DInventorViewer* viewer = reinterpret_cast<Gui::View3DInventorViewer*>(node->getUserData());
ViewProvider *self = reinterpret_cast<ViewProvider*>(ud);
assert(self);
try {
// Keyboard events
if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
SoKeyboardEvent * ke = (SoKeyboardEvent *)ev;
const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false;
switch (ke->getKey()) {
case SoKeyboardEvent::ESCAPE:
if (self->keyPressed (press, ke->getKey())) {
node->setHandled();
}
else {
Gui::TimerFunction* func = new Gui::TimerFunction();
func->setAutoDelete(true);
Gui::Document* doc = Gui::Application::Instance->activeDocument();
func->setFunction(boost::bind(&Document::resetEdit, doc));
QTimer::singleShot(0, func, SLOT(timeout()));
}
break;
default:
// call the virtual method
if (self->keyPressed (press, ke->getKey()))
node->setHandled();
break;
}
}
// switching the mouse buttons
else if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
const int button = event->getButton();
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
// call the virtual method
if (self->mouseButtonPressed(button,press,ev->getPosition(),viewer))
node->setHandled();
}
// Mouse Movement handling
else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
if (self->mouseMove(ev->getPosition(),viewer))
node->setHandled();
}
}
catch (const Base::Exception& e) {
Base::Console().Error("Unhandled exception in ViewProvider::eventCallback: %s\n", e.what());
}
catch (const std::exception& e) {
Base::Console().Error("Unhandled std exception in ViewProvider::eventCallback: %s\n", e.what());
}
catch (...) {
Base::Console().Error("Unhandled unknown C++ exception in ViewProvider::eventCallback");
}
}
开发者ID:mdjurfeldt,项目名称:FreeCAD,代码行数:59,代码来源:ViewProvider.cpp
示例6: getDocumentPtr
Py::Object DocumentPy::getActiveObject(void) const
{
App::DocumentObject *object = getDocumentPtr()->getDocument()->getActiveObject();
if (object) {
ViewProvider *viewObj = getDocumentPtr()->getViewProvider(object);
return Py::Object(viewObj->getPyObject(), true);
} else {
return Py::None();
}
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:10,代码来源:DocumentPyImp.cpp
示例7: SaveDocFile
/**
* Saves the properties of the view providers.
*/
void Document::SaveDocFile (Base::Writer &writer) const
{
writer.Stream() << "<?xml version='1.0' encoding='utf-8'?>" << std::endl
<< "<!--" << std::endl
<< " FreeCAD Document, see http://free-cad.sourceforge.net for more information..."
<< std::endl << "-->" << std::endl;
writer.Stream() << "<Document SchemaVersion=\"1\">" << std::endl;
std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::const_iterator it;
// writing the view provider names itself
writer.incInd(); // indention for 'ViewProviderData Count'
writer.Stream() << writer.ind() << "<ViewProviderData Count=\""
<< d->_ViewProviderMap.size() <<"\">" << std::endl;
bool xml = writer.isForceXML();
//writer.setForceXML(true);
writer.incInd(); // indention for 'ViewProvider name'
for(it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) {
const App::DocumentObject* doc = it->first;
ViewProvider* obj = it->second;
writer.Stream() << writer.ind() << "<ViewProvider name=\""
<< doc->getNameInDocument() << "\" "
<< "expanded=\"" << (doc->testStatus(App::Expand) ? 1:0)
<< "\">" << std::endl;
obj->Save(writer);
writer.Stream() << writer.ind() << "</ViewProvider>" << std::endl;
}
writer.setForceXML(xml);
writer.decInd(); // indention for 'ViewProvider name'
writer.Stream() << writer.ind() << "</ViewProviderData>" << std::endl;
writer.decInd(); // indention for 'ViewProviderData Count'
// set camera settings
QString viewPos;
if (d->_pcAppWnd->sendHasMsgToActiveView("GetCamera")) {
const char* ppReturn=0;
d->_pcAppWnd->sendMsgToActiveView("GetCamera",&ppReturn);
// remove the first line because it's a comment like '#Inventor V2.1 ascii'
QStringList lines = QString(QString::fromAscii(ppReturn)).split(QLatin1String("\n"));
if (lines.size() > 1) {
lines.pop_front();
viewPos = lines.join(QLatin1String(" "));
}
}
writer.incInd(); // indention for camera settings
writer.Stream() << writer.ind() << "<Camera settings=\""
<< (const char*)viewPos.toAscii() <<"\"/>" << std::endl;
writer.decInd(); // indention for camera settings
writer.Stream() << "</Document>" << std::endl;
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:58,代码来源:Document.cpp
示例8: xmlReader
/**
* Restores the properties of the view providers.
*/
void Document::RestoreDocFile(Base::Reader &reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader xmlReader("GuiDocument.xml", reader);
int i,Cnt;
xmlReader.readElement("Document");
long scheme = xmlReader.getAttributeAsInteger("SchemaVersion");
// At this stage all the document objects and their associated view providers exist.
// Now we must restore the properties of the view providers only.
//
// SchemeVersion "1"
if (scheme == 1) {
// read the viewproviders itself
xmlReader.readElement("ViewProviderData");
Cnt = xmlReader.getAttributeAsInteger("Count");
for (i=0 ;i<Cnt ;i++) {
xmlReader.readElement("ViewProvider");
std::string name = xmlReader.getAttribute("name");
ViewProvider* pObj = getViewProviderByName(name.c_str());
if (pObj) // check if this feature has been registered
pObj->Restore(xmlReader);
xmlReader.readEndElement("ViewProvider");
}
xmlReader.readEndElement("ViewProviderData");
// read camera settings
xmlReader.readElement("Camera");
const char* ppReturn = xmlReader.getAttribute("settings");
std::string sMsg = "SetCamera ";
sMsg += ppReturn;
if (strcmp(ppReturn, "") != 0) { // non-empty attribute
try {
if (d->_pcAppWnd->sendHasMsgToActiveView("SetCamera"))
d->_pcAppWnd->sendMsgToActiveView(sMsg.c_str());
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
}
}
xmlReader.readEndElement("Document");
// In the file GuiDocument.xml new data files might be added
if (!xmlReader.getFilenames().empty())
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader));
// reset modifeid flag
setModified(false);
}
开发者ID:clementCAM,项目名称:FreeCAD,代码行数:56,代码来源:Document.cpp
示例9: getObject
/**
* Extracts the associated view providers of the objects of the associated object group group.
*/
void ViewProviderDocumentObjectGroup::getViewProviders(std::vector<ViewProviderDocumentObject*>& vp) const
{
App::DocumentObject* doc = getObject();
if (doc->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) {
Gui::Document* gd = Application::Instance->getDocument(doc->getDocument());
App::DocumentObjectGroup* grp = (App::DocumentObjectGroup*)doc;
std::vector<App::DocumentObject*> obj = grp->getObjects();
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
ViewProvider* v = gd->getViewProvider(*it);
if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
vp.push_back((ViewProviderDocumentObject*)v);
}
}
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:17,代码来源:ViewProviderDocumentObjectGroup.cpp
示例10: getViewProvider
void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
{
//Base::Console().Log("Document::slotChangedObject() called\n");
ViewProvider* viewProvider = getViewProvider(&Obj);
if (viewProvider) {
try {
viewProvider->update(&Prop);
}
catch(const Base::MemoryException& e) {
Base::Console().Error("Memory exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
}
catch(Base::Exception& e){
e.ReportException();
}
catch(const std::exception& e){
Base::Console().Error("C++ exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
}
catch (...) {
Base::Console().Error("Cannot update representation for '%s'.\n", Obj.getNameInDocument());
}
// check for children
if(viewProvider->getChildRoot()) {
std::vector<App::DocumentObject*> children = viewProvider->claimChildren3D();
SoGroup* childGroup = viewProvider->getChildRoot();
// size not the same -> build up the list new
if(childGroup->getNumChildren() != children.size()){
childGroup->removeAllChildren();
for(std::vector<App::DocumentObject*>::iterator it=children.begin();it!=children.end();++it){
ViewProvider* ChildViewProvider = getViewProvider(*it);
if(ChildViewProvider) {
SoSeparator* childRootNode = ChildViewProvider->getRoot();
childGroup->addChild(childRootNode);
// cycling to all views of the document to remove the viewprovider from the viewer itself
for (std::list<Gui::BaseView*>::iterator vIt = d->baseViews.begin();vIt != d->baseViews.end();++vIt) {
View3DInventor *activeView = dynamic_cast<View3DInventor *>(*vIt);
if (activeView && viewProvider) {
if (d->_pcInEdit == ChildViewProvider)
resetEdit();
activeView->getViewer()->removeViewProvider(ChildViewProvider);
}
}
}
}
}
}
if (viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
signalChangedObject(static_cast<ViewProviderDocumentObject&>(*viewProvider), Prop);
}
// a property of an object has changed
setModified(true);
}
开发者ID:RipCurrent,项目名称:FreeCAD_sf_master,代码行数:58,代码来源:Document.cpp
示例11: PyDict_GetItemString
PyObject *DocumentPy::getCustomAttributes(const char* attr) const
{
// Note: Here we want to return only a document object if its
// name matches 'attr'. However, it is possible to have an object
// with the same name as an attribute. If so, we return 0 as other-
// wise it wouldn't be possible to address this attribute any more.
// The object must then be addressed by the getObject() method directly.
if (this->ob_type->tp_dict == NULL) {
if (PyType_Ready(this->ob_type) < 0)
return 0;
}
PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr);
if (item) return 0;
// search for an object with this name
ViewProvider* obj = getDocumentPtr()->getViewProviderByName(attr);
return (obj ? obj->getPyObject() : 0);
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:17,代码来源:DocumentPyImp.cpp
示例12: getExtendedViewProvider
void ViewProviderGroupExtension::extensionShow(void) {
// when reading the Visibility property from file then do not hide the
// objects of this group because they have stored their visibility status, too
if (!getExtendedViewProvider()->isRestoring() && !this->visible) {
auto* group = getExtendedViewProvider()->getObject()->getExtensionByType<App::GroupExtension>();
const std::vector<App::DocumentObject*> & links = group->Group.getValues();
Gui::Document* doc = Application::Instance->getDocument(group->getExtendedObject()->getDocument());
for (std::vector<App::DocumentObject*>::const_iterator it = links.begin(); it != links.end(); ++it) {
ViewProvider* view = doc->getViewProvider(*it);
if (view)
view->show();
}
}
ViewProviderExtension::extensionShow();
this->visible = true;
}
开发者ID:SparkyCola,项目名称:FreeCAD,代码行数:19,代码来源:ViewProviderGroupExtension.cpp
示例13: exportObjects
void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, Base::Writer& writer)
{
writer.Stream() << "<?xml version='1.0' encoding='utf-8'?>" << std::endl;
writer.Stream() << "<Document SchemaVersion=\"1\">" << std::endl;
std::map<const App::DocumentObject*,ViewProvider*> views;
for (std::vector<App::DocumentObject*>::const_iterator it = obj.begin(); it != obj.end(); ++it) {
Document* doc = Application::Instance->getDocument((*it)->getDocument());
if (doc) {
ViewProvider* vp = doc->getViewProvider(*it);
if (vp) views[*it] = vp;
}
}
// writing the view provider names itself
writer.incInd(); // indention for 'ViewProviderData Count'
writer.Stream() << writer.ind() << "<ViewProviderData Count=\""
<< views.size() <<"\">" << std::endl;
bool xml = writer.isForceXML();
//writer.setForceXML(true);
writer.incInd(); // indention for 'ViewProvider name'
std::map<const App::DocumentObject*,ViewProvider*>::const_iterator jt;
for (jt = views.begin(); jt != views.end(); ++jt) {
const App::DocumentObject* doc = jt->first;
ViewProvider* obj = jt->second;
writer.Stream() << writer.ind() << "<ViewProvider name=\""
<< doc->getNameInDocument() << "\" type=\""
<< obj->getTypeId().getName()
<< "\">" << std::endl;
obj->Save(writer);
writer.Stream() << writer.ind() << "</ViewProvider>" << std::endl;
}
writer.setForceXML(xml);
writer.decInd(); // indention for 'ViewProvider name'
writer.Stream() << writer.ind() << "</ViewProviderData>" << std::endl;
writer.decInd(); // indention for 'ViewProviderData Count'
writer.incInd(); // indention for camera settings
writer.Stream() << writer.ind() << "<Camera settings=\"\"/>" << std::endl;
writer.decInd(); // indention for camera settings
writer.Stream() << "</Document>" << std::endl;
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:43,代码来源:Document.cpp
示例14: Selection
void StdCmdRandomColor::activated(int iMsg)
{
// get the complete selection
std::vector<SelectionSingleton::SelObj> sel = Selection().getCompleteSelection();
for (std::vector<SelectionSingleton::SelObj>::iterator it = sel.begin(); it != sel.end(); ++it) {
float fMax = (float)RAND_MAX;
float fRed = (float)rand()/fMax;
float fGrn = (float)rand()/fMax;
float fBlu = (float)rand()/fMax;
ViewProvider* view = Application::Instance->getDocument(it->pDoc)->getViewProvider(it->pObject);
App::Property* color = view->getPropertyByName("ShapeColor");
if (color && color->getTypeId() == App::PropertyColor::getClassTypeId()) {
// get the view provider of the selected object and set the shape color
doCommand(Gui, "Gui.getDocument(\"%s\").getObject(\"%s\").ShapeColor=(%.2f,%.2f,%.2f)"
, it->DocName, it->FeatName, fRed, fGrn, fBlu);
}
}
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:19,代码来源:CommandFeat.cpp
示例15: xmlReader
void Document::importObjects(const std::vector<App::DocumentObject*>& obj, Base::Reader& reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader xmlReader("GuiDocument.xml", reader);
xmlReader.readElement("Document");
long scheme = xmlReader.getAttributeAsInteger("SchemaVersion");
// At this stage all the document objects and their associated view providers exist.
// Now we must restore the properties of the view providers only.
//
// SchemeVersion "1"
if (scheme == 1) {
// read the viewproviders itself
xmlReader.readElement("ViewProviderData");
int Cnt = xmlReader.getAttributeAsInteger("Count");
std::vector<App::DocumentObject*>::const_iterator it = obj.begin();
for (int i=0;i<Cnt&&it!=obj.end();++i,++it) {
// The stored name usually doesn't match with the current name anymore
// thus we try to match by type. This should work because the order of
// objects should not have changed
xmlReader.readElement("ViewProvider");
std::string type = xmlReader.getAttribute("type");
ViewProvider* pObj = getViewProvider(*it);
while (pObj && type != pObj->getTypeId().getName()) {
if (it != obj.end()) {
++it;
pObj = getViewProvider(*it);
}
}
if (pObj && type == pObj->getTypeId().getName())
pObj->Restore(xmlReader);
xmlReader.readEndElement("ViewProvider");
if (it == obj.end())
break;
}
xmlReader.readEndElement("ViewProviderData");
}
xmlReader.readEndElement("Document");
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:40,代码来源:Document.cpp
示例16: getViewProvider
void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
{
//Base::Console().Log("Document::slotChangedObject() called\n");
ViewProvider* viewProvider = getViewProvider(&Obj);
if (viewProvider) {
try {
viewProvider->update(&Prop);
} catch(const Base::MemoryException& e) {
Base::Console().Error("Memory exception in '%s' thrown: %s\n",Obj.getNameInDocument(),e.what());
} catch(Base::Exception &e){
e.ReportException();
} catch (...) {
Base::Console().Error("Cannot update representation for '%s'.\n", Obj.getNameInDocument());
}
if (viewProvider->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
signalChangedObject(static_cast<ViewProviderDocumentObject&>(*viewProvider), Prop);
}
// a property of an object has changed
setModified(true);
}
开发者ID:clementCAM,项目名称:FreeCAD,代码行数:22,代码来源:Document.cpp
示例17: getObject
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
示例18: snprintf
// doc from parent
void
SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
{
// If off then don't handle this event
if (!selectionRole.getValue()) {
inherited::handleEvent(action);
return;
}
static char buf[513];
HighlightModes mymode = (HighlightModes) this->highlightMode.getValue();
const SoEvent * event = action->getEvent();
// If we don't need to pick for locate highlighting,
// then just behave as separator and return.
// NOTE: we still have to pick for ON even though we don't have
// to re-render, because the app needs to be notified as the mouse
// goes over locate highlight nodes.
//if (highlightMode.getValue() == OFF) {
// inherited::handleEvent( action );
// return;
//}
//
// If this is a mouseMotion event, then check for locate highlighting
//
if (event->isOfType(SoLocation2Event::getClassTypeId())) {
// NOTE: If preselection is off then we do not check for a picked point because otherwise this search may slow
// down extremely the system on really big data sets. In this case we just check for a picked point if the data
// set has been selected.
if (mymode == AUTO || mymode == ON) {
// check to see if the mouse is over our geometry...
const SoPickedPoint * pp = this->getPickedPoint(action);
SoFullPath *pPath = (pp != NULL) ? (SoFullPath *) pp->getPath() : NULL;
ViewProvider *vp = 0;
ViewProviderDocumentObject* vpd = 0;
if (pPath && pPath->containsPath(action->getCurPath()))
vp = viewer->getViewProviderByPathFromTail(pPath);
if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
vpd = static_cast<ViewProviderDocumentObject*>(vp);
SbBool old_state = highlighted;
highlighted = FALSE;
if (vpd && vpd->useNewSelectionModel() && vpd->isSelectable()) {
std::string documentName = vpd->getObject()->getDocument()->getName();
std::string objectName = vpd->getObject()->getNameInDocument();
std::string subElementName = vpd->getElement(pp ? pp->getDetail() : 0);
static char buf[513];
snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
,objectName.c_str()
,subElementName.c_str()
,pp->getPoint()[0]
,pp->getPoint()[1]
,pp->getPoint()[2]);
getMainWindow()->showMessage(QString::fromAscii(buf),3000);
if (Gui::Selection().setPreselect(documentName.c_str()
,objectName.c_str()
,subElementName.c_str()
,pp->getPoint()[0]
,pp->getPoint()[1]
,pp->getPoint()[2])){
SoSearchAction sa;
sa.setNode(vp->getRoot());
sa.apply(vp->getRoot());
if (sa.getPath()) {
highlighted = TRUE;
if (currenthighlight && currenthighlight->getTail() != sa.getPath()->getTail()) {
SoHighlightElementAction action;
action.setHighlighted(FALSE);
action.apply(currenthighlight);
currenthighlight->unref();
currenthighlight = 0;
old_state = !highlighted;
}
currenthighlight = static_cast<SoFullPath*>(sa.getPath()->copy());
currenthighlight->ref();
}
}
}
if (currenthighlight/* && old_state != highlighted*/) {
SoHighlightElementAction action;
action.setHighlighted(highlighted);
action.setColor(this->colorHighlight.getValue());
action.setElement(pp ? pp->getDetail() : 0);
action.apply(currenthighlight);
if (!highlighted) {
currenthighlight->unref();
currenthighlight = 0;
}
this->touch();
}
}
//.........这里部分代码省略.........
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:101,代码来源:SoFCUnifiedSelection.cpp
示例19: xmlReader
/**
* Restores the properties of the view providers.
*/
void Document::RestoreDocFile(Base::Reader &reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader xmlReader("GuiDocument.xml", reader);
xmlReader.FileVersion = reader.getFileVersion();
int i,Cnt;
xmlReader.readElement("Document");
long scheme = xmlReader.getAttributeAsInteger("SchemaVersion");
// At this stage all the document objects and their associated view providers exist.
// Now we must restore the properties of the view providers only.
//
// SchemeVersion "1"
if (scheme == 1) {
// read the viewproviders itself
xmlReader.readElement("ViewProviderData");
Cnt = xmlReader.getAttributeAsInteger("Count");
for (i=0 ;i<Cnt ;i++) {
xmlReader.readElement("ViewProvider");
std::string name = xmlReader.getAttribute("name");
bool expanded = false;
if (xmlReader.hasAttribute("expanded")) {
const char* attr = xmlReader.getAttribute("expanded");
if (strcmp(attr,"1") == 0) {
expanded = true;
}
}
ViewProvider* pObj = getViewProviderByName(name.c_str());
if (pObj) // check if this feature has been registered
pObj->Restore(xmlReader);
if (pObj && expanded) {
Gui::ViewProviderDocumentObject* vp = static_cast<Gui::ViewProviderDocumentObject*>(pObj);
this->signalExpandObject(*vp, Gui::Expand);
}
xmlReader.readEndElement("ViewProvider");
}
xmlReader.readEndElement("ViewProviderData");
// read camera settings
xmlReader.readElement("Camera");
const char* ppReturn = xmlReader.getAttribute("settings");
std::string sMsg = "SetCamera ";
sMsg += ppReturn;
if (strcmp(ppReturn, "") != 0) { // non-empty attribute
try {
const char** pReturnIgnore=0;
std::list<MDIView*> mdi = getMDIViews();
for (std::list<MDIView*>::iterator it = mdi.begin(); it != mdi.end(); ++it) {
if ((*it)->onHasMsg("SetCamera"))
(*it)->onMsg(sMsg.c_str(), pReturnIgnore);
}
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
}
}
xmlReader.readEndElement("Document");
// In the file GuiDocument.xml new data files might be added
if (!xmlReader.getFilenames().empty())
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader.getStream()));
// reset modified flag
setModified(false);
}
开发者ID:microelly2,项目名称:FreeCAD,代码行数:72,代码来源:Document.cpp
注:本文中的ViewProvider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论