void Plot::drawDots(QVector< QVector<struct numCluster> > data, double n, double k, int index, int size, int number) { int j, l; QPolygonF points; QwtPlotCurve *curve; QwtSymbol *symbol; points.clear(); curve = new QwtPlotCurve();//QString("y = norm%1(x)").arg(index)); curve->setItemAttribute(QwtPlotItem::Legend, false); curve->setStyle( QwtPlotCurve::Dots ); for (l = 0; l < data.size(); l++){ if (data[l][number].cluster == index){ // ПЕРЕДЕЛАТЬ если возможно!!! Нужно, чтобы он печатал сразу для всех кластеров одной л.п. if (index == 0 && data[l][number].number < n){ points << QPointF(data[l][number].number, 1); }else if (index == size - 1 && data[l][number].number > n){ points << QPointF(data[l][number].number, 1); }else{ points << QPointF(data[l][number].number, func_normal(data[l][number].number,n,k)); } //std::cout << index << "data = " << data[l][i].number << std::endl; } } curve->setSamples(points); switch (index % 5){ case 0: symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::yellow ), QPen( Qt::red, 1 ), QSize( 8, 8 ) ); curve->setSymbol(symbol); break; case 1: symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::green ), QPen( Qt::red, 1 ), QSize( 8, 8 ) ); curve->setSymbol(symbol); break; case 2: symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::cyan ), QPen( Qt::red, 1 ), QSize( 8, 8 ) ); curve->setSymbol(symbol); break; case 3: symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::magenta ), QPen( Qt::red, 1 ), QSize( 8, 8 ) ); curve->setSymbol(symbol); break; case 4: symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::gray ), QPen( Qt::red, 1 ), QSize( 8, 8 ) ); curve->setSymbol(symbol); break; default: break; } curve->attach(this); this->replot(); }
// State of motor callibration FLY_STATE func_motor_callibration(void) { FLY_STATE mode = FLY_STATE_CALIB; if(fly_param.length > 0) { if(fly_param.motor[2] != 0) // release calibration mode { update_calib_data(); // mode = FLY_STATE_NORMAL; func_normal(); } { // calibration mode float acc[3]; // sensor data; button_func(button_check((unsigned char)fly_param.motor[3])); update_motor_data(); // センサーデータ取得 kx022.get_val(acc); // センサーデータの送信 Print.init(tx_data,sizeof(tx_data)); Print.p("SensorData,"); Print.f(acc[0],1); Print.p(","); Print.f(acc[1],1); Print.p(","); Print.f(acc[2],1); Print.p(","); // digitalWrite(BLUE_LED,LOW); // P56D=0; SubGHz.send(SUBGHZ_PANID,SUBGHZ_TXADDR, (unsigned char *)&tx_data, Print.len(),NULL); // digitalWrite(BLUE_LED,HIGH); // P56D=1; } } else { if((fly_param.current_time-fly_param.last_recv_time)>500) { func_waiting_zero(); mode = FLY_STATE_DETECTING_ZERO; } } return mode; }
//---------------------------------------- //テストメイン int main(const int argc, const char* argv[]) { //コンパイラ確認テスト printf("Compiler: name=\"%s\", Ver=[%d(0x%08x).%d(0x%08x)]\n", COMPILER_NAME, COMPILER_VER, COMPILER_VER, COMPILER_MINOR, COMPILER_MINOR); #ifdef IS_VC printf(" This compiler is \"Visual C++\"\n"); #endif//IS_VC #ifdef IS_GCC printf(" This compiler is \"GCC\"\n"); #endif//IS_GCC //C++言語確認テスト printf("\n"); printf("Compiler-language: %s (C++ Ver.=%d)\n", COMPILER_LANGUAGE, CPP_VER); #ifdef IS_CPP printf(" C++ is available.\n"); #endif//IS_CPP #ifdef HAS_CPP98 printf(" C++ is implemented C++98.\n"); #endif//HAS_CPP98 #ifdef HAS_CPP03 printf(" C++ is implemented C++03.\n"); #endif//HAS_CPP03 #ifdef HAS_CPP11 printf(" C++ is implemented C++11.\n"); #endif//HAS_CPP11 //プラットフォーム確認テスト printf("\n"); printf("Plataform: \"%s\"(%s %dbits, %s-endian), Ver=[%d(0x%08x).%d(0x%08x)]\n", PLATFORM_NAME, PLATFORM_ARCHITECTURE, PLATFORM_ARCHITECTURE_BITS, ENDIAN, PLATFORM_VER, PLATFORM_VER, PLATFORM_MINOR, PLATFORM_MINOR); #ifdef IS_WIN printf(" Target plarform is \"Windows\"\n"); #endif//IS_WIN #ifdef IS_LINUX printf(" Target plarform is \"Linux\"\n"); #endif//IS_LINUX #ifdef IS_CYGWIN printf(" Target plarform is \"Cygwin\"\n"); #endif//IS_CYGWIN //定義済みマクロ表示テスト struct test { static void func() { printf("\n"); printf("__FILE__=\"%s\"\n", __FILE__); printf("__LINE__=%d\n", __LINE__); printf("__FUNCTION__=\"%s\"\n", __FUNCTION__); printf("__PRETTY_FUNCTION__=\"%s\"\n", __PRETTY_FUNCTION__); printf("__FUNCSIG__=\"%s\"\n", __FUNCSIG__); printf("__func__=\"%s\"\n", __func__); printf("__FUNCDNAME__=\"%s\"\n", __FUNCDNAME__); printf("__DATE__=\"%s\"\n", __DATE__); printf("__TIME__=\"%s\"\n", __TIME__); printf("__TIMESTAMP__=\"%s\"\n", __TIMESTAMP__); printf("\n"); printf("GET_FUNC_NAME()=\"%s\"\n", GET_FUNC_NAME()); printf("GET_FILE_LINE()=\"%s\"\n", GET_FILE_LINE()); printf("GET_FILE_LINE_TIME()=\"%s\"\n", GET_FILE_LINE_TIME()); } }; test::func(); //noinline/always_inlineテスト func_normal(); func_inline(); func_noinline(); func_always_inline(); //【C++11仕様】nullptrテスト printf("\n"); printf("nullptr_var=%p\n", nullptr_var); #ifdef HAS_NULLPTR printf(" 'nullptr' is featured.\n"); #endif//HAS_NULLPTR //【C++11仕様】overrideテスト printf("\n"); override_func_var.func(); #ifdef HAS_OVERRIDE printf(" 'override' is featured.\n"); #endif//HAS_OVERRIDE //【C++11仕様】constexprテスト printf("\n"); printf("constexpr_var=%d\n", constexpr_var); printf("constexpr_calc(1, 2)=%d\n", constexpr_calc(1, 2)); #ifdef HAS_CONSTEXPR printf(" 'constexpr' is featured.\n"); #endif//HAS_CONSTEXPR //【C++11仕様】ユーザー定義リテラルテスト #ifdef HAS_USER_DEFINED_LITERAL printf("\n"); printf("user_defined_literal_var=%d\n", user_defined_literal_var); #endif//HAS_USER_DEFINED_LITERAL #ifdef HAS_USER_DEFINED_LITERAL printf(" 'operator \"\"'(user defined literal) is featured.\n"); #endif//HAS_USER_DEFINED_LITERAL //【C++11仕様】TLSテスト printf("\n"); printf("TLS Variable=%d\n", m_var_tls); #ifdef HAS_THREAD_LOCAL printf(" 'thread_local' is featured.\n"); #endif//HAS_THREAD_LOCAL //【C++11仕様】アラインメント指定/取得/指定付メモリ確保と解放テスト printf("\n"); printf("sizeof(data_t)=%d\n", sizeof(data_t)); printf("alignof(data_t)=%d\n", alignof(data_t));//アラインメント取得テスト data_t* p = reinterpret_cast<data_t*>(_aligned_malloc(sizeof(data_t), alignof(data_t))); printf("_aligned_malloc(sizeof(data_t), alignof(data_t))=%p\n", p); _aligned_free(p); printf("_aligned_free(p)\n"); #ifdef HAS_ALIGNAS printf(" 'alignas' is featured.\n"); #endif//HAS_ALIGNAS #ifdef HAS_ALIGNOF printf(" 'alignof' is featured.\n"); #endif//HAS_ALIGNOF return EXIT_SUCCESS; }