/** \brief \author Peter G Baum, William J Giddings \date **/ int labelFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onChanged", "class", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnChangedIdx, ClassIdx}; LabelParams *para = ( LabelParams * ) data; GtkWidget *widget = GTK_WIDGET ( para->label ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case ClassIdx: Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "label", -1 ) ); break; case DeleteIdx: return gnoclDelete ( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, labelOptions, G_OBJECT ( widget ) ) == TCL_OK ) { ret = configure ( interp, para, labelOptions ); } gnoclClearOptions ( labelOptions ); return ret; } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( para->label ), labelOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, para, labelOptions, idx ); } } case OnChangedIdx: { const char *txt = gtk_label_get_text ( para->label ); if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } return doCommand ( para, txt, 0 ); } } return TCL_OK; }
result_t Redis::getRange(const char *key, int32_t start, int32_t end, std::string &retVal) { return doCommand("GETRANGE", key, start, end, retVal); }
result_t Redis::bitcount(const char *key, int32_t start, int32_t end, int32_t &retVal) { return doCommand("BITCOUNT", key, start, end, retVal); }
result_t Redis::msetNX(v8::Local<v8::Array> kvs) { Variant v; return doCommand("MSETNX", kvs, v); }
result_t Redis::append(const char *key, const char *value, int32_t &retVal) { return doCommand("APPEND", key, value, retVal); }
/** * Received when user clicks the Change Association button. */ void NicksOnline::slotChangeAssociationButton_Clicked() { doCommand(ciAddressbookChange); }
/** * Received from popup menu when user chooses something. */ void NicksOnline::slotPopupMenu_Activated(int id) { doCommand(id); }
result_t Redis::pub(Buffer_base *channel, Buffer_base *message, int32_t &retVal) { return doCommand("PUBLISH", channel, message, retVal); }
int main(int argc, char **argv) { int status, i, j; rErrMsg_t errMsg; rodsArguments_t myRodsArgs; char *mySubName; char *myName; int argOffset; int maxCmdTokens=20; char *cmdToken[20]; int keepGoing; int firstTime; rodsLogLevel(LOG_ERROR); status = parseCmdLineOpt (argc, argv, "vVhgrcGRCdulz:", 0, &myRodsArgs); if (status) { printf("Use -h for help.\n"); exit(1); } if (myRodsArgs.help==True) { usage(""); exit(0); } if (myRodsArgs.zone==True) { strncpy(zoneArgument, myRodsArgs.zoneName, MAX_NAME_LEN); } if (myRodsArgs.longOption) { longMode=1; } argOffset = myRodsArgs.optind; if (argOffset > 1) { if (argOffset > 2) { if (*argv[1]=='-' && *(argv[1]+1)=='z') { if (*(argv[1]+2)=='\0') { argOffset=3; /* skip -z zone */ } else { argOffset=2; /* skip -zzone */ } } else { argOffset=1; /* Ignore the parseCmdLineOpt parsing as -d etc handled below*/ } } else { argOffset=1; /* Ignore the parseCmdLineOpt parsing as -d etc handled below*/ } } status = getRodsEnv (&myEnv); if (status < 0) { rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d", status); exit (1); } strncpy(cwd,myEnv.rodsCwd,BIG_STR); if (strlen(cwd)==0) { strcpy(cwd,"/"); } for (i=0;i<maxCmdTokens;i++) { cmdToken[i]=""; } j=0; for (i=argOffset;i<argc;i++) { cmdToken[j++]=argv[i]; } #if defined(linux_platform) /* imeta cp -d TestFile1 -d TestFile3 comes in as: -d -d cp TestFile1 TestFile3 so switch it to: cp -d -d TestFile1 TestFile3 */ if (cmdToken[0]!=NULL && *cmdToken[0]=='-') { /* args were toggled, switch them back */ if (cmdToken[1]!=NULL && *cmdToken[1]=='-') { cmdToken[0]=argv[argOffset+2]; cmdToken[1]=argv[argOffset]; cmdToken[2]=argv[argOffset+1]; } else { cmdToken[0]=argv[argOffset+1]; cmdToken[1]=argv[argOffset]; } } #else /* tested on Solaris, not sure other than Linux/Solaris */ /* imeta cp -d TestFile1 -d TestFile3 comes in as: cp -d TestFile1 -d TestFile3 so switch it to: cp -d -d TestFile1 TestFile3 */ if (cmdToken[0]!=NULL && cmdToken[1]!=NULL && *cmdToken[1]=='-' && cmdToken[2]!=NULL && cmdToken[3]!=NULL && *cmdToken[3]=='-') { /* two args */ cmdToken[2]=argv[argOffset+3]; cmdToken[3]=argv[argOffset+2]; } #endif if (strcmp(cmdToken[0],"help")==0 || strcmp(cmdToken[0],"h") == 0) { usage(cmdToken[1]); exit(0); } if (strcmp(cmdToken[0],"spass") ==0) { char scrambled[MAX_PASSWORD_LEN+100]; if (strlen(cmdToken[1])>MAX_PASSWORD_LEN-2) { printf("Password exceeds maximum length\n"); } else { obfEncodeByKey(cmdToken[1], cmdToken[2], scrambled); printf("Scrambled form is:%s\n", scrambled); } exit(0); } Conn = rcConnect (myEnv.rodsHost, myEnv.rodsPort, myEnv.rodsUserName, myEnv.rodsZone, 0, &errMsg); if (Conn == NULL) { myName = rodsErrorName(errMsg.status, &mySubName); rodsLog(LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg); exit (2); } status = clientLogin(Conn); if (status != 0) { if (!debug) exit (3); } keepGoing=1; firstTime=1; while (keepGoing) { int status; status=doCommand(cmdToken); if (status==-1) keepGoing=0; if (firstTime) { if (status==0) keepGoing=0; if (status==-2) { keepGoing=0; lastCommandStatus=-1; } firstTime=0; } if (keepGoing) { getInput(cmdToken, maxCmdTokens); } } printErrorStack(Conn->rError); rcDisconnect(Conn); if (lastCommandStatus != 0) exit(4); exit(0); }
void Mine::evaluate(RobotCommands commandList) { for (auto c : commandList) doCommand(c); }
void CmdRaytracingWriteCamera::activated(int iMsg) { const char* ppReturn=0; getGuiApplication()->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; } } SoInput in; in.setBuffer((void*)ppReturn,std::strlen(ppReturn)); SoNode* rootNode; SoDB::read(&in,rootNode); if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId())) throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read " "camera information from ASCII stream....\n"); // root-node returned from SoDB::readAll() has initial zero // ref-count, so reference it before we start using it to // avoid premature destruction. SoCamera * Cam = static_cast<SoCamera*>(rootNode); Cam->ref(); SbRotation camrot = Cam->orientation.getValue(); SbVec3f upvec(0, 1, 0); // init to default up vector camrot.multVec(upvec, upvec); SbVec3f lookat(0, 0, -1); // init to default view direction vector camrot.multVec(lookat, lookat); SbVec3f pos = Cam->position.getValue(); float Dist = Cam->focalDistance.getValue(); 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(); // building up the python string std::stringstream out; out << "Raytracing.writeCameraFile(\"" << strToPython(cFullName) << "\"," << "(" << pos.getValue()[0] <<"," << pos.getValue()[1] <<"," << pos.getValue()[2] <<")," << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," ; lookat *= Dist; lookat += pos; out << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," << "(" << upvec.getValue()[0] <<"," << upvec.getValue()[1] <<"," << upvec.getValue()[2] <<") )" ; doCommand(Doc,"import Raytracing"); doCommand(Gui,out.str().c_str()); // Bring ref-count of root-node back to zero to cause the // destruction of the camera. Cam->unref(); }
bool CanalSharedMemLevel1::doCmdOpen( const wxString& strInterface, unsigned long flags ) { bool rv = true; // return value struct __shmOpen *pListenShMemArea; int shmid; struct sembuf sb; key_t cmdkey = IPC_LISTEN_SHM_KEY; if ( -1 == ( shmid = shmget( cmdkey, 0, 0 ) ) ) { ::wxLogDebug( _("CanalSharedMemLevel1: Failed to open Listen Command semaphore") ); return false; } if ( -1 == (long)( pListenShMemArea = (struct __shmOpen *)shmat( shmid, NULL, 0 ) ) ) { ::wxLogDebug( _("CanalSharedMemLevel1: Failed to open Listen Done semaphore.") ); return false; } int semListenObj; key_t semkey = IPC_LISTEN_SEM_KEY; // Semaphore 1 - access to shared memory // Semaphore 2 - valid command semListenObj = semget( semkey, 0, 0 ); if ( -1 == semListenObj ) { shmdt( pListenShMemArea); ::wxLogDebug( _("CanalSharedMemLevel1: Failed to open Listen Command semaphore.") ); return false; } // Get access to Listenthread common resources sb.sem_num = LISTEN_SEM_RESOURCE; sb.sem_op = -1; sb.sem_flg = 0; semop( semListenObj, &sb, 1 ); // Write Command pListenShMemArea->m_command = CANAL_COMMAND_OPEN_VSCP_LEVEL1; pListenShMemArea->m_flags = flags; if ( strInterface.Length() ) { memcpy( pListenShMemArea->m_strIfName, strInterface, strInterface.Length() ); } // Execute command on server sb.sem_num = LISTEN_SEM_COMMAND; sb.sem_op = 1; sb.sem_flg = 0; semop( semListenObj, &sb, 1 ); if ( !pListenShMemArea->m_cmdResult ) { // Give the server thread some time to start usleep( 1000 ); // Get the client command memory area if ( -1 == (long)( m_pCommandMem = shmat( pListenShMemArea->m_shmid, NULL, 0 ) ) ) { // Failed to get shared memory ::wxLogError(_("CanalSharedMemLevel1: Could not get shared memory. %d"), pListenShMemArea->m_shmid); rv = false; } else { // Save a pointer to the command structure m_pLevel1 = (struct __shmCanalLevelI *)m_pCommandMem; // Wait for server thread to give clearence int cnt = 0; while( 0xaa55 != m_pLevel1->m_test ) { sleep( 1 ); cnt++; if ( cnt > 3 ) { ::wxLogError(_("Appers to be no client thread\n")); // Release listen thread resources we are done with them sb.sem_num = LISTEN_SEM_RESOURCE; sb.sem_op = 1; sb.sem_flg = 0; semop( semListenObj, &sb, 1 ); // No need for memory anymore shmdt( pListenShMemArea ); return false; } } // Get the clinet semaphore m_semCommand = m_pLevel1->m_semCmd; // Go on m_pLevel1->m_test = 0x55aa; // We have an open channel! // Do a dummy Open of interface doCommand( CANAL_COMMAND_OPEN ); } } else { ::wxLogError(_("Cmd result error\n")); rv = false; } // Release listen thread resources we are done with them sb.sem_num = LISTEN_SEM_RESOURCE; sb.sem_op = 1; sb.sem_flg = 0; semop( semListenObj, &sb, 1 ); // release listthread sh memory shmdt( pListenShMemArea ); return rv; }
void DevConsole::on_edit_command_returnPressed() { doCommand(); }
void DevConsole::on_button_send_clicked() { doCommand(); }
/* * ======== apLoop ======== */ __extern void apLoop() { /* Did a client connect/disconnect since the last time we checked? */ int a = WiFi.getTotalDevices(); if (a != num_clients) { if (a > num_clients) { // new Client connected int i; digitalWrite(MAIN_LED_PIN, !digitalRead(MAIN_LED_PIN)); /* display all clients on the network */ Serial.println("New client connected. All clients:"); for (i = 0; i < a; i++) { Serial.print(" Client #"); Serial.print(i); Serial.print(" at IP address = "); Serial.print(WiFi.deviceIpAddress(i)); Serial.print(", MAC = "); Serial.println(WiFi.deviceMacAddress(i)); } } else { // a Client disconnected digitalWrite(MAIN_LED_PIN, !digitalRead(MAIN_LED_PIN)); Serial.print("Client disconnected, "); Serial.print(a); Serial.println(" clients remaining."); } num_clients = a; } if (num_clients > 0) { /* listen for incoming clients */ WiFiClient client = server.available(); if (client) { /* if there's a client, read and process commands */ Serial.print("new client socket: "); Serial.println(++num_sockets); static char buffer[64] = {0}; int bufLen = 0; /* while connected to the client, read commands and send results */ unsigned int lapse = 0; unsigned int start = millis(); while (client.connected()) { /* if there's a byte to read from the client .. */ if (client.available()) { /* copy it to the command buffer, byte at a time */ char c = client.read(); /* ignore bogus characters */ if (c == '\0' || c == '\r') continue; /* never overrun the command buffer */ if (bufLen >= (int)(sizeof (buffer))) { bufLen = sizeof (buffer) - 1; } buffer[bufLen++] = c; //Serial.print(num_sockets); Serial.print(": "); //Serial.println((int)c); /* if there's a new line, we have a complete command */ if (c == '\n') { doCommand(buffer, bufLen, client); /* reset command buffer index to get next command */ bufLen = 0; } lapse = 0; start = millis(); } else { lapse = millis() - start; } } Serial.print("client socket disconnected: lapse = "); Serial.println(lapse); /* client disconnected or timed out, close the connection */ client.stop(); /* disconnect => implicitly stop the motor */ motorWASD = ' '; } } /* check for new connections 2 times per second */ delay(500); }
int main(int argc, char* argv[]) { // verify input u8 command = 0; std::string target = ""; //parse commands if (0 == strcmp(argv[0], "unsnag")) { if (argc < 2) { std::cerr << "ERROR: you didn't provide a server. "; std::cerr << "Type snag -h for help" << std::endl; return 1; } command = unsnag; target = argv[1]; } else if (argc == 1) { command = list; } else if (argc == 2) { if (0 == strcmp(argv[1], "-l")) { command = list; } else if (0 == strcmp(argv[1], "-h")) { command = help; } else if (0 == strcmp(argv[1], "-u") || 0 == strcmp(argv[1], "-a") || 0 == strcmp(argv[1], "-d")) { std::cerr << "ERROR: you didn't provide a server. "; std::cerr << "Type snag -h for help" << std::endl; return 1; } else if (argv[1][0] == '-') { std::cerr << "ERROR: unknown command '" << argv[1] << "', "; std::cerr << "Type snag -h for help" << std::endl; return 1; } else { command = snag; target = argv[1]; } } else if (argc > 2) { if (0 == strcmp(argv[1], "-l")) { command = list; std::cerr << "TIP: list command takes no arguments." << std::endl; } else if (0 == strcmp(argv[1], "-h")) { command = help; std::cerr << "TIP: help command takes no arguments." << std::endl; } else if (0 == strcmp(argv[1], "-u")) { command = unsnag; target = argv[2]; } else if (0 == strcmp(argv[1], "-a")) { command = add; target = argv[2]; } else if (0 == strcmp(argv[1], "-d")) { command = del; target = argv[2]; } else { std::cerr << "ERROR: invalid command '" << argv[1] << "', "; std::cerr << "Type snag -h for help" << std::endl; return 1; } } // perform commands if (command == help) { helpCommand(); return 0; } Socket clientSocket = connectToServer(); if (clientSocket == -1) { return 1; } char clientNameBuffer[20]; getlogin_r(clientNameBuffer, 20); std::string clientName(clientNameBuffer); switch(command) { case list: listCommand(clientSocket); return 0; break; case snag: doCommand("s", clientSocket, target, clientName); break; case unsnag: doCommand("u", clientSocket, target, clientName); break; case add: doCommand("a", clientSocket, target, clientName); break; case del: doCommand("d", clientSocket, target, clientName); break; } // get server reply std::cout << std::endl; char buffer[1024]; memset(buffer, 0, 1024); int readLen = read(clientSocket, buffer, 2048); if (readLen < 0) { std::cerr << "ERROR reading from socket" << std::endl; return 1; } std::cout << buffer << std::endl; std::cout << std::endl; } // end main
void TeamDialog::onCommand(EventCommand* event) { if (event->getSender() == m_Ok) doCommand(); }
static int spinButtonFunc( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onValueChanged", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnValueChangedIdx }; SpinButtonParams *para = (SpinButtonParams *)data; GtkWidget *widget = GTK_WIDGET( para->spinButton ); int idx; if( objc < 2 ) { Tcl_WrongNumArgs( interp, 1, objv, "command" ); return TCL_ERROR; } if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case DeleteIdx: return gnoclDelete( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if( gnoclParseOptions( interp, objc - 1, objv + 1, spinButtonOptions ) == TCL_OK ) { ret = configure( interp, para, spinButtonOptions ); } gnoclClearOptions( spinButtonOptions ); return ret; } break; case CgetIdx: { int idx; switch( gnoclCget( interp, objc, objv, G_OBJECT( para->spinButton ), spinButtonOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget( interp, para, spinButtonOptions, idx ); } } case OnValueChangedIdx: { if( objc != 2 ) { Tcl_WrongNumArgs( interp, 2, objv, NULL ); return TCL_ERROR; } return doCommand( para, getObjValue( para->spinButton ), 0 ); } } return TCL_OK; }
/** * Received when user clicks the Delete Association button. */ void NicksOnline::slotDeleteAssociationButton_Clicked() { doCommand(ciAddressbookDelete); }
int main( void ) { int c; u8 pos = 0; // Position in buffer u8 atstate = WAITING_FOR_A; // AT-state initHardware(); uart0Init( B115200 ); //uart0Init(B2x115200); // Double speed sja1000_init(); sei(); uart0BlockingPuts( "\r\n" IDSTR "\r\n" ); for ( ;; ) { // Give the dog a bone wdt_reset(); if ( -1 != ( c = uart0Getch() ) ) { if ( OFF_LINE == gmode ) { // echo character uart0BlockingPutch( c ); if ( WAITING_FOR_A == atstate ) { c &= ~0x20; // -> upper case if ( 'A' == c ) { atstate = WAITING_FOR_T; } } else if ( WAITING_FOR_T == atstate ) { c &= ~0x20; // -> upper case if ( 'T' == c ) { atstate = WAITING_FOR_CR; pos = 0; } else if ( ( '/' & ~0x20 ) == c ) { // "a/" // Redo last command doCommand(); atstate = WAITING_FOR_A; } } else if ( WAITING_FOR_CR == atstate ) { // CR if ( 0x0d == c ) { gbuffer[ pos ] = 0x00; doCommand(); atstate = WAITING_FOR_A; } // Backspace else if ( 0x08 == c ) { if ( pos ) pos -= 1; } // Space else if ( 0x20 == c ) { ; // Ignore } // Tab else if ( 0x09 == c ) { ; // Ignore } else { gbuffer[ pos++ ] = c; if ( pos >= SIZE_INPUT_BUFFER ) { // Buffer FULL doResponse( FALSE, 0 ); atstate = WAITING_FOR_A; } } } else { // Invalid state doResponse( FALSE, 0 ); atstate = WAITING_FOR_A; } } else { // ON_LINE // Packet are just transfered over the // line } } // Character } // Main loop return 0; }
result_t Redis::command(const char *cmd, const v8::FunctionCallbackInfo<v8::Value> &args, v8::Local<v8::Value> &retVal) { _arg a(args, 1); return doCommand(cmd, a, retVal); }
void TransformableTool::onReflectElement(TransformableElement *element) { doCommand(new ReflectElementCommand(element)); }
result_t Redis::msetNX(const v8::FunctionCallbackInfo<v8::Value> &args) { Variant v; _arg a(args); return doCommand("MSETNX", a, v); }
void TransformableTool::onBringFrontElement(TransformableElement *element) { qreal newZOrder = scene->getNewZOrder(element, EditorScene::BringFront); doCommand(new ChangeElementZOrderCommand(element, newZOrder)); }
result_t Redis::setRange(const char *key, int32_t offset, const char *value, int32_t &retVal) { return doCommand("SETRANGE", key, offset, value, retVal); }
void TransformableTool::onMoveForwardElement(TransformableElement *element) { qreal newZOrder = scene->getNewZOrder(element, EditorScene::MoveForward); doCommand(new ChangeElementZOrderCommand(element, newZOrder)); }
result_t Redis::strlen(const char *key, int32_t &retVal) { return doCommand("STRLEN", key, retVal); }
void TransformableTool::onSendBackElement(TransformableElement *element) { qreal newZOrder = scene->getNewZOrder(element, EditorScene::SendBack); doCommand(new ChangeElementZOrderCommand(element, newZOrder)); }
result_t Redis::get(const char *key, std::string &retVal) { return doCommand("GET", key, retVal); }
void CmdPartRuledSurface::activated(int iMsg) { bool ok = false; TopoDS_Shape curve1, curve2; std::string link1, link2, obj1, obj2; Gui::SelectionFilter edgeFilter ("SELECT Part::Feature SUBELEMENT Edge COUNT 1..2"); Gui::SelectionFilter wireFilter ("SELECT Part::Feature SUBELEMENT Wire COUNT 1..2"); Gui::SelectionFilter partFilter ("SELECT Part::Feature COUNT 2"); bool matchEdge = edgeFilter.match(); bool matchWire = wireFilter.match(); if (matchEdge || matchWire) { // get the selected object const std::vector<Gui::SelectionObject>& result = matchEdge ? edgeFilter.Result[0] : wireFilter.Result[0]; // two edges from one object if (result.size() == 1) { const Part::Feature* part = static_cast<const Part::Feature*>(result[0].getObject()); const std::vector<std::string>& edges = result[0].getSubNames(); if (edges.size() != 2) { ok = false; } else { ok = true; // get the selected sub-shapes const Part::TopoShape& shape = part->Shape.getValue(); curve1 = shape.getSubShape(edges[0].c_str()); curve2 = shape.getSubShape(edges[1].c_str()); obj1 = result[0].getObject()->getNameInDocument(); link1 = edges[0]; obj2 = result[0].getObject()->getNameInDocument(); link2 = edges[1]; } } // two objects and one edge per object else if (result.size() == 2) { const Part::Feature* part1 = static_cast<const Part::Feature*>(result[0].getObject()); const std::vector<std::string>& edges1 = result[0].getSubNames(); const Part::Feature* part2 = static_cast<const Part::Feature*>(result[1].getObject()); const std::vector<std::string>& edges2 = result[1].getSubNames(); if (edges1.size() != 1 || edges2.size() != 1) { ok = false; } else { ok = true; const Part::TopoShape& shape1 = part1->Shape.getValue(); curve1 = shape1.getSubShape(edges1[0].c_str()); const Part::TopoShape& shape2 = part2->Shape.getValue(); curve2 = shape2.getSubShape(edges2[0].c_str()); obj1 = result[0].getObject()->getNameInDocument(); link1 = edges1[0]; obj2 = result[1].getObject()->getNameInDocument(); link2 = edges2[0]; } } } else if (partFilter.match()) { const std::vector<Gui::SelectionObject>& result = partFilter.Result[0]; const Part::Feature* part1 = static_cast<const Part::Feature*>(result[0].getObject()); const Part::Feature* part2 = static_cast<const Part::Feature*>(result[1].getObject()); const Part::TopoShape& shape1 = part1->Shape.getValue(); curve1 = shape1._Shape; const Part::TopoShape& shape2 = part2->Shape.getValue(); curve2 = shape2._Shape; obj1 = part1->getNameInDocument(); obj2 = part2->getNameInDocument(); if (!curve1.IsNull() && !curve2.IsNull()) { if (curve1.ShapeType() == TopAbs_EDGE && curve2.ShapeType() == TopAbs_EDGE) ok = true; if (curve1.ShapeType() == TopAbs_WIRE && curve2.ShapeType() == TopAbs_WIRE) ok = true; } } if (!ok) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("You have to select either two edges or two wires.")); return; } openCommand("Create ruled surface"); doCommand(Doc, "FreeCAD.ActiveDocument.addObject('Part::RuledSurface','Filled shape')"); doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.Curve1=(FreeCAD.ActiveDocument.%s,['%s'])" ,obj1.c_str(), link1.c_str()); doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.Curve2=(FreeCAD.ActiveDocument.%s,['%s'])" ,obj2.c_str(), link2.c_str()); commitCommand(); updateActive(); }