int main(int argc, char *argv[]) { int result = 0; QGuiApplication *app = SailfishApp::application(argc, argv); QQuickView *view = SailfishApp::createView(); qmlRegisterType<PlotWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "PlotWidget"); qmlRegisterType<SatellitePosWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatellitePosWidget"); qmlRegisterType<SatelliteStrengthWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatelliteStrengthWidget"); QTimer refreshTimer; Accelerometer accelerometer(false); Gyroscope gyroscope(false); Magnetometer magnetometer(false); Rotation rotation(false); Light light(false); Proximity proximity(true); SatelliteInfo satelliteinfo; Position position; // connect not self-refreshing sensors to the global timer QObject::connect(&refreshTimer, SIGNAL(timeout()), &accelerometer, SLOT(refresh())); QObject::connect(&refreshTimer, SIGNAL(timeout()), &gyroscope, SLOT(refresh())); QObject::connect(&refreshTimer, SIGNAL(timeout()), &magnetometer, SLOT(refresh())); QObject::connect(&refreshTimer, SIGNAL(timeout()), &rotation, SLOT(refresh())); QObject::connect(&refreshTimer, SIGNAL(timeout()), &light, SLOT(refresh())); QString qml = QString("qml/%1.qml").arg("Messwerk"); view->rootContext()->setContextProperty("accelerometer", &accelerometer); view->rootContext()->setContextProperty("gyroscope", &gyroscope); view->rootContext()->setContextProperty("magnetometer", &magnetometer); view->rootContext()->setContextProperty("rotationsensor", &rotation); view->rootContext()->setContextProperty("lightsensor", &light); view->rootContext()->setContextProperty("proximitysensor", &proximity); view->rootContext()->setContextProperty("satelliteinfo", &satelliteinfo); view->rootContext()->setContextProperty("positionsensor", &position); view->rootContext()->setContextProperty("settings", &(Settings::instance())); view->setSource(SailfishApp::pathTo(qml)); view->show(); refreshTimer.start(100); result = app->exec(); delete view; delete app; return result; }
int32_t rice::pastry::direct::DirectPastryNodeFactory_getNodeHandleAdapter_2::proximity(::java::lang::Object* i, ::java::util::Map* options) { return proximity(dynamic_cast< ::rice::pastry::NodeHandle* >(i), options); }
int32_t rice::pastry::transport::NodeHandleAdapter::proximity(::java::lang::Object* i, ::java::util::Map* options) { return proximity(dynamic_cast< ::rice::pastry::NodeHandle* >(i), options); }
double GACPforORGSolverGene::fitness( ) { if( fit==-1 ) { Word newWord = theWord2; Word relator = theGroup.relator(); for( int pos=theWord2.length()-1 ; pos>=0 ; pos-- ) { for( unsigned c=0 ; c<lengthes[pos] ; ++c ) { GACPforORGSolverChromosome *chr = chromosomes[pos][c]; Word w1; if( chr->deg ) w1 = chr->con * relator * chr->con.inverse( ); else w1 = chr->con * relator.inverse( ) * chr->con.inverse( ); GAConjProblemForORGroupSolver::insert( newWord , w1 , pos ); } } newWord = GAConjProblemForORGroupSolver::greedyReduce( theGroup , newWord ); //if new word shorter than second word if( newWord.length( )<theWord2.length( ) ) { hasShorterWords = true; //if newWord shorter than first word, change their places if( newWord.length()<theWord1.length() ) { *this = GACPforORGSolverGene( theGroup , newWord , theWord1 ); // here you needn't to check gene, because this function was invoked in Solver::tournament() // and if flag hasShorterWords sets, it invoke toStart() func., that resets all genes // check( ); fit = proximity( theWord1 , theWord2 ); } else { *this = GACPforORGSolverGene( theGroup , theWord1 , newWord ); // here you needn't to check gene, because this function was invoked in Solver::tournament() // and if flag hasShorterWords sets, it invoke toStart() func., that resets all genes // check( ); fit = proximity( theWord1 , theWord2 ); } } else { int c1 , c2; fit = proximity( theWord1 , newWord , &c1 , &c2 ); //int L = theWord2.length( )-theWord1.length(); //L>=0 always //There's two way //if reduced more than half of words, I do conjecture that other two parts are equal //if obtained a pair like ( w , w x ), I do conjecture that x==1 if( fit/(theWord2.length( )+theWord1.length()) < 0.5 && theWord2.length( )+theWord1.length()>10 && //prev. condition (line) may be changed by next condition (line), prev. condition stronger than next one //fit<=L && fit!=0 && theWord1.length( )>3 ) { Word conjWord1; Word conjWord2 = ( theWord1.inverse( ).cyclicallyPermute(c1) * newWord.cyclicallyPermute(c2) ); conjWord2 = conjWord2.freelyReduce(); hasConjecture = true; conjectureWord = conjWord2; } } } return fit; }
void DiagramCanvas::mousePressEvent(QMouseEvent *e) { if (readOnly) { for( int i = 0; i<edgeList.size();i++) if (proximity(e->pos(),edgeList[i]) && edgeList[i]->edge_type == singular ) emit selectionChanged( edgeList[i]->arc_id ); return; } untouched = FALSE; if (e->button() == LeftButton ) { if (edge_creation_in_progress) { int vertex_index; if (completed_edge_general_position(currentEdge, &vertex_index )) { if (joinState == join) { Vertex *vertex, *new_vertex; vertex = vertexList[vertex_index]; paint( currentEdge, TRUE ); currentEdge->vertex[end]->~Vertex(); currentEdge->vertex[end] = vertex; EndData *ed = new EndData( currentEdge, end ); vertex->incidentEndData.insert( vertex->incidentEndData.end(), ed ); edgeList.insert( edgeList.end(), currentEdge ); new_vertex = NULL; Edge *edge = currentEdge; currentEdge = NULL; edge_creation_in_progress = FALSE; assign_arcs(); assign_links(); assign_new_crossings( edge); paint( edge, FALSE ); } else { Vertex *vertex, *new_vertex; vertex = currentEdge->vertex[end]; vertexList.insert( vertexList.end(), vertex ); edgeList.insert( edgeList.end(), currentEdge ); new_vertex = new Vertex( vertex->position ); Edge *edge = currentEdge; currentEdge = new Edge( vertex, new_vertex ); currentEdge->edge_type = (drill_on) ? drilled : singular; edge_creation_in_progress = TRUE; assign_arcs(); assign_links(); assign_new_crossings( edge ); } } } else { int vertex_index; if (new_point_general_position(e->pos(), &vertex_index )) { if (joinState == join) { Vertex *vertex, *new_vertex; vertex = vertexList[vertex_index]; new_vertex = new Vertex( vertex->position ); currentEdge = new Edge( vertex, new_vertex); currentEdge->edge_type = (drill_on) ? drilled : singular; edge_creation_in_progress = TRUE; assign_arcs(); assign_links(); } else { Vertex *new_vertex1, *new_vertex2; new_vertex1 = new Vertex( e->pos() ); vertexList.insert( vertexList.end(), new_vertex1 ); new_vertex2 = new Vertex( e->pos() ); currentEdge = new Edge( new_vertex1, new_vertex2); currentEdge->edge_type = (drill_on) ? drilled : singular; edge_creation_in_progress = TRUE; assign_arcs(); assign_links(); } } else { bool close_to_crossing = FALSE; int i; for( i = 0; i<crossingList.size();i++) if (proximity(e->pos(),crossingList[i]->position)) { crossingList[i]->switchCrossing(); update(); close_to_crossing = TRUE; } if (!close_to_crossing) for( i = 0; i<edgeList.size();i++) if (proximity(e->pos(),edgeList[i])) invert_arc(edgeList[i]); } } } if (e->button() == RightButton ) { if (edge_creation_in_progress) { Vertex *vertex; paint( currentEdge, TRUE ); vertex = currentEdge->vertex[begin]; currentEdge->vertex[end]->~Vertex(); currentEdge->~Edge(); if (vertex->incidentEndData.size() == 1) { vector<Vertex *>::iterator v_it; v_it = vertexList.begin(); while( v_it != vertexList.end() ) if (*v_it == vertex) break; else v_it++; (*v_it)->~Vertex(); vertexList.erase(v_it); } else { vector<EndData *>::iterator ed_it; ed_it = vertex->incidentEndData.end() - 1; (*ed_it)->~EndData(); vertex->incidentEndData.erase( ed_it); } edge_creation_in_progress = FALSE; assign_arcs(); assign_links(); } else { int i; bool action_taken = FALSE; for( i = 0; i<crossingList.size();i++) if (proximity(e->pos(),crossingList[i]->position)) { crossingList[i]->switchCrossing(); update(); action_taken = TRUE; } if (!action_taken) for( i = 0; i<vertexList.size();i++) if (proximity(e->pos(),vertexList[i]->position)) { draggedVertex = vertexList[i]; saved_vertex_position = draggedVertex->position; delete_dragged_crossings(); vertex_drag_in_progress = TRUE; action_taken = TRUE; } if (!action_taken) for( i = 0; i<edgeList.size();i++) if (proximity(e->pos(),edgeList[i])) { if (edgeList[i]->selected) { paint( edgeList[i], TRUE ); edgeList[i]->selected = FALSE; edgeList[i]->thickness = THIN; paint( edgeList[i], FALSE); } else { paint( edgeList[i], TRUE ); edgeList[i]->selected = TRUE; edgeList[i]->thickness = THICK; paint( edgeList[i], FALSE); } update(); } } } if (e->button() == MidButton ) emit drillToggled(); }
void DiagramCanvas::mouseMoveEvent(QMouseEvent *e) { int i; bool status_bar_changed = FALSE, near_vertex = FALSE; QString status; setCursor(Qt::arrowCursor); if (edge_creation_in_progress) if (!completed_edge_general_position(currentEdge, &i )) { status.sprintf(" Right click to kill cord."); status_bar_changed = TRUE; } for(i=0;i<vertexList.size();i++) if (proximity(e->pos(),vertexList[i]->position)) { near_vertex = TRUE; setCursor(Qt::pointingHandCursor); if (!status_bar_changed && !edge_creation_in_progress) { if (vertexList[i]->link_id == -1) { if (!readOnly) status.sprintf("Right click and drag to move."); } else status.sprintf(" Vertex:\t%d", vertexList[i]->link_id+1 ); status_bar_changed = TRUE; } } if (!edge_creation_in_progress && !status_bar_changed && !near_vertex ) for(i=0;i<edgeList.size();i++) if (proximity(e->pos(),edgeList[i])) { setCursor(Qt::pointingHandCursor); if (edgeList[i]->edge_type == singular) status.sprintf(" Coloured Edge:\t%d", edgeList[i]->arc_id+1); else if (readOnly && edgeList[i]->cuff_id > -1 ) status.sprintf(" Vertex:\t%d\tCuff:\t%d", edgeList[i]->link_id+1, edgeList[i]->cuff_id+1); else status.sprintf(" Vertex:\t%d", edgeList[i]->link_id+1); status_bar_changed = TRUE; } if (edge_creation_in_progress) redrawMovedEdge( e ); else for(i=0;i<crossingList.size();i++) if (!readOnly && proximity(e->pos(),crossingList[i]->position)) { setCursor(Qt::pointingHandCursor); status.sprintf(" Click to switch crossing."); status_bar_changed = TRUE; } if (vertex_drag_in_progress) redrawDraggedVertex( e ); if (!status_bar_changed) status.sprintf(" "); emit statusBarChanged(status); }