const String WebMediaConstraintsPrivate::toString() const { StringBuilder builder; if (!isEmpty()) { builder.append('{'); builder.append(basic().toString()); if (!advanced().isEmpty()) { if (builder.length() > 1) builder.appendLiteral(", "); builder.appendLiteral("advanced: ["); bool first = true; for (const auto& constraintSet : advanced()) { if (!first) builder.appendLiteral(", "); builder.append('{'); builder.append(constraintSet.toString()); builder.append('}'); first = false; } builder.append(']'); } builder.append('}'); } return builder.toString(); }
ExecStatus ManProp<ManTask,Cap>::propagate(Space& home, const ModEventDelta& med) { // Only bounds changes? if (Int::IntView::me(med) != Int::ME_INT_DOM) GECODE_ES_CHECK(overload(home,c.max(),t)); GECODE_ES_CHECK(edgefinding(home,c.max(),t)); bool subsumed; ExecStatus es = basic(home,subsumed,c,t); GECODE_ES_CHECK(es); if (subsumed) return home.ES_SUBSUMED(*this); if (Cap::varderived() && c.assigned() && c.val()==1) { // Check that tasks do not overload resource for (int i=t.size(); i--; ) if (t[i].c() > 1) return ES_FAILED; // Rewrite to unary resource constraint TaskArray<typename TaskTraits<ManTask>::UnaryTask> ut(home,t.size()); for (int i=t.size(); i--;) ut[i]=t[i]; GECODE_REWRITE(*this, (Unary::ManProp<typename TaskTraits<ManTask>::UnaryTask> ::post(home(*this),ut))); } else { return es; } }
char* core(const char* str, const char* alphabet, const int comp_fact, const int N) { int str_pos = 0, str_len = strlen(str), alpha_len = strlen(alphabet), indx; ul hash; // this is unsafe, particularly for smaul input strings, but whatever. int max_sig_len = (str_len/comp_fact) * 1.5, sig_pos = 0; // this wiul leak, obviously, as swig has no way to deaulocate. // Probably needs to be replaced with std::string. char* sig = malloc(max_sig_len); for(str_pos=0; (str_pos+N) < str_len; str_pos++) { // hash neighborhood to 64 bits hash = basic(str, str_pos, N); int char_outputted = output_char(sig, sig_pos, alphabet, hash, comp_fact); if(char_outputted) { sig_pos++; if(sig_pos >= max_sig_len) { sig_pos = 0; } } } return sig; }
int main(void) { setup(); basic(); badenc(FD_IS_OK, FD_IS_OK); badenc(FD_IS_OK, FD_IS_BULLSHIT); badenc(FD_IS_OK, FD_IS_WRONGMODE); badenc(FD_IS_BULLSHIT, FD_IS_OK); badenc(FD_IS_BULLSHIT, FD_IS_BULLSHIT); badenc(FD_IS_BULLSHIT, FD_IS_WRONGMODE); badenc(FD_IS_WRONGMODE, FD_IS_OK); badenc(FD_IS_WRONGMODE, FD_IS_BULLSHIT); badenc(FD_IS_WRONGMODE, FD_IS_WRONGMODE); baddec(FD_IS_OK, FD_IS_OK); baddec(FD_IS_OK, FD_IS_BULLSHIT); baddec(FD_IS_OK, FD_IS_WRONGMODE); baddec(FD_IS_BULLSHIT, FD_IS_OK); baddec(FD_IS_BULLSHIT, FD_IS_BULLSHIT); baddec(FD_IS_BULLSHIT, FD_IS_WRONGMODE); baddec(FD_IS_WRONGMODE, FD_IS_OK); baddec(FD_IS_WRONGMODE, FD_IS_BULLSHIT); baddec(FD_IS_WRONGMODE, FD_IS_WRONGMODE); unittest_finish(); }
int main(int, char const *[]) { std::cout <<"\nBasic example /////////////////////"<< std::endl; basic(); std::cout <<"\nSize example /////////////////////"<< std::endl; size(); return 0; }
void BasicOptions::initOptions(ProgramOptions::OptionGroup& root) { OptionGroup basic("Basic Options"); basic.addOptions() ("stats" , storeTo(stats)->parser(&BasicOptions::mapStats)->setImplicit(),"Print extended statistics") ("quiet,q", bool_switch(&quiet), "Do not print models") ("asp09" , bool_switch(&asp09), "Write output in ASP Competition'09 format") ("time-limit" , storeTo(timeout), "Set time limit to <n> seconds", "<n>") ; root.addOptions(basic, true); }
QSize VideoRendererDefault::videoSize() const { LONG w = 0, h = 0; ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); if (basic) { basic->GetVideoSize( &w, &h); } return QSize(w, h); }
void TerrainWeightEditor::InitializeCanvases() { QGroupBox* group = editor_widget_->findChild<QGroupBox*>("weight_group"); if(!group) return; QGridLayout* layout = dynamic_cast<QGridLayout*>(group->layout()); if(!layout) return; TerrainLabel* label1 = new TerrainLabel(this); label1->setObjectName("canvas_1"); label1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); label1->setScaledContents(true); layout->addWidget(label1,0,0); TerrainLabel* label2 = new TerrainLabel(this); label2->setObjectName("canvas_2"); label2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); label2->setScaledContents(true); layout->addWidget(label2,0,1); TerrainLabel* label3 = new TerrainLabel(this); label3->setObjectName("canvas_3"); label3->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); label3->setScaledContents(true); layout->addWidget(label3,2,0); TerrainLabel* label4 = new TerrainLabel(this); label4->setObjectName("canvas_4"); label4->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); label4->setScaledContents(true); layout->addWidget(label4,2,1); QLabel *canvas1 = editor_widget_->findChild<QLabel *>("canvas_1"); QLabel *canvas2 = editor_widget_->findChild<QLabel *>("canvas_2"); QLabel *canvas3 = editor_widget_->findChild<QLabel *>("canvas_3"); QLabel *canvas4 = editor_widget_->findChild<QLabel *>("canvas_4"); QLabel *brush_canvas = editor_widget_->findChild<QLabel *>("brush_label"); assert(canvas1 && canvas2 && canvas3 && canvas4 && brush_canvas); QPixmap basic(1024,1024); basic.fill(Qt::black); canvas1->setPixmap(basic); canvas2->setPixmap(basic); canvas3->setPixmap(basic); canvas4->setPixmap(basic); QPixmap brush(256, 256); brush.fill(QColor(neutral_color_,neutral_color_,neutral_color_)); brush_canvas->setPixmap(brush); }
void VideoRendererDefault::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, Phonon::VideoWidget::ScaleMode scaleMode) { if (!isActive()) { ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); if (basic) { basic->SetDestinationPosition(0, 0, 0, 0); } return; } ComPointer<IVideoWindow> video(m_filter, IID_IVideoWindow); OAHWND owner; HRESULT hr = video->get_Owner(&owner); if (FAILED(hr)) { return; } const OAHWND newOwner = reinterpret_cast<OAHWND>(m_target->winId()); if (owner != newOwner) { video->put_Owner(newOwner); video->put_MessageDrain(newOwner); video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); } //make sure the widget takes the whole size of the parent video->SetWindowPosition(0, 0, size.width(), size.height()); const QSize vsize = videoSize(); internalNotifyResize(size, vsize, aspectRatio, scaleMode); ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); if (basic) { basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight); } }
int is_all_basic(DWORD input_length, const DWORD input[]) { int j; for(j = 0; j < (int)input_length; j++) { if (basic(input[j])) { continue; } else { return 0; } } return 1; }
int main (int argc, char **argv) { if (argc > 1 && !strcmp (argv[1], "--verbose")) verbose = 1; gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); basic (); canon_len (); back_and_forth (); check_sscan (); return error_count? 1:0; }
int main (int argc, char **argv) { token_buffer tb; char const *delim; size_t delim_len; atexit (close_stdout); if (argc == 1) { basic (); return 0; } init_tokenbuffer (&tb); if (argc != 2) return 99; delim = argv[1]; delim_len = strlen (delim); if (STREQ (delim, "\\0")) { delim = ""; delim_len = 1; } while (1) { size_t token_length = readtoken (stdin, delim, delim_len, &tb); if (token_length == (size_t) -1) break; fwrite (tb.buffer, 1, token_length, stdout); putchar (':'); } putchar ('\n'); free (tb.buffer); ASSERT ( ! ferror (stdin)); return 0; }
/** *************************************************************************** * main... * */ int main(int argc, char **argv) { (void)printf("testing libbloom...\n"); if (argc == 4 && !strncmp(argv[1], "-p", 2)) { perf_loop(atoi(argv[2]), atoi(argv[3])); exit(0); } basic(); add_random(100, 0.001, 300); int i; for (i = 0; i < 10; i++) { add_random(1000000, 0.001, 1000000); } perf_loop(10000000, 10000000); }
void on_event (AtspiEvent *event, void *data) { if (atspi_accessible_get_role (event->source, NULL) == ATSPI_ROLE_DESKTOP_FRAME) { if (strstr (event->type, "add")) { AtspiAccessible *desktop = atspi_get_desktop (0); guint id; basic (desktop); g_object_unref (desktop); id = g_timeout_add (3000, kill_child, NULL); g_source_set_name_by_id (id, "[at-spi2-core] kill_child"); } else { guint id; id = g_idle_add (end, NULL); g_source_set_name_by_id (id, "[at-spi2-core] end"); } } g_boxed_free (ATSPI_TYPE_EVENT, event); }
QImage VideoRendererDefault::snapshot() const { ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo); if (basic) { LONG bufferSize = 0; //1st we get the buffer size basic->GetCurrentImage(&bufferSize, 0); QByteArray buffer; buffer.resize(bufferSize); HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast<long*>(buffer.data())); if (SUCCEEDED(hr)) { const BITMAPINFOHEADER *bmi = reinterpret_cast<const BITMAPINFOHEADER*>(buffer.constData()); const int w = qAbs(bmi->biWidth), h = qAbs(bmi->biHeight); // Create image and copy data into image. QImage ret(w, h, QImage::Format_RGB32); if (!ret.isNull()) { const char *data = buffer.constData() + bmi->biSize; const int bytes_per_line = w * sizeof(QRgb); for (int y = h - 1; y >= 0; --y) { qMemCopy(ret.scanLine(y), //destination data, //source bytes_per_line); data += bytes_per_line; } } return ret; } } return QImage(); }
CheckH5Config(int argc, char **argv) { /* Parse command line arguments */ po::options_description basic("Basic Options"); basic.add_options() ("version", "Print version information") ("help,h", "Print help message") ("verbose,v", "Print extra (debugging) information") ; po::options_description config("Configuration Options"); config.add_options() ("input,i",po::value<std::string>(&(this->input_filename)), "input filename (required)") ; po::options_description options; options.add(basic).add(config); po::variables_map vm; try { po::store(po::command_line_parser(argc, argv).options(options).run(), vm); po::notify(vm); if (vm.count("help")) { std::cout << options << std::endl; exit(0); } if (vm.count("version")) { version(); exit(0); } if (vm.count("debug")) { debug = true; } } catch (std::exception &e) { std::cout << e.what() << std::endl; std::cout << options << std::endl; exit(1); } }
int punycode_decode( unsigned int input_length, const char input[], unsigned int *output_length, DWORD output[] ) { DWORD n, out, i, max_out, bias, b, j, in, oldi, w, k, delta, digit, t; /* Initialize the state: */ n = initial_n; out = i = 0; max_out = *output_length; bias = initial_bias; /* Handle the basic code points: Let b be the number of input code */ /* points before the last delimiter, or 0 if there is none, then */ /* copy the first b code points to the output. */ for (b = j = 0; j < input_length; ++j) if (delim(input[j])) b = j; if (b > max_out) return XCODE_BAD_ARGUMENT_ERROR; for (j = 0; j < b; ++j) { if (!basic(input[j])) return XCODE_BAD_ARGUMENT_ERROR; output[out++] = input[j]; } /* Main decoding loop: Start just after the last delimiter if any */ /* basic code points were copied; start at the beginning otherwise. */ for (in = b > 0 ? b + 1 : 0; in < input_length; ++out) { /* in is the index of the next character to be consumed, and */ /* out is the number of code points in the output array. */ /* Decode a generalized variable-length integer into delta, */ /* which gets added to i. The overflow checking is easier */ /* if we increase i as we go, then subtract off its starting */ /* value at the end to obtain delta. */ for (oldi = i, w = 1, k = base; ; k += base) { if (in >= input_length) return XCODE_BAD_ARGUMENT_ERROR; digit = decode_digit(input[in++]); if (digit >= base) return XCODE_BAD_ARGUMENT_ERROR; if (digit > (maxint - i) / w) return XCODE_BUFFER_OVERFLOW_ERROR; i += digit * w; t = k <= bias ? tmin : k - bias >= tmax ? tmax : k - bias; if (digit < t) break; if (w > maxint / (base - t)) return XCODE_BUFFER_OVERFLOW_ERROR; w *= (base - t); } /* Adapt the bias: */ delta = oldi == 0 ? i / damp : (i - oldi) >> 1; delta += delta / (out + 1); for (bias = 0; delta > cutoff; bias += base) delta /= lobase; bias += (lobase + 1) * delta / (delta + skew); /* i was supposed to wrap around from out+1 to 0, */ /* incrementing n each time, so we'll fix that now: */ if (i / (out + 1) > maxint - n) return XCODE_BUFFER_OVERFLOW_ERROR; n += i / (out + 1); i %= (out + 1); /* Insert n at position i of the output: */ /* not needed for AMC-ACE-Z: */ /* if (decode_digit(n) <= base) return amc_ace_invalid_input; */ if (out >= max_out) return XCODE_BAD_ARGUMENT_ERROR; memmove(output + i + 1, output + i, (out - i) * sizeof *output); output[i++] = n; } *output_length = (unsigned int) out; return XCODE_SUCCESS; }
int main (int argc, char **argv) { int last_argc = -1; if (argc) { argc--; argv++; } while (argc && last_argc != argc ) { last_argc = argc; if (!strcmp (*argv, "--")) { argc--; argv++; break; } else if (!strcmp (*argv, "--help")) { puts ( "usage: " PGMNAME " [options]\n" "\n" "Options:\n" " --verbose Show what is going on\n" " --debug Flyswatter\n" ); exit (0); } else if (!strcmp (*argv, "--verbose")) { verbose = 1; argc--; argv++; } else if (!strcmp (*argv, "--debug")) { verbose = debug = 1; argc--; argv++; } else if (!strncmp (*argv, "--", 2)) die ("unknown option '%s'", *argv); } if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); if (!gcry_check_version (GCRYPT_VERSION)) die ("version mismatch"); /* #include "../src/gcrypt-int.h" indicates that internal interfaces may be used; thus better do an exact version check. */ if (strcmp (gcry_check_version (NULL), GCRYPT_VERSION)) die ("exact version match failed"); gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); basic (); canon_len (); back_and_forth (); check_sscan (); check_extract_param (); bug_1594 (); return errorcount? 1:0; }
enum punycode_status punycode_decode( punycode_uint input_length, const char input[], punycode_uint *output_length, punycode_uint output[], unsigned char case_flags[] ) { punycode_uint n, out, i, max_out, bias, b, j, in, oldi, w, k, digit, t; /* Initialize the state: */ n = initial_n; out = i = 0; max_out = *output_length; bias = initial_bias; /* Handle the basic code points: Let b be the number of input code */ /* points before the last delimiter, or 0 if there is none, then */ /* copy the first b code points to the output. */ for (b = j = 0; j < input_length; ++j) if (delim(input[j])) b = j; if (b > max_out) return punycode_big_output; for (j = 0; j < b; ++j) { if (case_flags) case_flags[out] = flagged(input[j]); if (!basic(input[j])) return punycode_bad_input; output[out++] = input[j]; } /* Main decoding loop: Start just after the last delimiter if any */ /* basic code points were copied; start at the beginning otherwise. */ for (in = b > 0 ? b + 1 : 0; in < input_length; ++out) { /* in is the index of the next character to be consumed, and */ /* out is the number of code points in the output array. */ /* Decode a generalized variable-length integer into delta, */ /* which gets added to i. The overflow checking is easier */ /* if we increase i as we go, then subtract off its starting */ /* value at the end to obtain delta. */ for (oldi = i, w = 1, k = base; ; k += base) { if (in >= input_length) return punycode_bad_input; digit = decode_digit(input[in++]); if (digit >= base) return punycode_bad_input; if (digit > (maxint - i) / w) return punycode_overflow; i += digit * w; t = k <= bias /* + tmin */ ? tmin : /* +tmin not needed */ k >= bias + tmax ? tmax : k - bias; if (digit < t) break; if (w > maxint / (base - t)) return punycode_overflow; w *= (base - t); } bias = adapt(i - oldi, out + 1, oldi == 0); /* i was supposed to wrap around from out+1 to 0, */ /* incrementing n each time, so we'll fix that now: */ if (i / (out + 1) > maxint - n) return punycode_overflow; n += i / (out + 1); i %= (out + 1); /* Insert n at position i of the output: */ /* not needed for Punycode: */ /* if (decode_digit(n) <= base) return punycode_invalid_input; */ if (out >= max_out) return punycode_big_output; if (case_flags) { memmove(case_flags + i + 1, case_flags + i, out - i); /* Case of last character determines uppercase flag: */ case_flags[i] = flagged(input[in - 1]); } memmove(output + i + 1, output + i, (out - i) * sizeof *output); output[i++] = n; } *output_length = out; return punycode_success; }
enum punycode_status punycode_encode( punycode_uint input_length, const punycode_uint input[], const unsigned char case_flags[], punycode_uint *output_length, char output[] ) { punycode_uint n, delta, h, b, out, max_out, bias, j, m, q, k, t; /* Initialize the state: */ n = initial_n; delta = out = 0; max_out = *output_length; bias = initial_bias; /* Handle the basic code points: */ for (j = 0; j < input_length; ++j) { if (basic(input[j])) { if (max_out - out < 2) return punycode_big_output; output[out++] = (char) (case_flags ? encode_basic(input[j], case_flags[j]) : input[j]); } /* else if (input[j] < n) return punycode_bad_input; */ /* (not needed for Punycode with unsigned code points) */ } h = b = out; /* h is the number of code points that have been handled, b is the */ /* number of basic code points, and out is the number of characters */ /* that have been output. */ if (b > 0) output[out++] = delimiter; /* Main encoding loop: */ while (h < input_length) { /* All non-basic code points < n have been */ /* handled already. Find the next larger one: */ for (m = maxint, j = 0; j < input_length; ++j) { /* if (basic(input[j])) continue; */ /* (not needed for Punycode) */ if (input[j] >= n && input[j] < m) m = input[j]; } /* Increase delta enough to advance the decoder's */ /* <n,i> state to <m,0>, but guard against overflow: */ if (m - n > (maxint - delta) / (h + 1)) return punycode_overflow; delta += (m - n) * (h + 1); n = m; for (j = 0; j < input_length; ++j) { /* Punycode does not need to check whether input[j] is basic: */ if (input[j] < n /* || basic(input[j]) */ ) { if (++delta == 0) return punycode_overflow; } if (input[j] == n) { /* Represent delta as a generalized variable-length integer: */ for (q = delta, k = base; ; k += base) { if (out >= max_out) return punycode_big_output; t = k <= bias /* + tmin */ ? tmin : /* +tmin not needed */ k >= bias + tmax ? tmax : k - bias; if (q < t) break; output[out++] = encode_digit(t + (q - t) % (base - t), 0); q = (q - t) / (base - t); } output[out++] = encode_digit(q, case_flags && case_flags[j]); bias = adapt(delta, h + 1, h == b); delta = 0; ++h; } } ++delta, ++n; } *output_length = out; return punycode_success; }
Graph::Graph(const int *cartan, const std::vector<Word>& gens, //namesake const std::vector<Word>& v_cogens, const std::vector<Word>& e_gens, const std::vector<Word>& f_gens, const Vect& weights) { //define symmetry group relations std::vector<Word> words = words_from_cartan(cartan); { const Logging::fake_ostream& os = logger.debug(); os << "relations ="; for (int w=0; w<6; ++w) { Word& word = words[w]; os << "\n "; for (unsigned i=0; i<word.size(); ++i) { os << word[i]; } } os |0; } //check vertex stabilizer generators { const Logging::fake_ostream& os = logger.debug(); os << "v_cogens ="; for (unsigned w=0; w<v_cogens.size(); ++w) { const Word& jenn = v_cogens[w]; //namesake os << "\n "; for (unsigned t=0; t<jenn.size(); ++t) { int j = jenn[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //check edge generators { const Logging::fake_ostream& os = logger.debug(); os << "e_gens ="; for (unsigned w=0; w<e_gens.size(); ++w) { const Word& edge = e_gens[w]; os << "\n "; for (unsigned t=0; t<edge.size(); ++t) { int j = edge[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //check face generators { const Logging::fake_ostream& os = logger.debug(); os << "f_gens ="; for (unsigned w=0; w<f_gens.size(); ++w) { const Word& face = f_gens[w]; os << "\n "; for (unsigned t=0; t<face.size(); ++t) { int j = face[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //build symmetry group Group group(words); logger.debug() << "group.ord = " << group.ord |0; //build subgroup std::vector<int> subgroup; subgroup.push_back(0); std::set<int> in_subgroup; in_subgroup.insert(0); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; for (unsigned j=0; j<gens.size(); ++j) { int g1 = group.left(g0,gens[j]); if (in_subgroup.find(g1) != in_subgroup.end()) continue; subgroup.push_back(g1); in_subgroup.insert(g1); } } logger.debug() << "subgroup.ord = " << subgroup.size() |0; //build cosets and count ord std::map<int,int> coset; //maps group elements to cosets ord = 0; //used as coset number for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; if (coset.find(g0) != coset.end()) continue; int c0 = ord++; coset[g0] = c0; std::vector<int> members(1, g0); std::vector<int> others(0); for (unsigned i=0; i<members.size(); ++i) { int g1 = members[i]; for (unsigned w=0; w<v_cogens.size(); ++w) { int g2 = group.left(g1, v_cogens[w]); if (coset.find(g2) != coset.end()) continue; coset[g2] = c0; members.push_back(g2); } } } logger.info() << "cosets table built: " << " ord = " << ord |0; //build edge lists std::vector<std::set<int> > neigh(ord); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; int c0 = coset[g0]; for (unsigned w=0; w<e_gens.size(); ++w) { int g1 = group.left(g0, e_gens[w]); Assert (in_subgroup.find(g1) != in_subgroup.end(), "edge leaves subgroup"); int c1 = coset[g1]; if (c0 != c1) neigh[c0].insert(c1); } } // make symmetric for (int c0=0; c0<ord; ++c0) { const std::set<int>& n = neigh[c0]; for (std::set<int>::iterator c1=n.begin(); c1!=n.end(); ++c1) { neigh[*c1].insert(c0); } } // build edge table adj.resize(ord); for (int c=0; c<ord; ++c) { adj[c].insert(adj[c].begin(), neigh[c].begin(), neigh[c].end()); } neigh.clear(); deg = adj[0].size(); logger.info() << "edge table built: deg = " << deg |0; //define faces for (unsigned g=0; g<f_gens.size(); ++g) { const Word& face = f_gens[g]; logger.debug() << "defining faces on " << face |0; Logging::IndentBlock block; //define basic face in group Ring basic(1,0); // g = 0; int g0 = 0; for (unsigned c=0; true; ++c) { g0 = group.left(g0, face[c%face.size()]); if (c >= face.size() and g0 == 0) break; if (in_subgroup.find(g0) != in_subgroup.end() and g0 != basic.back()) { basic.push_back(g0); } } for (unsigned c=0; c<basic.size(); ++c) { logger.debug() << " corner: " << basic[c] |0; } logger.debug() << "sides/face (free) = " << basic.size() |0; //build orbit of basic face std::vector<Ring> faces_g; faces_g.push_back(basic); FaceRecognizer recognized; recognized(basic); for (unsigned i=0; i<faces_g.size(); ++i) { const Ring f = faces_g[i]; for (unsigned j=0; j<gens.size(); ++j) { //right action of group on faces Ring f_j(f.size()); for (unsigned c=0; c<f.size(); ++c) { f_j[c] = group.right(f[c],gens[j]); } //add face if (not recognized(f_j)) { faces_g.push_back(f_j); //logger.debug() << "new face: " << f_j |0; } else { //logger.debug() << "old face: " << f_j|0; } } } //hom face down to quotient graph recognized.clear(); for (unsigned f=0; f<faces_g.size(); ++f) { const Ring face_g = faces_g[f]; Ring face; face.push_back(coset[face_g[0]]); for (unsigned i=1; i<face_g.size(); ++i) { int c = coset[face_g[i]]; if (c != face.back() and c != face[0]) { face.push_back(c); } } if (face.size() < 3) continue; if (not recognized(face)) { faces.push_back(face); } } } ord_f = faces.size(); logger.info() << "faces defined: order = " << ord_f |0; //define vertex coset std::vector<Word> vertex_coset; for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; if (coset[g0]==0) vertex_coset.push_back(group.parse(g0)); } //build geometry std::vector<Mat> gen_reps(gens.size()); points.resize(ord); build_geom(cartan, vertex_coset, gens, v_cogens, weights, gen_reps, points[0]); std::vector<int> pointed(ord,0); pointed[0] = true; logger.debug() << "geometry built" |0; //build point sets std::vector<int> reached(1,0); std::set<int> is_reached; is_reached.insert(0); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = reached[g]; for (unsigned j=0; j<gens.size(); ++j) { int g1 = group.right(g0,gens[j]); if (is_reached.find(g1) == is_reached.end()) { if (not pointed[coset[g1]]) { vect_mult(gen_reps[j], points[coset[g0]], points[coset[g1]]); pointed[coset[g1]] = true; } reached.push_back(g1); is_reached.insert(g1); } } } logger.debug() << "point set built." |0; //build face normals normals.resize(ord_f); for (int f=0; f<ord_f; ++f) { Ring& face = faces[f]; Vect &a = points[face[0]]; Vect &b = points[face[1]]; Vect &c = points[face[2]]; Vect &n = normals[f]; cross4(a,b,c, n); normalize(n); /* Assert1(fabs(inner(a,n)) < 1e-6, "bad normal: <n,a> = " << fabs(inner(a,n))); Assert1(fabs(inner(b,n)) < 1e-6, "bad normal: <n,b> = " << fabs(inner(b,n))); Assert1(fabs(inner(c,n)) < 1e-6, "bad normal: <n,b> = " << fabs(inner(c,n))); */ } logger.debug() << "face normals built." |0; }
ProcReducerConfig(int argc, char **argv) { /* Parse command line arguments */ po::options_description basic("Basic Options"); basic.add_options() ("version", "Print version information") ("help,h", "Print help message") ("verbose,v", "Print extra (debugging) information") ; po::options_description config("Configuration Options"); config.add_options() ("daemonize,d", "Daemonize the procmon process") ("hostname,H",po::value<std::string>(&(this->hostname))->default_value(DEFAULT_REDUCER_HOSTNAME), "identifier for tagging data") ("identifier,I",po::value<std::string>(&(this->identifier))->default_value(DEFAULT_REDUCER_IDENTIFIER), "identifier for tagging data") ("subidentifier,S",po::value<std::string>(&(this->subidentifier))->default_value(DEFAULT_REDUCER_SUBIDENTIFIER), "secondary identifier for tagging data") ("outputhdf5prefix,O",po::value<std::string>(&(this->outputHDF5FilenamePrefix))->default_value(DEFAULT_REDUCER_OUTPUT_PREFIX), "prefix for hdf5 output filename [final names will be prefix.YYYYMMDDhhmmss.h5 (required)") ("cleanfreq,c",po::value<int>(&(this->cleanFreq))->default_value(DEFAULT_REDUCER_CLEAN_FREQUENCY), "time between process hash table cleaning runs") ("maxage,m",po::value<int>(&(this->maxProcessAge))->default_value(DEFAULT_REDUCER_MAX_PROCESS_AGE), "timeout since last communication from a pid before allowing removal from hash table (cleaning)") ("statblock",po::value<int>(&(this->statBlockSize))->default_value(DEFAULT_STAT_BLOCK_SIZE), "number of stat records per block in hdf5 file" ) ("datablock",po::value<int>(&(this->dataBlockSize))->default_value(DEFAULT_DATA_BLOCK_SIZE), "number of data records per block in hdf5 file" ) ("pid,q",po::value<string>(&(this->pidfile))->default_value(""), "pid file to write") ("debug", "enter debugging mode") ; po::options_description mqconfig("AMQP Configuration Options"); mqconfig.add_options() ("mqhostname,H", po::value<std::string>(&(this->mqServer))->default_value(DEFAULT_AMQP_HOST), "hostname for AMQP Server") ("mqport,P",po::value<unsigned int>(&(this->mqPort))->default_value(DEFAULT_AMQP_PORT), "port for AMQP Server") ("mqvhost,V",po::value<std::string>(&(this->mqVHost))->default_value(DEFAULT_AMQP_VHOST), "virtual-host for AMQP Server") ("mqexchange,E",po::value<std::string>(&(this->mqExchangeName))->default_value("procmon"), "exchange name for AMQP Server") ("mqUser",po::value<std::string>(&(this->mqUser))->default_value(DEFAULT_AMQP_USER), "virtual-host for AMQP Server") ("mqPassword",po::value<std::string>(&(this->mqPassword)), "virtual-host for AMQP Server") ("mqframe,F",po::value<unsigned int>(&(this->mqFrameSize))->default_value(DEFAULT_AMQP_FRAMESIZE), "maximum frame size for AMQP Messages (bytes)") ; po::options_description options; options.add(basic).add(config).add(mqconfig); po::variables_map vm; try { po::store(po::command_line_parser(argc, argv).options(options).run(), vm); po::notify(vm); if (vm.count("help")) { std::cout << options << std::endl; exit(0); } if (vm.count("version")) { version(); exit(0); } if (vm.count("daemonize")) { daemonize = true; } else { daemonize = false; } if (vm.count("debug")) { debug = true; } if (vm.count("mqPassword") == 0) { mqPassword = DEFAULT_AMQP_PASSWORD; } } catch (std::exception &e) { std::cout << e.what() << std::endl; std::cout << options << std::endl; exit(1); } }
void ofxMapamok::save(string fileName, string fileNameSummary) { if (!calibrationReady) { ofLogWarning() << "not enough points set to save a calibration"; return; } cv::FileStorage fs(ofToDataPath(fileName), cv::FileStorage::WRITE); if (!fs.isOpened()) { ofLogError() << "could not open calibration file for writing"; return; } cv::Mat cameraMatrix = intrinsics.getCameraMatrix(); fs << "cameraMatrix" << cameraMatrix; double focalLength = intrinsics.getFocalLength(); fs << "focalLength" << focalLength; cv::Point2d fov = intrinsics.getFov(); fs << "fov" << fov; fs << "distCoeffs" << distCoeffs; cv::Point2d principalPoint = intrinsics.getPrincipalPoint(); fs << "principalPoint" << principalPoint; cv::Size imageSize = intrinsics.getImageSize(); fs << "imageSize" << imageSize; fs << "translationVector" << tvec; fs << "rotationVector" << rvec; cv::Mat rotationMatrix; Rodrigues(rvec, rotationMatrix); fs << "rotationMatrix" << rotationMatrix; double rotationAngleRadians = norm(rvec, cv::NORM_L2); double rotationAngleDegrees = ofRadToDeg(rotationAngleRadians); cv::Mat rotationAxis = rvec / rotationAngleRadians; fs << "rotationAngleRadians" << rotationAngleRadians; fs << "rotationAngleDegrees" << rotationAngleDegrees; fs << "rotationAxis" << rotationAxis; ofVec3f axis(rotationAxis.at<double>(0), rotationAxis.at<double>(1), rotationAxis.at<double>(2)); ofVec3f euler = ofQuaternion(rotationAngleDegrees, axis).getEuler(); cv::Mat eulerMat = (cv::Mat_<double>(3, 1) << euler.x, euler.y, euler.z); fs << "euler" << eulerMat; if (fileNameSummary == "") { // skip summary if no summary filename supplied ofLogWarning() << "could not open summary file for writing"; return; } ofFile basic(fileNameSummary, ofFile::WriteOnly); if (!basic.is_open()) { ofLogWarning() << "could not open summary file for writing"; return; } ofVec3f position(tvec.at<double>(1), tvec.at<double>(2)); basic << "position (in world units):" << endl; basic << "\tx: " << ofToString(tvec.at<double>(0), 2) << endl; basic << "\ty: " << ofToString(tvec.at<double>(1), 2) << endl; basic << "\tz: " << ofToString(tvec.at<double>(2), 2) << endl; basic << "axis-angle rotation (in degrees):" << endl; basic << "\taxis x: " << ofToString(axis.x, 2) << endl; basic << "\taxis y: " << ofToString(axis.y, 2) << endl; basic << "\taxis z: " << ofToString(axis.z, 2) << endl; basic << "\tangle: " << ofToString(rotationAngleDegrees, 2) << endl; basic << "euler rotation (in degrees):" << endl; basic << "\tx: " << ofToString(euler.x, 2) << endl; basic << "\ty: " << ofToString(euler.y, 2) << endl; basic << "\tz: " << ofToString(euler.z, 2) << endl; basic << "fov (in degrees):" << endl; basic << "\thorizontal: " << ofToString(fov.x, 2) << endl; basic << "\tvertical: " << ofToString(fov.y, 2) << endl; basic << "principal point (in screen units):" << endl; basic << "\tx: " << ofToString(principalPoint.x, 2) << endl; basic << "\ty: " << ofToString(principalPoint.y, 2) << endl; basic << "image size (in pixels):" << endl; basic << "\tx: " << ofToString(imageSize.width, 2) << endl; basic << "\ty: " << ofToString(imageSize.height, 2) << endl; basic << "distortion coefficients:" << endl; basic << "\tradial: " << ofToString(distCoeffs.at<double>(0), 4) << " " << ofToString(distCoeffs.at<double>(1), 4) << " " << ofToString(distCoeffs.at<double>(4), 4) << endl; basic << "\ttangential: " << ofToString(distCoeffs.at<double>(2), 4) << " " << ofToString(distCoeffs.at<double>(3), 4) << endl; }
void HiRes1Engine::runIntro() const { StreamPtr stream(_files->createReadStream(IDS_HR1_EXE_0)); stream->seek(IDI_HR1_OFS_LOGO_0); _display->setMode(DISPLAY_MODE_HIRES); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); delay(4000); if (shouldQuit()) return; _display->setMode(DISPLAY_MODE_TEXT); StreamPtr basic(_files->createReadStream(IDS_HR1_LOADER)); Common::String str; str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_0, '"'); _display->printAsciiString(str + '\r'); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_1, '"'); _display->printAsciiString(str + "\r\r"); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_2, '"'); _display->printAsciiString(str + "\r\r"); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_3, '"'); _display->printAsciiString(str + '\r'); inputKey(); if (g_engine->shouldQuit()) return; _display->setMode(DISPLAY_MODE_MIXED); str = readStringAt(*stream, IDI_HR1_OFS_GAME_OR_HELP); bool instructions = false; while (1) { _display->printString(str); Common::String s = inputString(); if (g_engine->shouldQuit()) break; if (s.empty()) continue; if (s[0] == APPLECHAR('I')) { instructions = true; break; } else if (s[0] == APPLECHAR('G')) { break; } }; if (instructions) { _display->setMode(DISPLAY_MODE_TEXT); stream->seek(IDI_HR1_OFS_INTRO_TEXT); const uint pages[] = { 6, 6, 4, 5, 8, 7, 0 }; uint page = 0; while (pages[page] != 0) { _display->home(); uint count = pages[page++]; for (uint i = 0; i < count; ++i) { str = readString(*stream); _display->printString(str); stream->seek(3, SEEK_CUR); } inputString(); if (g_engine->shouldQuit()) return; stream->seek(6, SEEK_CUR); } } _display->printAsciiString("\r"); _display->setMode(DISPLAY_MODE_MIXED); // Title screen shown during loading stream.reset(_files->createReadStream(IDS_HR1_EXE_1)); stream->seek(IDI_HR1_OFS_LOGO_1); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); delay(2000); }
int main(int argc, char ** argv) { table_t *tab; int ret, iter_n = ITERATIONS, alignment = 0; long seed; argc--, argv++; /* set default seed */ seed = time(NULL); /* process the args */ for (; *argv != NULL; argv++, argc--) { if (**argv != '-') { continue; } switch (*(*argv + 1)) { case 'a': auto_adjust_b = 1; break; case 'A': if (argc > 0) { argv++, argc--; if (argc == 0) { usage(); } alignment = atoi(*argv); } break; case 'i': if (argc > 0) { argv++, argc--; if (argc == 0) { usage(); } iter_n = atoi(*argv); } break; case 'l': large_b = 1; break; case 's': if (argc > 0) { argv++, argc--; if (argc == 0) { usage(); } seed = atol(*argv); } break; case 'v': verbose_b = 1; break; default: usage(); break; } } if (argc > 0) { usage(); } (void)srandom(seed); (void)printf("Seed for random is %ld\n", seed); /* alloc the test table */ call_c++; tab = table_alloc(0, &ret); if (tab == NULL) { (void)printf("table_alloc returned: %s\n", table_strerror(ret)); exit(1); } if (auto_adjust_b) { ret = table_attr(tab, TABLE_FLAG_AUTO_ADJUST); if (ret != TABLE_ERROR_NONE) { (void)fprintf(stderr, "ERROR: could not set table for auto-adjust: %s\n", table_strerror(ret)); exit(1); } } if (alignment > 0) { ret = table_set_data_alignment(tab, alignment); if (ret != TABLE_ERROR_NONE) { (void)fprintf(stderr, "ERROR: could not set data alignment to %d: %s\n", alignment, table_strerror(ret)); exit(1); } } basic(tab); stress(tab, iter_n, 0); io_test(tab); order_test(tab); call_c++; ret = table_free(tab); if (ret != TABLE_ERROR_NONE) { (void)fprintf(stderr, "ERROR in table_free: %s\n", table_strerror(ret)); } (void)fputc('\n', stdout); (void)printf("Test program performed %d table calls\n", call_c); exit(0); }
int punycode_encode( unsigned int input_length, const DWORD input[], unsigned int *output_length, char output[] ) { DWORD n, delta, h, b, out, max_out, bias, j, m, q, k, t; /* Initialize the state: */ n = initial_n; delta = out = 0; max_out = *output_length; bias = initial_bias; /* Handle the basic code points: */ for (j = 0; j < input_length; ++j) { if ( basic( input[j] ) ) { if (max_out - out < 2) return XCODE_BAD_ARGUMENT_ERROR; output[out++] = (char)input[j]; } /* else if (input[j] < n) return XCODE_BAD_ARGUMENT_ERROR; */ /* (not needed for AMC-ACE-Z with unsigned code points) */ } h = b = out; /* h is the number of code points that have been handled, b is the */ /* number of basic code points, and out is the number of characters */ /* that have been output. */ if (b > 0) output[out++] = delimiter; /* Main encoding loop: */ while (h < input_length) { /* All non-basic code points < n have been */ /* handled already. Find the next larger one: */ for (m = maxint, j = 0; j < input_length; ++j) { /* if (basic(input[j])) continue; */ /* (not needed for AMC-ACE-Z) */ if (input[j] >= n && input[j] < m) m = input[j]; } /* Increase delta enough to advance the decoder's */ /* <n,i> state to <m,0>, but guard against overflow: */ if (m - n > (maxint - delta) / (h + 1)) return XCODE_BUFFER_OVERFLOW_ERROR; delta += (m - n) * (h + 1); n = m; for (j = 0; j < input_length; ++j) { #if 0 if (input[j] < n || basic(input[j])) { if (++delta == 0) return XCODE_BUFFER_OVERFLOW_ERROR; } #endif /* AMC-ACE-Z can use this simplified version instead: */ if (input[j] < n && ++delta == 0) return XCODE_BUFFER_OVERFLOW_ERROR; if (input[j] == n) { /* Represent delta as a generalized variable-length integer: */ for (q = delta, k = base; ; k += base) { if (out >= max_out) return XCODE_BAD_ARGUMENT_ERROR; t = k <= bias ? tmin : k - bias >= tmax ? tmax : k - bias; if (q < t) break; output[out++] = encode_digit(t + (q - t) % (base - t), 0); q = (q - t) / (base - t); } output[out++] = encode_digit(q, 0); /* Adapt the bias: */ delta = h == b ? delta / damp : delta >> 1; delta += delta / (h + 1); for (bias = 0; delta > cutoff; bias += base) delta /= lobase; bias += (lobase + 1) * delta / (delta + skew); delta = 0; ++h; } } ++delta; ++n; } *output_length = (unsigned int) out; return XCODE_SUCCESS; }
// we have a segment, in NFD. Find all the strings that are canonically equivalent to it. UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status) { Hashtable result(status); Hashtable permutations(status); Hashtable basic(status); if (U_FAILURE(status)) { return 0; } result.setValueDeleter(uprv_deleteUObject); permutations.setValueDeleter(uprv_deleteUObject); basic.setValueDeleter(uprv_deleteUObject); UChar USeg[256]; int32_t segLen = segment.extract(USeg, 256, status); getEquivalents2(&basic, USeg, segLen, status); // now get all the permutations // add only the ones that are canonically equivalent // TODO: optimize by not permuting any class zero. const UHashElement *ne = NULL; int32_t el = UHASH_FIRST; //Iterator it = basic.iterator(); ne = basic.nextElement(el); //while (it.hasNext()) while (ne != NULL) { //String item = (String) it.next(); UnicodeString item = *((UnicodeString *)(ne->value.pointer)); permutations.removeAll(); permute(item, CANITER_SKIP_ZEROES, &permutations, status); const UHashElement *ne2 = NULL; int32_t el2 = UHASH_FIRST; //Iterator it2 = permutations.iterator(); ne2 = permutations.nextElement(el2); //while (it2.hasNext()) while (ne2 != NULL) { //String possible = (String) it2.next(); //UnicodeString *possible = new UnicodeString(*((UnicodeString *)(ne2->value.pointer))); UnicodeString possible(*((UnicodeString *)(ne2->value.pointer))); UnicodeString attempt; nfd.normalize(possible, attempt, status); // TODO: check if operator == is semanticaly the same as attempt.equals(segment) if (attempt==segment) { //if (PROGRESS) printf("Adding Permutation: %s\n", UToS(Tr(*possible))); // TODO: use the hashtable just to catch duplicates - store strings directly (somehow). result.put(possible, new UnicodeString(possible), status); //add(possible); } else { //if (PROGRESS) printf("-Skipping Permutation: %s\n", UToS(Tr(*possible))); } ne2 = permutations.nextElement(el2); } ne = basic.nextElement(el); } /* Test for buffer overflows */ if(U_FAILURE(status)) { return 0; } // convert into a String[] to clean up storage //String[] finalResult = new String[result.size()]; UnicodeString *finalResult = NULL; int32_t resultCount; if((resultCount = result.count())) { finalResult = new UnicodeString[resultCount]; if (finalResult == 0) { status = U_MEMORY_ALLOCATION_ERROR; return NULL; } } else { status = U_ILLEGAL_ARGUMENT_ERROR; return NULL; } //result.toArray(finalResult); result_len = 0; el = UHASH_FIRST; ne = result.nextElement(el); while(ne != NULL) { finalResult[result_len++] = *((UnicodeString *)(ne->value.pointer)); ne = result.nextElement(el); } return finalResult; }
void basicCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { //qDebug()<<"hey!"; borderPen = QPen(Qt::green); polyPen = QPen(Qt::darkYellow); polyPen.setWidth(POLY_PEN_WIDTH); cellPen = QPen(Qt::yellow); cellBrush = QBrush(Qt::darkCyan); quint32 x = SIDE; static const QPointF points[16] = { QPointF(0, x), QPointF(0, 8*x), QPointF(x, 8*x), QPointF(x, 7*x), QPointF(2*x, 7*x), QPointF(2*x, 8*x), QPointF(3*x, 8*x), QPointF(3*x, 7*x), QPointF(4*x, 7*x), QPointF(4*x, 0), QPointF(3*x, 0), QPointF(3*x, x), QPointF(2*x, x), QPointF(2*x, 0), QPointF(x, 0), QPointF(x, x), }; QRegExp rxUnit("(F\\d{4})"); if (rxUnit.indexIn(m_cellDbName) != -1){ painter->setBrush(cellBrush); painter->drawPolygon(points, 16); QString str; str.append(m_cellMelName); str.append("/"); str.append(m_cellDbName); if(m_active){ //str.append("\nact"); } str.append("\nM: "); str.append(m_cellMelMacro); painter->setBrush(Qt::NoBrush); QRect basic(0,0,4*SIDE,8*SIDE); if(!m_active){ painter->setPen(borderPen); //painter->drawRect(basic); }else{ painter->setPen(QPen(Qt::darkCyan)); } painter->drawRect(basic); painter->setPen(QPen(Qt::black)); if(m_cellDbPinsInfo.size()>=9){ painter->drawText(5*SIDE/4,SIDE, m_cellDbPinsInfo.at(0+9*m_cellPlace)); painter->drawText(SIDE/4,8*SIDE-SIDE/4, m_cellDbPinsInfo.at(0+9*m_cellPlace)); painter->drawText(13*SIDE/4,SIDE, m_cellDbPinsInfo.at(3+9*m_cellPlace)); painter->drawText(9*SIDE/4,8*SIDE-SIDE/4, m_cellDbPinsInfo.at(6+9*m_cellPlace)); } if(m_cellPlace < m_cellCnt-1){ painter->setPen(QPen(Qt::darkCyan)); painter->drawLine(4*SIDE,0,4*SIDE, 8*SIDE); emit oversizedCell(m_cellMelName, m_cellPlace + 1, QPoint(m_column, m_row), m_cellMelMacro); } painter->setPen(borderPen); //QRect textRect(-m_cellCnt*SIDE,0,4*m_cellCnt*SIDE,8*SIDE); if(m_cellPlace == 0){ painter->drawText(basic, Qt::AlignCenter, str); } }else{ painter->setPen(polyPen); painter->drawLine(3*SIDE/2,POLY_PEN_WIDTH/2,3*SIDE/2,4*SIDE);//xyxy painter->drawLine(3*SIDE/2,4*SIDE,SIDE/2,4*SIDE); painter->drawLine(SIDE/2,4*SIDE,SIDE/2,8*SIDE-POLY_PEN_WIDTH/2); painter->drawLine(7*SIDE/2,POLY_PEN_WIDTH/2,7*SIDE/2,3*SIDE); painter->drawLine(5*SIDE/2,5*SIDE,5*SIDE/2,8*SIDE-POLY_PEN_WIDTH/2); painter->setPen(borderPen); painter->drawRect(0,0,4*SIDE,8*SIDE); } bool trueMapIndexes; if(!m_map.isEmpty()){ qDebug()<<m_map; if (m_map.size()<5){ trueMapIndexes = true; for (quint8 i = 0; i<m_map.size(); i++){ if (m_map[i].size()>=9){ trueMapIndexes = false; } } if(trueMapIndexes){ for(quint8 x = 0; x<m_map.size(); x++){ //qDebug()<<"m_mapWHAT?1"; for(quint8 y = 0; y<m_map[x].size();y++){ //qDebug()<<"m_mapWHAT?"; ///##################### mePen = QPen(QColor(233,233,233)); mePen.setWidth(ME_PEN_WIDTH); painter->setPen(mePen); if (m_map[x][y] & (1<<LEFT)){ painter->drawLine(QLine(SIDE*x + M_OFFSET, SIDE*y + HALF, SIDE*x + HALF, SIDE*y + HALF)); } if (m_map[x][y] & (1<<RIGTH)){ painter->drawLine(QLine(SIDE*x + HALF, SIDE*y + HALF, SIDE*x + M_FULL,SIDE*y + HALF)); } if (m_map[x][y] & (1<<TOP)){ painter->drawLine(QLine(SIDE*x + HALF, SIDE*y + M_OFFSET, SIDE*x + HALF, SIDE*y + HALF)); } if (m_map[x][y] & (1<<DOWN)){ painter->drawLine(QLine(SIDE*x + HALF, SIDE*y + HALF, SIDE*x + HALF, SIDE*y + M_FULL)); } if (m_map[x][y] & (1<<CIRC)){ painter->setBrush(SCENE_COLOR); painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(SIDE*x + SIDE/4, SIDE*y + SIDE/4, SIDE/2, SIDE/2, SIDE/3, SIDE/3); painter->setRenderHint(QPainter::Antialiasing, false); } ///##################### } } } } } }