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(); } }
bool CmdSketcherToggleConstruction::isActive(void) { return isAlterGeoActive( getActiveGuiDocument() ); }
bool CmdRaytracingExportProject::isActive(void) { return (getActiveGuiDocument() ? true : false); }
bool CmdRaytracingResetCamera::isActive(void) { return (getActiveGuiDocument() ? true : false); }
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 POV-Ray 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("POV-Ray(*.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()); try { doCommand(Doc,"result = open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read()"); doCommand(Doc,"content = ''"); doCommand(Doc,"content += 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,"content += Raytracing.getPartAsPovray('%s',App.activeDocument().%s.Shape,%f,%f,%f)", (*it)->getNameInDocument(),(*it)->getNameInDocument(),col.r,col.g,col.b); } } doCommand(Doc,"result = result.replace('//RaytracingContent',content)"); doCommand(Doc,"OutFile.write(result)"); doCommand(Doc,"OutFile.close()"); doCommand(Doc,"del OutFile"); commitCommand(); } catch (...) { doCommand(Doc,"OutFile.close()"); doCommand(Doc,"del OutFile"); abortCommand(); throw; } }
bool CmdPartRuledSurface::isActive(void) { return getActiveGuiDocument(); }