//---------------- void oilWaterNode::update(){ repulsionDist = 29.0; if( bRise ){ repulsionDist = 30.0; }else{ repulsionDist = 30.0; } // nodeText.update(0.04); //printf("state is %s\n", nodeStateToStr(state).c_str()); if(state == NODE_ACTIVATING){ nPct += 0.03; if( nPct > 1.0 ){ nPct = 1.0; state = NODE_ACTIVE; globalSnd.play("OIL_WATER_BURST", 0.9, 1.0, 0.0); } } if( nPct >= 0.9 ){ updateActive(); }else{ updateActive(); updateInactive(); } }
void CmdPartRefineShape::activated(int iMsg) { Gui::WaitCursor wc; Base::Type partid = Base::Type::fromName("Part::Feature"); std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(partid); openCommand("Refine shape"); for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) { try { doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape=" "App.ActiveDocument.%s.Shape.removeSplitter()\n" "App.ActiveDocument.ActiveObject.Label=" "App.ActiveDocument.%s.Label\n" "Gui.ActiveDocument.%s.hide()\n", (*it)->getNameInDocument(), (*it)->getNameInDocument(), (*it)->getNameInDocument(), (*it)->getNameInDocument()); copyVisual("ActiveObject", "ShapeColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "LineColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "PointColor", (*it)->getNameInDocument()); } catch (const Base::Exception& e) { Base::Console().Warning("%s: %s\n", (*it)->Label.getValue(), e.what()); } } commitCommand(); updateActive(); }
void CmdPointsExport::activated(int iMsg) { QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString::null, QString(), QObject::tr("Ascii Points (*.asc);;All Files (*.*)")); if ( fn.isEmpty() ) return; if (! fn.isEmpty() ) { QFileInfo fi; fi.setFile(fn); openCommand("Export Points"); std::vector<App::DocumentObject*> points = getSelection().getObjectsOfType(Points::Feature::getClassTypeId()); doCommand(Doc,"f = App.ActiveDocument.addObject(\"Points::Export\",\"%s\")", (const char*)fi.baseName().toAscii()); doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toAscii()); doCommand(Doc,"l=list()"); for ( std::vector<App::DocumentObject*>::const_iterator it = points.begin(); it != points.end(); ++it ) { doCommand(Doc,"l.append(App.ActiveDocument.getObject(\"%s\"))",(*it)->getNameInDocument()); } doCommand(Doc,"f.Sources = l"); commitCommand(); updateActive(); } }
void CmdPartDesignDuplicateSelection::activated(int iMsg) { Q_UNUSED(iMsg); PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false); std::vector<App::DocumentObject*> beforeFeatures = getDocument()->getObjects(); openCommand("Duplicate a PartDesign object"); doCommand(Doc,"FreeCADGui.runCommand('Std_DuplicateSelection')"); if (pcActiveBody) { // Find the features that were added std::vector<App::DocumentObject*> afterFeatures = getDocument()->getObjects(); std::vector<App::DocumentObject*> newFeatures; std::sort(beforeFeatures.begin(), beforeFeatures.end()); std::sort(afterFeatures.begin(), afterFeatures.end()); std::set_difference(afterFeatures.begin(), afterFeatures.end(), beforeFeatures.begin(), beforeFeatures.end(), std::back_inserter(newFeatures)); for (auto feature : newFeatures) { if (PartDesign::Body::isAllowed(feature)) { doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), feature->getNameInDocument()); doCommand(Gui,"Gui.activeDocument().hide(\"%s\")", feature->getNameInDocument()); } } // Adjust visibility of features doCommand(Gui,"Gui.activeDocument().show(\"%s\")", newFeatures.back()->getNameInDocument()); } updateActive(); }
void CmdPathCompound::activated(int iMsg) { std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection(); if (Sel.size() > 0) { std::ostringstream cmd; cmd << "["; Path::Feature *pcPathObject; for (std::vector<Gui::SelectionSingleton::SelObj>::const_iterator it=Sel.begin();it!=Sel.end();++it) { if ((*it).pObject->getTypeId().isDerivedFrom(Path::Feature::getClassTypeId())) { pcPathObject = dynamic_cast<Path::Feature*>((*it).pObject); cmd << "FreeCAD.activeDocument()." << pcPathObject->getNameInDocument() << ","; } else { Base::Console().Error("Only Path objects must be selected before running this command\n"); return; } } cmd << "]"; std::string FeatName = getUniqueObjectName("PathCompound"); openCommand("Create Path Compound"); doCommand(Doc,"FreeCAD.activeDocument().addObject('Path::FeatureCompound','%s')",FeatName.c_str()); doCommand(Doc,"FreeCAD.activeDocument().%s.Group = %s",FeatName.c_str(),cmd.str().c_str()); commitCommand(); updateActive(); } else { Base::Console().Error("At least one Path object must be selected\n"); return; } }
LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp) { LLMemType mt(LLMemType::MTYPE_OBJECT); LLUUID fullid; fullid.generate(); LLViewerObject *objectp = LLViewerObject::createObject(fullid, pcode, regionp); if (!objectp) { // llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << llendl; return NULL; } mUUIDObjectMap[fullid] = objectp; if(objectp->isAvatar()) { LLVOAvatar *pAvatar = dynamic_cast<LLVOAvatar*>(objectp); if(pAvatar) mUUIDAvatarMap[fullid] = pAvatar; } mObjects.push_back(objectp); updateActive(objectp); return objectp; }
LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRegion *regionp, const LLUUID &uuid, const U32 local_id, const LLHost &sender) { LLMemType mt(LLMemType::MTYPE_OBJECT); LLFastTimer t(LLFastTimer::FTM_CREATE_OBJECT); LLUUID fullid; if (uuid == LLUUID::null) { fullid.generate(); } else { fullid = uuid; } LLViewerObject *objectp = LLViewerObject::createObject(fullid, pcode, regionp); if (!objectp) { // llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << llendl; return NULL; } mUUIDObjectMap[fullid] = objectp; setUUIDAndLocal(fullid, local_id, gMessageSystem->getSenderIP(), gMessageSystem->getSenderPort()); mObjects.put(objectp); updateActive(objectp); return objectp; }
void CmdPartFuse::activated(int iMsg) { unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId()); if (n < 2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select two shapes or more, please.")); return; } std::string FeatName = getUniqueObjectName("Fusion"); std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection(); std::stringstream str; std::vector<std::string> tempSelNames; str << "App.activeDocument()." << FeatName << ".Shapes = ["; for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){ str << "App.activeDocument()." << it->FeatName << ","; tempSelNames.push_back(it->FeatName); } str << "]"; openCommand("Fusion"); doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiFuse\",\"%s\")",FeatName.c_str()); runCommand(Doc,str.str().c_str()); for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it) doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str()); copyVisual(FeatName.c_str(), "ShapeColor", tempSelNames.front().c_str()); copyVisual(FeatName.c_str(), "DisplayMode", tempSelNames.front().c_str()); updateActive(); commitCommand(); }
void CmdPartCut::activated(int iMsg) { unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId()); if (n != 2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select two shapes please.")); return; } std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection(); std::string FeatName = getUniqueObjectName("Cut"); std::string BaseName = Sel[0].FeatName; std::string ToolName = Sel[1].FeatName; openCommand("Part Cut"); doCommand(Doc,"App.activeDocument().addObject(\"Part::Cut\",\"%s\")",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),BaseName.c_str()); doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),ToolName.c_str()); doCommand(Gui,"Gui.activeDocument().hide('%s')",BaseName.c_str()); doCommand(Gui,"Gui.activeDocument().hide('%s')",ToolName.c_str()); copyVisual(FeatName.c_str(), "ShapeColor", BaseName.c_str()); copyVisual(FeatName.c_str(), "DisplayMode", BaseName.c_str()); updateActive(); commitCommand(); }
void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp, void** user_data, U32 i, const EObjectUpdateType update_type, LLDataPacker* dpp, BOOL just_created) { LLMessageSystem* msg = gMessageSystem; // ignore returned flags objectp->processUpdateMessage(msg, user_data, i, update_type, dpp); if (objectp->isDead()) { // The update failed return; } updateActive(objectp); // Also sets the approx. pixel area objectp->setPixelAreaAndAngle(gAgent); // Update the image levels of textures for this object. objectp->updateTextures(gAgent); if (just_created) { gPipeline.addObject(objectp); } else { primbackup::getInstance()->prim_update(objectp); } // RN: this must be called after we have a drawable // (from gPipeline.addObject) // so that the drawable parent is set properly findOrphans(objectp, msg->getSenderIP(), msg->getSenderPort()); // If we're just wandering around, don't create new objects selected. if (just_created && update_type != OUT_TERSE_IMPROVED && objectp->mCreateSelected) { if ( gToolMgr->getCurrentTool() != gToolPie ) { //llinfos << "DEBUG selecting " << objectp->mID << " " // << objectp->mLocalID << llendl; gSelectMgr->selectObjectAndFamily(objectp); dialog_refresh_all(); } objectp->mCreateSelected = false; gViewerWindow->getWindow()->decBusyCount(); gViewerWindow->getWindow()->setCursor( UI_CURSOR_ARROW ); primbackup::getInstance()->newprim(objectp); } }
void LegendTab::setSingle(bool single) { _single = single; updateActive(); if (single) { _autoContents->setTristate(false); _displayVertically->setTristate(false); } }
void CmdPartDesignMoveTip::activated(int iMsg) { Q_UNUSED(iMsg); std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType( Part::Feature::getClassTypeId() ); App::DocumentObject* selFeature; PartDesign::Body* body= nullptr; if ( features.size() == 1 ) { selFeature = features.front(); if ( selFeature->getTypeId().isDerivedFrom ( PartDesign::Body::getClassTypeId() ) ) { body = static_cast<PartDesign::Body *> ( selFeature ); } else { body = PartDesignGui::getBodyFor ( selFeature, /* messageIfNot =*/ false ); } } else { selFeature = nullptr; } if (!selFeature) { QMessageBox::warning (0, QObject::tr( "Selection error" ), QObject::tr( "Select exactly one PartDesign feature or a body." ) ); return; } else if (!body) { QMessageBox::warning (0, QObject::tr( "Selection error" ), QObject::tr( "Couldn't determine a body for the selected feature '%s'.", selFeature->Label.getValue() ) ); return; } else if ( !selFeature->isDerivedFrom(PartDesign::Feature::getClassTypeId () ) && selFeature != body && body->BaseFeature.getValue() != selFeature ) { QMessageBox::warning (0, QObject::tr( "Selection error" ), QObject::tr( "Only a solid feature can be the tip of a body." ) ); return; } App::DocumentObject* oldTip = body->Tip.getValue(); if (oldTip == selFeature) { // it's not generally an error, so print only a console message Base::Console().Message ("%s is already the tip of the body", selFeature->getNameInDocument () ); return; } openCommand("Move tip to selected feature"); if (selFeature == body) { doCommand(Doc,"App.activeDocument().%s.Tip = None", body->getNameInDocument()); } else { doCommand(Doc,"App.activeDocument().%s.Tip = App.activeDocument().%s",body->getNameInDocument(), selFeature->getNameInDocument()); // Adjust visibility to show only the Tip feature doCommand(Gui,"Gui.activeDocument().show(\"%s\")", selFeature->getNameInDocument()); } // TOOD: Hide all datum features after the Tip feature? But the user might have already hidden some and wants to see // others, so we would have to remember their state somehow updateActive(); }
void CmdRaytracingNewPartSegment::activated(int iMsg) { std::vector<Part::Feature*> parts = Gui::Selection().getObjectsOfType<Part::Feature>(); if (parts.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select a Part object.")); return; } std::vector<App::DocumentObject*> pages = App::GetApplication().getActiveDocument() ->getObjectsOfType(Raytracing::RayProject::getClassTypeId()); std::vector<App::DocumentObject*> pages2 = App::GetApplication().getActiveDocument() ->getObjectsOfType(Raytracing::LuxProject::getClassTypeId()); pages.insert(pages.end(),pages2.begin(),pages2.end()); if (pages.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No Raytracing project to insert"), QObject::tr("Create a Raytracing project to insert a view.")); return; } std::string ProjName; if (pages.size() > 1) { // priority to the elders, if there is a pov project in the selection, it is used first! pages = Gui::Selection().getObjectsOfType(Raytracing::RayProject::getClassTypeId()); if (pages.size() != 1) { pages = Gui::Selection().getObjectsOfType(Raytracing::LuxProject::getClassTypeId()); if (pages.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No Raytracing project to insert"), QObject::tr("Select a Raytracing project to insert the view.")); return; } } } ProjName = pages.front()->getNameInDocument(); const char *FeatType; if (pages.front()->getTypeId().isDerivedFrom(Raytracing::RayProject::getClassTypeId())) { FeatType = "RayFeature"; } else { FeatType = "LuxFeature"; } openCommand("Create view"); for (std::vector<Part::Feature*>::iterator it = parts.begin(); it != parts.end(); ++it) { std::string FeatName = (*it)->getNameInDocument(); FeatName += "_View"; FeatName = getUniqueObjectName(FeatName.c_str()); doCommand(Doc,"App.activeDocument().addObject('Raytracing::%s','%s')",FeatType,FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Color = Gui.activeDocument().%s.ShapeColor",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Transparency = Gui.activeDocument().%s.Transparency",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",ProjName.c_str(), FeatName.c_str()); } updateActive(); commitCommand(); }
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(); }
void CmdRaytracingResetCamera::activated(int iMsg) { std::vector<App::DocumentObject*> sel = getSelection().getObjectsOfType(Raytracing::RayProject::getClassTypeId()); if (sel.size() != 1) { sel = getSelection().getObjectsOfType(Raytracing::LuxProject::getClassTypeId()); if (sel.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one Raytracing project object.")); return; } } if (sel.front()->getTypeId().isDerivedFrom(Raytracing::RayProject::getClassTypeId())) { //povray try { openCommand("Reset Raytracing Camera"); doCommand(Doc,"import RaytracingGui"); doCommand(Doc,"App.activeDocument().%s.Camera = RaytracingGui.povViewCamera()",sel.front()->getNameInDocument()); commitCommand(); updateActive(); } catch (...) { abortCommand(); throw; } } else if (sel.front()->getTypeId().isDerivedFrom(Raytracing::LuxProject::getClassTypeId())) { //luxrender try { openCommand("Reset Raytracing Camera"); doCommand(Doc,"import RaytracingGui"); doCommand(Doc,"App.activeDocument().%s.Camera = RaytracingGui.luxViewCamera()",sel.front()->getNameInDocument()); commitCommand(); updateActive(); } catch (...) { abortCommand(); throw; } } }
// __________________________________________________________________________________________________ void KikiGear::actionFinished ( KikiAction * action ) { KikiValve::actionFinished (action); int actionId = action->getId(); if (actionId == ACTION_PUSH || actionId == ACTION_FALL) { if (move_action == NULL) { updateActive(); } } }
void ledseqStop(led_t led, const ledseq_t *sequence) { int prio = getPrio(sequence); if(prio<0) return; xSemaphoreTake(ledseqSem, portMAX_DELAY); state[led][prio] = LEDSEQ_STOP; //Stop the seq. updateActive(led); xSemaphoreGive(ledseqSem); //Run the next active sequence (if any...) runLedseq(timer[led]); }
void CmdPartBox::activated(int iMsg) { QString cmd; cmd = qApp->translate("CmdPartBox","Cube"); openCommand((const char*)cmd.toUtf8()); doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Box\",\"Box\")"); cmd = QString::fromAscii("App.ActiveDocument.ActiveObject.Label = \"%1\"") .arg(qApp->translate("CmdPartBox","Cube")); doCommand(Doc,(const char*)cmd.toUtf8()); commitCommand(); updateActive(); doCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")"); }
void CmdPartBox3::activated(int iMsg) { openCommand("Part Box Create"); doCommand(Doc,"from FreeCAD import Base"); doCommand(Doc,"import Part"); doCommand(Doc,"__fb__ = App.ActiveDocument.addObject(\"Part::Box\",\"PartBox\")"); doCommand(Doc,"__fb__.Location = Base.Vector(50.0,50.0,50.0)"); doCommand(Doc,"__fb__.Length = 100.0"); doCommand(Doc,"__fb__.Width = 100.0"); doCommand(Doc,"__fb__.Height = 100.0"); doCommand(Doc,"del __fb__"); commitCommand(); updateActive(); }
void ledseqRun(led_t led, const ledseq_t *sequence) { int prio = getPrio(sequence); if(prio<0) return; xSemaphoreTake(ledseqSem, portMAX_DELAY); state[led][prio] = 0; //Reset the seq. to its first step updateActive(led); xSemaphoreGive(ledseqSem); //Run the first step if the new seq is the active sequence if(activeSeq[led] == prio) runLedseq(timer[led]); }
void CmdPartImportCurveNet::activated(int iMsg) { QStringList filter; filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)"); filter << QObject::tr("STEP (*.stp *.step)"); filter << QObject::tr("IGES (*.igs *.iges)"); filter << QObject::tr("BREP (*.brp *.brep)"); filter << QObject::tr("All Files (*.*)"); QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); if (!fn.isEmpty()) { QFileInfo fi; fi.setFile(fn); openCommand("Part Import Curve Net"); doCommand(Doc,"f = App.activeDocument().addObject(\"Part::CurveNet\",\"%s\")", (const char*)fi.baseName().toAscii()); doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toAscii()); commitCommand(); updateActive(); } }
void CmdPartDefeaturing::activated(int iMsg) { Q_UNUSED(iMsg); Gui::WaitCursor wc; Base::Type partid = Base::Type::fromName("Part::Feature"); std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx(0, partid); openCommand("Defeaturing"); for (std::vector<Gui::SelectionObject>::iterator it = objs.begin(); it != objs.end(); ++it) { try { std::string shape; shape.append("sh=App."); shape.append(it->getDocName()); shape.append("."); shape.append(it->getFeatName()); shape.append(".Shape\n"); std::string faces; std::vector<std::string> subnames = it->getSubNames(); for (std::vector<std::string>::iterator sub = subnames.begin(); sub != subnames.end(); ++sub) { faces.append("sh."); faces.append(*sub); faces.append(","); } doCommand(Doc,"\nsh = App.getDocument('%s').%s.Shape\n" "nsh = sh.defeaturing([%s])\n" "if not sh.isPartner(nsh):\n" "\t\tdefeat = App.ActiveDocument.addObject('Part::Feature','Defeatured').Shape = nsh\n" "\t\tGui.ActiveDocument.%s.hide()\n" "else:\n" "\t\tFreeCAD.Console.PrintError('Defeaturing failed\\n')", it->getDocName(), it->getFeatName(), faces.c_str(), it->getFeatName()); } catch (const Base::Exception& e) { Base::Console().Warning("%s: %s\n", it->getFeatName(), e.what()); } } commitCommand(); updateActive(); }
void CmdRaytracingNewPartSegment::activated(int iMsg) { std::vector<Part::Feature*> parts = Gui::Selection().getObjectsOfType<Part::Feature>(); if (parts.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select a Part object.")); return; } std::vector<App::DocumentObject*> pages = App::GetApplication().getActiveDocument() ->getObjectsOfType(Raytracing::RayProject::getClassTypeId()); if (pages.empty()) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No Povray project to insert"), QObject::tr("Create a Povray project to insert a view.")); return; } std::string ProjName; if (pages.size() > 1) { pages = Gui::Selection().getObjectsOfType(Raytracing::RayProject::getClassTypeId()); if (pages.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No Povray project to insert"), QObject::tr("Select a Povray project to insert the view.")); return; } } ProjName = pages.front()->getNameInDocument(); openCommand("Create view"); for (std::vector<Part::Feature*>::iterator it = parts.begin(); it != parts.end(); ++it) { std::string FeatName = (*it)->getNameInDocument(); FeatName += "_View"; FeatName = getUniqueObjectName(FeatName.c_str()); doCommand(Doc,"App.activeDocument().addObject('Raytracing::RayFeature','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Color = Gui.activeDocument().%s.ShapeColor",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",ProjName.c_str(), FeatName.c_str()); } updateActive(); commitCommand(); }
void CmdPartSimpleCopy::activated(int iMsg) { Base::Type partid = Base::Type::fromName("Part::Feature"); std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(partid); openCommand("Create Copy"); for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) { doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape=" "App.ActiveDocument.%s.Shape\n" "App.ActiveDocument.ActiveObject.Label=" "App.ActiveDocument.%s.Label\n", (*it)->getNameInDocument(), (*it)->getNameInDocument(), (*it)->getNameInDocument()); copyVisual("ActiveObject", "ShapeColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "LineColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "PointColor", (*it)->getNameInDocument()); } commitCommand(); updateActive(); }
void WidgetSelection::setWidget(QWidget *w) { if (m_widget != 0) m_widget->removeEventFilter(this); if (w == 0) { hide(); m_widget = 0; return; } m_widget = w; m_widget->installEventFilter(this); updateActive(); updateGeometry(); show(); }
void CmdPartDesignPart::activated(int iMsg) { Q_UNUSED(iMsg); if ( !PartDesignGui::assureModernWorkflow( getDocument() ) ) return; openCommand("Add a part"); std::string FeatName = getUniqueObjectName("Part"); std::string PartName; PartName = getUniqueObjectName("Part"); doCommand(Doc,"App.activeDocument().Tip = App.activeDocument().addObject('App::Part','%s')",PartName.c_str()); // TODO We really must to set label ourselfs? (2015-08-17, Fat-Zer) doCommand(Doc,"App.activeDocument().%s.Label = '%s'", PartName.c_str(), QObject::tr(PartName.c_str()).toUtf8().data()); doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PARTKEY, PartName.c_str()); updateActive(); }
void CmdPointsImport::activated(int iMsg) { QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString::null, QString(), QObject::tr("Ascii Points (*.asc);;All Files (*.*)")); if ( fn.isEmpty() ) return; if (! fn.isEmpty() ) { QFileInfo fi; fi.setFile(fn); openCommand("Points Import Create"); doCommand(Doc,"f = App.ActiveDocument.addObject(\"Points::ImportAscii\",\"%s\")", (const char*)fi.baseName().toAscii()); doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toAscii()); commitCommand(); updateActive(); } }
/* Center of the led sequence machine. This function is executed by the FreeRTOS * timer and runs the sequences */ static void runLedseq( xTimerHandle xTimer ) { led_t led = (led_t)pvTimerGetTimerID(xTimer); const ledseq_t *step; bool leave=false; if (!ledseqEnabled) return; while(!leave) { int prio = activeSeq[led]; if (prio == LEDSEQ_STOP) return; step = &sequences[prio][state[led][prio]]; state[led][prio]++; xSemaphoreTake(ledseqSem, portMAX_DELAY); switch(step->action) { case LEDSEQ_LOOP: state[led][prio] = 0; break; case LEDSEQ_STOP: state[led][prio] = LEDSEQ_STOP; updateActive(led); break; default: //The step is a LED action and a time ledSet(led, step->value); if (step->action == 0) break; xTimerChangePeriod(xTimer, M2T(step->action), 0); xTimerStart(xTimer, 0); leave=true; break; } xSemaphoreGive(ledseqSem); } }
LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp) { LLMemType mt(LLMemType::MTYPE_OBJECT); LLUUID fullid; fullid.generate(); LLViewerObject *objectp = LLViewerObject::createObject(fullid, pcode, regionp); if (!objectp) { // llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << llendl; return NULL; } mUUIDObjectMap[fullid] = objectp; mObjects.put(objectp); updateActive(objectp); return objectp; }
void CmdPathShape::activated(int iMsg) { std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection(); if (Sel.size() == 1) { if (Sel[0].pObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { Part::Feature *pcPartObject = dynamic_cast<Part::Feature*>(Sel[0].pObject); std::string FeatName = getUniqueObjectName("PathShape"); openCommand("Create Path Compound"); doCommand(Doc,"FreeCAD.activeDocument().addObject('Path::FeatureShape','%s')",FeatName.c_str()); doCommand(Doc,"FreeCAD.activeDocument().%s.Shape = FreeCAD.activeDocument().%s.Shape.copy()",FeatName.c_str(),pcPartObject->getNameInDocument()); commitCommand(); updateActive(); } else { Base::Console().Error("Exactly one shape object must be selected\n"); return; } } else { Base::Console().Error("Exactly one shape object must be selected\n"); return; } }