int main() { system("cls"); int r,g,a,i,j,e,z,k=0; char ch; for(i=1,a=I;i<I/2;i++,a--){ for(j=I-sqrt(I*I-(a-i)*(a-i));j>0;j--) printf(" "); for(e=1;e<=sqrt(I*I-(a-i)*(a-i));e++) {Sleep(10);color(e%16);printf("\3");} z=2*sqrt(I*I-(a-i)*(a-i)); for(;e<=2*sqrt(I*I-(a-i)*(a-i));e++) {Sleep(10);color((z-e)%16);printf("\3");} for(j=2*( I-sqrt(I*I-(a-i)*(a-i)) );j>0;j--) printf(" "); for(e=1;e<=sqrt(I*I-(a-i)*(a-i));e++) {Sleep(10);color(e%16);printf("\3");} for(;e<=2*sqrt(I*I-(a-i)*(a-i));e++) {Sleep(10);color((z-e)%16);printf("\3");} printf("\n"); } for(i=1;i<=R/2;i++){ if(i%2||i%3)continue; for(j=R-sqrt(R*R-i*i);j>0;j--) printf(" "); for(e=1;e<=( sqrt(R*R-i*i) - (R-2*I) );e++) {Sleep(10);color(e%16);printf("\3");} z=2*( sqrt(R*R-i*i) - (R-2*I) ); for(;e<=2*( sqrt(R*R-i*i) - (R-2*I) );e++) {Sleep(10);color((z-e)%16);printf("\3");} printf("\n"); } for(g=1;g<36;g++) { for(i=1,a=I,r=0;i<I/2;i++,a--,r++){ gotoxy(g,r); for(j=I-sqrt(I*I-(a-i)*(a-i));j>0;j--) printf(" "); for(e=1;e<=sqrt(I*I-(a-i)*(a-i));e++) {color((e+k)%16);printf("\3");} z=2*sqrt(I*I-(a-i)*(a-i)); for(;e<=2*sqrt(I*I-(a-i)*(a-i));e++) {color((z-e+k)%16);printf("\3");} for(j=2*( I-sqrt(I*I-(a-i)*(a-i)) );j>0;j--) printf(" "); for(e=1;e<=sqrt(I*I-(a-i)*(a-i));e++) {color((e+k)%16);printf("\3");} for(;e<=2*sqrt(I*I-(a-i)*(a-i));e++) {color((z-e+k)%16);printf("\3");} printf("\n"); } for(i=1;i<=R/2;i++) { if(i%2||i%3)continue;gotoxy(g,r);r++; for(j=R-sqrt(R*R-i*i);j>0;j--) printf(" "); for(e=1;e<=( sqrt(R*R-i*i) - (R-2*I) );e++) {color((e+k)%16);printf("\3");} z=2*( sqrt(R*R-i*i) - (R-2*I) ); for(;e<=2*( sqrt(R*R-i*i) - (R-2*I) );e++) {color((z-e+k)%16);printf("\3");} printf("\n"); } } k=0; while(1) { // system("cls"); // system("color c"); gotoxy(0,0); for(i=0;i<2*k&&i<250;i++) { color(4);printf("%c",h[i]); } for(i=1,a=I,r=0;i<I/2;i++,a--,r++){ gotoxy(35,r); for(j=I-sqrt(I*I-(a-i)*(a-i));j>0;j--) printf(" "); for(e=1;e<=sqrt(I*I-(a-i)*(a-i));e++) {color((e+k)%16);printf("\3");} z=2*sqrt(I*I-(a-i)*(a-i)); for(;e<=2*sqrt(I*I-(a-i)*(a-i));e++) {color((z-e+k)%16);printf("\3");} for(j=2*( I-sqrt(I*I-(a-i)*(a-i)) );j>0;j--) printf(" "); for(e=1;e<=sqrt(I*I-(a-i)*(a-i));e++) {color((e+k)%16);printf("\3");} for(;e<=2*sqrt(I*I-(a-i)*(a-i));e++) {color((z-e+k)%16);printf("\3");} printf("\n"); } for(i=1;i<=R/2;i++) { if(i%2||i%3)continue;gotoxy(35,r);r++; for(j=R-sqrt(R*R-i*i);j>0;j--) printf(" "); for(e=1;e<=( sqrt(R*R-i*i) - (R-2*I) );e++) {color((e+k)%16);printf("\3");} z=2*( sqrt(R*R-i*i) - (R-2*I) ); for(;e<=2*( sqrt(R*R-i*i) - (R-2*I) );e++) {color((z-e+k)%16);printf("\3");} printf("\n"); } k++; Sleep(50); } return 0; }
void Panel::Draw() { //Draw panel KrRGBA *pixels = getCanvasResource()->Pixels(); int width = Width(), height = Height(); if(flags.IsSet(FLAG_HASSHADOWS)) { width -= SHADOW_THICKNESS; height -= SHADOW_THICKNESS; } if(bInvertBevel) { KrRGBA aux; aux = colorUp; colorUp = colorDown; colorDown = aux; } //Fill background int i, j; for(j = 0; j < height; j++) { KrRGBA color(SlowCanvas::MixColors(Panel::getColorUp(), Panel::getColorDown(), j/(double)height)); for(i = 0; i < width; i++) { pixels[ j*Width() + i ] = color; } } //Glass effect if(height < 55) { KrRGBA white(255, 255, 255); int hm = height/2; for(j = 0; j < hm; j++) { for(i = 0; i < width; i++) { pixels[ j*Width() + i ] = SlowCanvas::MixColors(pixels[ j*Width() + i ], white, .8*j/(double)hm); } } } KrRGBA colorBorder(104, 104, 104); //Horizontal lines for(i = 0; i < width; i++) { pixels[ i ] = colorBorder; pixels[ (height-1)*Width() + i ] = colorBorder; } //Vertical lines for(j = 0; j < height; j++) { pixels[ j*Width() ] = colorBorder; pixels[ j*Width() + (width-1) ] = colorBorder; } //Corner pixels pixels[ 1 + 1*Width() ] = colorBorder; pixels[ (width - 2) + 1*Width() ] = colorBorder; pixels[ (width - 2) + (height - 2)*Width() ] = colorBorder; pixels[ 1 + (height - 2)*Width() ] = colorBorder; //Restore colors if(bInvertBevel) { KrRGBA aux; aux = colorUp; colorUp = colorDown; colorDown = aux; } //Make trasparent corners KrRGBA transp(0, 0, 0, 0); pixels[ 0 + 0*Width() ] = transp; pixels[ 1 + 0*Width() ] = transp; pixels[ 0 + 1*Width() ] = transp; pixels[ (width - 1) + 0*Width() ] = transp; pixels[ (width - 2) + 0*Width() ] = transp; pixels[ (width - 1) + 1*Width() ] = transp; if(!flags.IsSet(FLAG_HASSHADOWS)) { pixels[ (width - 1) + (height - 1)*Width() ] = transp; pixels[ (width - 2) + (height - 1)*Width() ] = transp; pixels[ (width - 1) + (height - 2)*Width() ] = transp; } pixels[ 0 + (height - 1)*Width() ] = transp; pixels[ 1 + (height - 1)*Width() ] = transp; pixels[ 0 + (height - 2)*Width() ] = transp; if(flags.IsSet(FLAG_HASSHADOWS)) { KrRGBA colorShadow; double shadowFactor; //Orange colorShadow.c.red = 0; colorShadow.c.green = 0; colorShadow.c.blue = 0; colorShadow.c.alpha = SHADOW_MAX; //Corner pixels[ (width - 1) + (height - 1)*Width() ] = colorShadow; pixels[ (width - 2) + (height - 1)*Width() ] = colorShadow; pixels[ (width - 1) + (height - 2)*Width() ] = colorShadow; //Vertical shadow for(i = width; i < Width(); i++) { for(int j = SHADOW_THICKNESS; j < Height(); j++) { shadowFactor = 1.0 - (i - width)/(double)SHADOW_THICKNESS; shadowFactor *= (j >= height)?(1.0 - (j - height)/(double)SHADOW_THICKNESS):1.0; shadowFactor *= (j - SHADOW_THICKNESS < SHADOW_FADE)?(j - SHADOW_THICKNESS)/(double)SHADOW_FADE:1.0; colorShadow.c.alpha = SHADOW_MAX*shadowFactor; pixels[ j*Width() + i ] = colorShadow; } } //Horizontal shadow for(i = SHADOW_THICKNESS; i < Width() - SHADOW_THICKNESS; i++) { for(int j = height; j < Height(); j++) { shadowFactor = 1.0 - (j - height)/(double)SHADOW_THICKNESS; shadowFactor *= (i - SHADOW_THICKNESS < SHADOW_FADE)?(i - SHADOW_THICKNESS)/(double)SHADOW_FADE:1.0; colorShadow.c.alpha = SHADOW_MAX*shadowFactor; pixels[ j*Width() + i ] = colorShadow; } } } getCanvasResource()->Refresh(); }
void ArtifactCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QRect r = rect(); const BasicData * data = browser_node->get_data(); FILE * fp = svg(); if (fp != 0) fputs("<g>\n", fp); const QPixmap * px = ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom()); if (px != 0) { p.setBackgroundMode(::Qt::TransparentMode); int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x(); p.drawPixmap(lft, r.y(), *px); if (fp != 0) // pixmap not really exported in SVG fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1); r.moveBy(0, px->height()); p.setFont(the_canvas()->get_font(UmlNormalBoldFont)); p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name()); if (fp != 0) { draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(), p.font(), fp); fputs("</g>\n", fp); } } else { QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); p.setBackgroundColor(co); // <<artifact>>/stereotype on 2*font_height with the icon on the right // the icon height = 2*font_height // the icon width = 3*height/4 // name on font_height+4 points const int four = (int) (4 * the_canvas()->zoom()); QFontMetrics fm(the_canvas()->get_font(UmlNormalBoldFont)); const int he = fm.height(); if (used_color != UmlTransparent) { const int shadow = the_canvas()->shadow(); if (shadow != 0) { r.setRight(r.right() - shadow); r.setBottom(r.bottom() - shadow); p.fillRect (r.right(), r.top() + shadow, shadow, r.height() - 1, ::Qt::darkGray); p.fillRect (r.left() + shadow, r.bottom(), r.width() - 1, shadow, ::Qt::darkGray); if (fp != 0) { fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", QColor(::Qt::darkGray).rgb()&0xffffff, r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1); fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", QColor(::Qt::darkGray).rgb()&0xffffff, r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1); } } } QRect re = r; if (used_color != UmlTransparent) { p.fillRect(r, co); if (fp != 0) fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); } else if (fp != 0) fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", r.x(), r.y(), r.width() - 1, r.height() - 1); p.drawRect(r); r.setHeight(he*2); p.setFont(the_canvas()->get_font(UmlNormalFont)); if (data->get_stereotype()[0]) { p.drawText(r, ::Qt::AlignCenter, QString("<<") + toUnicode(data->get_short_stereotype()) + ">>"); if (fp != 0) draw_text(r, ::Qt::AlignCenter, QString("<<") + toUnicode(data->get_short_stereotype()) + ">>", p.font(), fp); } else { p.drawText(r, ::Qt::AlignCenter, "<<artifact>>"); if (fp != 0) draw_text(r, ::Qt::AlignCenter, "<<artifact>>", p.font(), fp); } r.moveBy(0, r.height()); r.setHeight(he+four); p.setFont(the_canvas()->get_font(UmlNormalBoldFont)); p.drawText(r, ::Qt::AlignCenter, browser_node->get_name()); if (fp != 0) draw_text(r, ::Qt::AlignCenter, browser_node->get_name(), p.font(), fp); p.setFont(the_canvas()->get_font(UmlNormalFont)); // draw icon re.setLeft(re.right() - 6*he/4 + four); re.setRight(re.right() - four); re.setTop(re.top() + four); re.setHeight(2*(he - four)); Q3PointArray a(7); const int corner_size = re.width()/3; a.setPoint(0, re.left(), re.top()); a.setPoint(1, re.right() - corner_size, re.top()); a.setPoint(2, re.right() - corner_size, re.top() + corner_size); a.setPoint(3, re.right(), re.top() + corner_size); a.setPoint(4, re.right(), re.bottom()); a.setPoint(5, re.left(), re.bottom()); a.setPoint(6, re.left(), re.top()); p.drawPolyline(a); //p.moveTo(re.right() - corner_size, re.top()); //p.lineTo(re.right(), re.top() + corner_size); p.drawLine(re.right() - corner_size, re.top(), re.right(), re.top() + corner_size); if (fp != 0) { draw_poly(fp, a, UmlTransparent); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n" "</g>\n", re.right() - corner_size, re.top(), re.right(), re.top() + corner_size); } p.setBackgroundColor(bckgrnd); } if (selected()) show_mark(p, rect()); }
static void wt_status_print_trailer(struct wt_status *s) { status_printf_ln(s, color(WT_STATUS_HEADER, s), ""); }
void wt_status_print(struct wt_status *s) { const char *branch_color = color(WT_STATUS_ONBRANCH, s); const char *branch_status_color = color(WT_STATUS_HEADER, s); if (s->branch) { const char *on_what = _("On branch "); const char *branch_name = s->branch; if (!prefixcmp(branch_name, "refs/heads/")) branch_name += 11; else if (!strcmp(branch_name, "HEAD")) { branch_name = ""; branch_status_color = color(WT_STATUS_NOBRANCH, s); on_what = _("Not currently on any branch."); } status_printf(s, color(WT_STATUS_HEADER, s), ""); status_printf_more(s, branch_status_color, "%s", on_what); status_printf_more(s, branch_color, "%s\n", branch_name); if (!s->is_initial) wt_status_print_tracking(s); } if (s->is_initial) { status_printf_ln(s, color(WT_STATUS_HEADER, s), ""); status_printf_ln(s, color(WT_STATUS_HEADER, s), _("Initial commit")); status_printf_ln(s, color(WT_STATUS_HEADER, s), ""); } wt_status_print_updated(s); wt_status_print_unmerged(s); wt_status_print_changed(s); if (s->submodule_summary && (!s->ignore_submodule_arg || strcmp(s->ignore_submodule_arg, "all"))) { wt_status_print_submodule_summary(s, 0); /* staged */ wt_status_print_submodule_summary(s, 1); /* unstaged */ } if (s->show_untracked_files) { wt_status_print_other(s, &s->untracked, _("Untracked"), "add"); if (s->show_ignored_files) wt_status_print_other(s, &s->ignored, _("Ignored"), "add -f"); } else if (s->commitable) status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"), advice_status_hints ? _(" (use -u option to show untracked files)") : ""); if (s->verbose) wt_status_print_verbose(s); if (!s->commitable) { if (s->amend) status_printf_ln(s, GIT_COLOR_NORMAL, _("No changes")); else if (s->nowarn) ; /* nothing */ else if (s->workdir_dirty) printf(_("no changes added to commit%s\n"), advice_status_hints ? _(" (use \"git add\" and/or \"git commit -a\")") : ""); else if (s->untracked.nr) printf(_("nothing added to commit but untracked files present%s\n"), advice_status_hints ? _(" (use \"git add\" to track)") : ""); else if (s->is_initial) printf(_("nothing to commit%s\n"), advice_status_hints ? _(" (create/copy files and use \"git add\" to track)") : ""); else if (!s->show_untracked_files) printf(_("nothing to commit%s\n"), advice_status_hints ? _(" (use -u to show untracked files)") : ""); else printf(_("nothing to commit%s\n"), advice_status_hints ? _(" (working directory clean)") : ""); } }
InputWindow::InputWindow(int w, int h, const char *label, const char *defaultName, InputWindowType type, int folderIndex) : Fl_Window(MAX(w, 445), h, label), cbUseDefaultNames(NULL), ctFileChooser(NULL), userWindowStatus(OK), fileSelectionIndex(-1) { string = (char*)malloc(sizeof(char)*90); color(GUI_WINDOW_BGCOLOR); set_modal(); windowType = type; inputText = (char *) malloc(MAX_BUFFER_SIZE * sizeof(char)); if(type == InputWindow::FILE_INPUT) { strncpy(inputText, defaultName, MAX_BUFFER_SIZE - 1); inputText[MAX_BUFFER_SIZE - 1] = '\0'; char *extPtr = strrchr(inputText, '.'); if(extPtr != NULL) { *extPtr = '\0'; } char *filenameStartPtr = strrchr(inputText, '/'); int fnameStartPos; if(filenameStartPtr != NULL) { fnameStartPos = filenameStartPtr - inputText; } else { fnameStartPos = 0; } char saveDirInfo[MAX_BUFFER_SIZE]; snprintf(saveDirInfo, fnameStartPos + 1, "%s", inputText); sprintf(string, "Export to Directory: %s", saveDirInfo); input = new Fl_Input(25, 50, 235, 30); input->when(FL_WHEN_ENTER_KEY); input->value(filenameStartPtr + 1); Fl_Box *box = new Fl_Box(110, 20, 100, 30, (const char*)string); box->box(FL_NO_BOX); box->align(FL_ALIGN_CENTER); Fl_Box *fileExtBox = new Fl_Box(260,50,30,30,".csv"); Fl_Button *button = new Fl_Button(305, 50, 110, 30, "Export to CSV @->"); button->callback(InputCallback, (void*)0); button->set_active(); input->callback(InputCallback, (void*)0); callback(CloseCallback); } else if(type == InputWindow::FOLDER_INPUT) { std::string actualStructName = ExtractStructureNameFromCTName(defaultName); const char *actualStructNameCStr = actualStructName.c_str(); strncpy(inputText, actualStructNameCStr, actualStructName.size() + 1); ConfigParser::nullTerminateString(inputText, actualStructName.size()); sprintf(string, "Creating new folder for the CT structure %s", defaultName); input = new Fl_Input(160, 50, 250, 30, "@fileopen New Folder Name:"); input->when(FL_WHEN_ENTER_KEY); input->maximum_size(60); input->value(inputText); input->color(GUI_BGCOLOR); input->textcolor(GUI_BTEXT_COLOR); Fl_Box *box = new Fl_Box(50, 1, 350, 40, (const char*) string); box->box(FL_OSHADOW_BOX); box->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_WRAP); box->color(GUI_BGCOLOR); box->labelcolor(GUI_BTEXT_COLOR); Fl_Button *button = new Fl_Button(340, 50, 100, 30, "Add Folder @|>"); button->callback(InputCallback, (void*)0); button->labelcolor(GUI_BTEXT_COLOR); button->set_active(); input->callback(InputCallback, (void*)0); input->labelcolor(GUI_TEXT_COLOR); const char *cbText = " Use only default names for structure folders"; cbUseDefaultNames = new Fl_Check_Button(30, 100, 375, 30, cbText); cbUseDefaultNames->box(FL_ROUND_UP_BOX); cbUseDefaultNames->color(GUI_BGCOLOR); cbUseDefaultNames->labelcolor(GUI_BTEXT_COLOR); cbUseDefaultNames->down_color(GUI_WINDOW_BGCOLOR); cbUseDefaultNames->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CENTER); callback(CloseCallback); } else { const char *windowDisplayMsg = "Which CT file structure for the organism\ndo you want to display?"; Fl_Box *box = new Fl_Box(75, 5, 300, 40, windowDisplayMsg); box->box(FL_RSHADOW_BOX); box->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_WRAP); box->color(GUI_BGCOLOR); box->labelcolor(GUI_BTEXT_COLOR); Fl_Button *displayButton = new Fl_Button(100, 100, 200, 30, "Display Zoomed Region @|>"); displayButton->callback(DisplayCTFileCallback, (void*)0); displayButton->color(GUI_BGCOLOR); displayButton->labelcolor(GUI_BTEXT_COLOR); displayButton->set_active(); //displayButton->shortcut(FL_Enter); Fl_Button *cancelButton = new Fl_Button(310, 100, 75, 30, "Cancel @1+"); cancelButton->callback(CancelCallback); cancelButton->color(GUI_BGCOLOR); cancelButton->labelcolor(GUI_BTEXT_COLOR); ctFileChooser = new Fl_Choice(175, 55, 215, 30, "Choose CT Structure: "); ctFileChooser->color(GUI_BGCOLOR); ctFileChooser->labelcolor(GUI_BTEXT_COLOR); StructureManager *structManager = RNAStructViz::GetInstance()->GetStructureManager(); Folder *curFolder = structManager->GetFolderAt(folderIndex); for(int s = 0; s < curFolder->structCount; s++) { RNAStructure *rnaStruct = structManager->GetStructure(curFolder->folderStructs[s]); const char *ctFileName = rnaStruct->GetFilename(); ctFileChooser->add(ctFileName); } ctFileChooser->value(0); } show(); if(type != InputWindow::FOLDER_INPUT || !GUI_USE_DEFAULT_FOLDER_NAMES) { show(); } else { show(); InputCallback((Fl_Widget *) cbUseDefaultNames, (void *) NULL); } }
void ADFun<Base>::SparseJacobianCase( const std::set<size_t>& set_type , const VectorBase& x , const VectorSet& p , VectorBase& jac ) { typedef CppAD::vector<size_t> SizeVector; typedef CppAD::vectorBool VectorBool; size_t i, j, k; size_t m = Range(); size_t n = Domain(); // some values const Base zero(0); const Base one(1); // check VectorSet is Simple Vector class with sets for elements CheckSimpleVector<std::set<size_t>, VectorSet>( one_element_std_set<size_t>(), two_element_std_set<size_t>() ); // check VectorBase is Simple Vector class with Base type elements CheckSimpleVector<Base, VectorBase>(); CPPAD_ASSERT_KNOWN( x.size() == n, "SparseJacobian: size of x not equal domain dimension for f" ); CPPAD_ASSERT_KNOWN( p.size() == m, "SparseJacobian: using sets and size of p " "not equal range dimension for f" ); CPPAD_ASSERT_UNKNOWN(jac.size() == m * n); // point at which we are evaluating the Jacobian Forward(0, x); // initialize the return value for(i = 0; i < m; i++) for(j = 0; j < n; j++) jac[i * n + j] = zero; // create a copy of the transpose sparsity pattern VectorSet q(n); std::set<size_t>::const_iterator itr_i, itr_j; for(i = 0; i < m; i++) { itr_j = p[i].begin(); while( itr_j != p[i].end() ) { j = *itr_j++; q[j].insert(i); } } if( n <= m ) { // use forward mode ---------------------------------------- // initial coloring SizeVector color(n); for(j = 0; j < n; j++) color[j] = j; // See GreedyPartialD2Coloring Algorithm Section 3.6.2 of // Graph Coloring in Optimization Revisited by // Assefaw Gebremedhin, Fredrik Maane, Alex Pothen VectorBool forbidden(n); for(j = 0; j < n; j++) { // initial all colors as ok for this column for(k = 0; k < n; k++) forbidden[k] = false; // for each row connected to column j itr_i = q[j].begin(); while( itr_i != q[j].end() ) { i = *itr_i++; // for each column connected to row i itr_j = p[i].begin(); while( itr_j != p[i].end() ) { // if this is not j, forbid it k = *itr_j++; forbidden[ color[k] ] = (k != j); } } k = 0; while( forbidden[k] && k < n ) { k++; CPPAD_ASSERT_UNKNOWN( k < n ); } color[j] = k; } size_t n_color = 1; for(k = 0; k < n; k++) n_color = std::max(n_color, color[k] + 1); // direction vector for calls to forward VectorBase dx(n); // location for return values from Reverse VectorBase dy(m); // loop over colors size_t c; for(c = 0; c < n_color; c++) { // determine all the colums with this color for(j = 0; j < n; j++) { if( color[j] == c ) dx[j] = one; else dx[j] = zero; } // call forward mode for all these columns at once dy = Forward(1, dx); // set the corresponding components of the result for(j = 0; j < n; j++) if( color[j] == c ) { itr_i = q[j].begin(); while( itr_i != q[j].end() ) { i = *itr_i++; jac[i * n + j] = dy[i]; } } } } else { // use reverse mode ---------------------------------------- // initial coloring SizeVector color(m); for(i = 0; i < m; i++) color[i] = i; // See GreedyPartialD2Coloring Algorithm Section 3.6.2 of // Graph Coloring in Optimization Revisited by // Assefaw Gebremedhin, Fredrik Maane, Alex Pothen VectorBool forbidden(m); for(i = 0; i < m; i++) { // initial all colors as ok for this row for(k = 0; k < m; k++) forbidden[k] = false; // for each column connected to row i itr_j = p[i].begin(); while( itr_j != p[i].end() ) { j = *itr_j++; // for each row connected to column j itr_i = q[j].begin(); while( itr_i != q[j].end() ) { // if this is not i, forbid it k = *itr_i++; forbidden[ color[k] ] = (k != i); } } k = 0; while( forbidden[k] && k < m ) { k++; CPPAD_ASSERT_UNKNOWN( k < n ); } color[i] = k; } size_t n_color = 1; for(k = 0; k < m; k++) n_color = std::max(n_color, color[k] + 1); // weight vector for calls to reverse VectorBase w(m); // location for return values from Reverse VectorBase dw(n); // loop over colors size_t c; for(c = 0; c < n_color; c++) { // determine all the rows with this color for(i = 0; i < m; i++) { if( color[i] == c ) w[i] = one; else w[i] = zero; } // call reverse mode for all these rows at once dw = Reverse(1, w); // set the corresponding components of the result for(i = 0; i < m; i++) if( color[i] == c ) { itr_j = p[i].begin(); while( itr_j != p[i].end() ) { j = *itr_j++; jac[i * n + j] = dw[j]; } } } } }
void btConvexTriangleCallback::processTriangle(btVector3* triangle, int partId, int triangleIndex) { if (!TestTriangleAgainstAabb2(triangle, m_aabbMin, m_aabbMax)) { return; } //just for debugging purposes //printf("triangle %d", m_triangleCount++); const btCollisionObject* ob = const_cast<btCollisionObject*>(m_triBodyWrap->getCollisionObject()); btCollisionAlgorithmConstructionInfo ci; ci.m_dispatcher1 = m_dispatcher; //const btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBodyWrap->getCollisionObject()); #if 1 ///debug drawing of the overlapping triangles if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe )) { btVector3 color(1,1,0); const btTransform& tr = ob->getWorldTransform(); m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]), tr(triangle[1]), color); m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]), tr(triangle[2]), color); m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]), tr(triangle[0]), color); } #endif if (m_convexBodyWrap->getCollisionShape()->isConvex()) { btTriangleShape tm(triangle[0], triangle[1], triangle[2]); tm.setMargin(m_collisionMarginTriangle); btCollisionObjectWrapper triObWrap(m_triBodyWrap, &tm, m_triBodyWrap->getCollisionObject(), m_triBodyWrap->getWorldTransform(), partId, triangleIndex);//correct transform? btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBodyWrap, &triObWrap, m_manifoldPtr); const btCollisionObjectWrapper* tmpWrap = 0; if (m_resultOut->getBody0Internal() == m_triBodyWrap->getCollisionObject()) { tmpWrap = m_resultOut->getBody0Wrap(); m_resultOut->setBody0Wrap(&triObWrap); m_resultOut->setShapeIdentifiersA(partId, triangleIndex); } else { tmpWrap = m_resultOut->getBody1Wrap(); m_resultOut->setBody1Wrap(&triObWrap); m_resultOut->setShapeIdentifiersB(partId, triangleIndex); } colAlgo->processCollision(m_convexBodyWrap, &triObWrap, *m_dispatchInfoPtr, m_resultOut); btIDebugDraw *drawer = NULL; if (m_dispatchInfoPtr) { drawer = m_dispatchInfoPtr->m_debugDraw; } // Compensate for any internal edge contact points btPersistentManifold *manifold = m_resultOut->getPersistentManifold(); for (int i = 0; i < manifold->getNumContacts(); i++) { btManifoldPoint &pt = manifold->getContactPoint(i); btAdjustInternalEdgeContacts(pt, &triObWrap, m_convexBodyWrap, partId, triangleIndex, BT_TRIANGLE_CONVEX_DOUBLE_SIDED | BT_TRIANGLE_CONCAVE_DOUBLE_SIDED, drawer); } if (m_resultOut->getBody0Internal() == m_triBodyWrap->getCollisionObject()) { m_resultOut->setBody0Wrap(tmpWrap); } else { m_resultOut->setBody1Wrap(tmpWrap); } colAlgo->~btCollisionAlgorithm(); ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo); } }
void Tweener::release(const TupInputDeviceInformation *input, TupBrushManager *brushManager, TupGraphicsScene *scene) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[Tweener::release()]"; #else T_FUNCINFO; #endif #endif Q_UNUSED(input); Q_UNUSED(brushManager); if (scene->currentFrameIndex() == k->initFrame) { if (k->editMode == TupToolPlugin::Properties) { if (k->nodesGroup) { k->nodesGroup->createNodes(k->path); k->nodesGroup->show(); k->nodesGroup->expandAllNodes(); k->configurator->updateSteps(k->path); QPainterPath::Element e = k->path->path().elementAt(0); QPointF begin = QPointF(e.x, e.y); if (begin != k->firstNode) { QPointF oldPos = k->firstNode; QPointF newPos = begin; int distanceX = newPos.x() - oldPos.x(); int distanceY = newPos.y() - oldPos.y(); if (k->objects.size() > 0) { foreach (QGraphicsItem *item, k->objects) item->moveBy(distanceX, distanceY); QGraphicsItem *item = k->objects.at(0); QRectF rect = item->sceneBoundingRect(); k->itemObjectReference = rect.center(); } k->firstNode = newPos; } updateTweenPoints(); } } else { if (scene->selectedItems().size() > 0) { k->objects = scene->selectedItems(); k->configurator->notifySelection(true); QGraphicsItem *item = k->objects.at(0); QRectF rect = item->sceneBoundingRect(); QPointF newPos = rect.center(); QPointF oldPos = k->itemObjectReference; k->itemObjectReference = newPos; if (!k->path) { k->path = new QGraphicsPathItem; k->path->setZValue(k->baseZValue); QColor color(55, 155, 55, 200); QPen pen(QBrush(color), 2, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin); k->path->setPen(pen); QPainterPath path; path.moveTo(newPos); k->firstNode = newPos; k->path->setPath(path); scene->addItem(k->path); k->isPathInScene = true; k->pathOffset = QPointF(0, 0); } else { int distanceX = newPos.x() - oldPos.x(); int distanceY = newPos.y() - oldPos.y(); k->path->moveBy(distanceX, distanceY); k->pathOffset = QPointF(distanceX, distanceY); // k->firstNode = newPos; } } } } }
// draw lines connecting pairs of points void Lines::draw_lines() const { if (color().visibility()) for (int i=1; i<number_of_points(); i+=2) fl_line(point(i-1).x,point(i-1).y,point(i).x,point(i).y); }
/* * Using polygons, hatching, and filling. */ main() { short val; winopen("poly"); unqdevice(INPUTCHANGE); qdevice(KEYBD); /* enable keyboard */ /* * Wait for REDRAW event ... */ while (qread(&val) != REDRAW) ; color(BLACK); /* clear to black */ clear(); /* * world coordinates are now in the range -10 to 10 * in x, y, and z. Note that positive z is towards us. */ ortho(-10.0, 10.0, -10.0, 10.0, 10.0, -10.0); color(YELLOW); /* * write out the string "Polygon from poly()" in the * starting at (-8.0, -4.0) and scaled to be 4.0 units long, * 0.5 units high. */ hfont("futura.m"); hboxtext(-8.0, -4.0, 4.0, 0.5, "Polygon from poly()/ polf()"); color(GREEN); /* * write out a scaled string starting at (0.0, 6.0) */ hboxtext(0.0, 6.0, 4.5, 0.5, "Polygon from bgnpoly()/ endpoly()"); hboxtext(0.0, 5.0, 4.5, 0.5, " pmv()/ pdr()/ pclos()"); color(MAGENTA); /* * write out a scaled string starting at (0.0, 6.0) */ hboxtext(3.5, -3.5, 1.9, 0.5, "Arc/ Arcf"); /* * draw some wire frame polygons */ drawpoly(); /* * rotate so the next polygons will appear in a different place. */ rot(20.0, 'x'); rot(30.0, 'y'); /* * draw some filled polygons. */ drawpolyf(); gexit(); }
void Shape::draw_lines() const { if (color().visibility() && 1<points.size()) // draw sole pixel? for (unsigned int i=1; i<points.size(); ++i) fl_line(points[i-1].x,points[i-1].y,points[i].x,points[i].y); }
void read_object_properties(lua_State *L, int index, ObjectProperties *prop) { if(index < 0) index = lua_gettop(L) + 1 + index; if(!lua_istable(L, index)) return; prop->hp_max = getintfield_default(L, -1, "hp_max", 10); getboolfield(L, -1, "physical", prop->physical); getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects); getfloatfield(L, -1, "weight", prop->weight); lua_getfield(L, -1, "collisionbox"); if(lua_istable(L, -1)) prop->collisionbox = read_aabb3f(L, -1, 1.0); lua_pop(L, 1); getstringfield(L, -1, "visual", prop->visual); getstringfield(L, -1, "mesh", prop->mesh); lua_getfield(L, -1, "visual_size"); if(lua_istable(L, -1)) prop->visual_size = read_v2f(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "textures"); if(lua_istable(L, -1)){ prop->textures.clear(); int table = lua_gettop(L); lua_pushnil(L); while(lua_next(L, table) != 0){ // key at index -2 and value at index -1 if(lua_isstring(L, -1)) prop->textures.push_back(lua_tostring(L, -1)); else prop->textures.push_back(""); // removes value, keeps key for next iteration lua_pop(L, 1); } } lua_pop(L, 1); lua_getfield(L, -1, "colors"); if (lua_istable(L, -1)) { int table = lua_gettop(L); prop->colors.clear(); for (lua_pushnil(L); lua_next(L, table); lua_pop(L, 1)) { video::SColor color(255, 255, 255, 255); read_color(L, -1, &color); prop->colors.push_back(color); } } lua_pop(L, 1); lua_getfield(L, -1, "spritediv"); if(lua_istable(L, -1)) prop->spritediv = read_v2s16(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "initial_sprite_basepos"); if(lua_istable(L, -1)) prop->initial_sprite_basepos = read_v2s16(L, -1); lua_pop(L, 1); getboolfield(L, -1, "is_visible", prop->is_visible); getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound); getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate); if (getfloatfield(L, -1, "stepheight", prop->stepheight)) prop->stepheight *= BS; lua_getfield(L, -1, "automatic_face_movement_dir"); if (lua_isnumber(L, -1)) { prop->automatic_face_movement_dir = true; prop->automatic_face_movement_dir_offset = luaL_checknumber(L, -1); } else if (lua_isboolean(L, -1)) { prop->automatic_face_movement_dir = lua_toboolean(L, -1); prop->automatic_face_movement_dir_offset = 0.0; } lua_pop(L, 1); getboolfield(L, -1, "backface_culling", prop->backface_culling); getstringfield(L, -1, "nametag", prop->nametag); lua_getfield(L, -1, "nametag_color"); if (!lua_isnil(L, -1)) { video::SColor color = prop->nametag_color; if (read_color(L, -1, &color)) prop->nametag_color = color; } lua_pop(L, 1); lua_getfield(L, -1, "automatic_face_movement_max_rotation_per_sec"); if (lua_isnumber(L, -1)) { prop->automatic_face_movement_max_rotation_per_sec = luaL_checknumber(L, -1); } lua_pop(L, 1); getstringfield(L, -1, "infotext", prop->infotext); }
/* >>>>>>>>>> EX10_1 <<<<<<<<<< */ void ex10_1 (void) { int nya = 2700, i; static char *ctit = "Bar Graphs (BARS)", cbuf[25]; static float x[9] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f}, y[9] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}, y1[9] = {1.f, 1.5f, 2.5f, 1.3f, 2.0f, 1.2f, 0.7f, 1.4f, 1.1f}, y2[9] = {2.f, 2.7f, 3.5f, 2.1f, 3.2f, 1.9f, 2.0f, 2.3f, 1.8f}, y3[9] = {4.f, 3.5f, 4.5f, 3.7f, 4.0f, 2.9f, 3.0f, 3.2f, 2.6f}; setpag ("da4p"); disini (); pagera (); hwfont (); ticks (1, "x"); intax ();; axslen (1600, 700); titlin (ctit, 3); legini (cbuf, 3, 8); leglin (cbuf, "FIRST", 1); leglin (cbuf, "SECOND", 2); leglin (cbuf, "THIRD", 3); legtit (" "); shdpat (5L); for (i = 1; i <= 3; i++) { if (i > 1) labels ("none", "x"); axspos (300, nya - (i - 1) * 800); graf (0.f, 10.f, 0.f, 1.f, 0.f, 5.f, 0.f, 1.f); if (i == 1) { bargrp (3, 0.15f); color ("red"); bars (x, y, y1, 9); color ("green"); bars (x, y, y2, 9); color ("blue"); bars (x, y, y3, 9); color ("fore"); reset ("bargrp"); } else if (i == 2) { height (30); labels ("delta", "bars"); labpos ("center", "bars"); color ("red"); bars (x, y, y1, 9); color ("green"); bars (x, y1, y2, 9); color ("blue"); bars (x, y2, y3, 9); color ("fore"); reset ("height"); } else if (i == 3) { labels ("second", "bars"); labpos ("outside", "bars"); color ("red"); bars (x, y, y1, 9); color ("fore"); } if (i != 3) legend (cbuf, 7); if (i == 3) { height (50); title (); } endgrf (); } disfin (); }
static void pixel_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; uint32_t *cells = malloc(t->real.width*t->real.height*4); struct { uint16_t x, y; } *pixels = malloc(reps*sizeof(*pixels)); int r, s; printf("Testing setting of single pixels (%s): ", test_target_name(target)); fflush(stdout); test_target_create_render(&t->real, target, &tt); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { int x = rand() % (tt.width - 1); int y = rand() % (tt.height - 1); int red = rand() % 0xff; int green = rand() % 0xff; int blue = rand() % 0xff; int alpha = rand() % 0xff; fill_rect(&t->real, tt.picture, PictOpSrc, x, y, 1, 1, 0, 0, MASK_NONE, red, green, blue, alpha); pixels[r].x = x; pixels[r].y = y; cells[y*t->real.width+x] = color(red, green, blue, alpha); } test_init_image(&image, &t->real.shm, tt.format, 1, 1); for (r = 0; r < reps; r++) { uint32_t result; uint32_t x = pixels[r].x; uint32_t y = pixels[r].y; XShmGetImage(t->real.dpy, tt.draw, &image, x, y, AllPlanes); result = *(uint32_t *)image.data; if (!pixel_equal(image.depth, result, cells[y*tt.width+x])) { uint32_t mask = depth_mask(image.depth); die("failed to set pixel (%d,%d) to %08x [%08x], found %08x [%08x] instead\n", x, y, cells[y*tt.width+x] & mask, cells[y*tt.width+x], result & mask, result); } } } printf("passed [%d iterations x %d]\n", reps, sets); test_target_destroy_render(&t->real, &tt); free(pixels); free(cells); }
void b2World::DrawDebugData() { if (m_debugDraw == NULL) { return; } uint32 flags = m_debugDraw->GetFlags(); if (flags & b2Draw::e_shapeBit) { for (b2Body* b = m_bodyList; b; b = b->GetNext()) { const b2Transform& xf = b->GetTransform(); for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) { if (b->IsActive() == false) { DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.3f)); } else if (b->GetType() == b2_staticBody) { DrawShape(f, xf, b2Color(0.5f, 0.9f, 0.5f)); } else if (b->GetType() == b2_kinematicBody) { DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.9f)); } else if (b->IsAwake() == false) { DrawShape(f, xf, b2Color(0.6f, 0.6f, 0.6f)); } else { DrawShape(f, xf, b2Color(0.9f, 0.7f, 0.7f)); } } } } if (flags & b2Draw::e_jointBit) { for (b2Joint* j = m_jointList; j; j = j->GetNext()) { DrawJoint(j); } } if (flags & b2Draw::e_pairBit) { b2Color color(0.3f, 0.9f, 0.9f); for (b2Contact* c = m_contactManager.m_contactList; c; c = c->GetNext()) { //b2Fixture* fixtureA = c->GetFixtureA(); //b2Fixture* fixtureB = c->GetFixtureB(); //b2Vec2 cA = fixtureA->GetAABB().GetCenter(); //b2Vec2 cB = fixtureB->GetAABB().GetCenter(); //m_debugDraw->DrawSegment(cA, cB, color); } } if (flags & b2Draw::e_aabbBit) { b2Color color(0.9f, 0.3f, 0.9f); b2BroadPhase* bp = &m_contactManager.m_broadPhase; for (b2Body* b = m_bodyList; b; b = b->GetNext()) { if (b->IsActive() == false) { continue; } for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) { for (int32 i = 0; i < f->m_proxyCount; ++i) { b2FixtureProxy* proxy = f->m_proxies + i; b2AABB aabb = bp->GetFatAABB(proxy->proxyId); b2Vec2 vs[4]; vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y); vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y); vs[2].Set(aabb.upperBound.x, aabb.upperBound.y); vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y); m_debugDraw->DrawPolygon(vs, 4, color); } } } } if (flags & b2Draw::e_centerOfMassBit) { for (b2Body* b = m_bodyList; b; b = b->GetNext()) { b2Transform xf = b->GetTransform(); xf.p = b->GetWorldCenter(); m_debugDraw->DrawTransform(xf); } } }
int PointHelpObject::DrawAndHit(TimeValue t, INode *inode, ViewExp *vpt) { if ( ! vpt || ! vpt->IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return FALSE; } float size; int centerMarker, axisTripod, cross, box, screenSize, drawOnTop; Color color(inode->GetWireColor()); Interval ivalid = FOREVER; pblock2->GetValue(pointobj_size, t, size, ivalid); pblock2->GetValue(pointobj_centermarker, t, centerMarker, ivalid); pblock2->GetValue(pointobj_axistripod, t, axisTripod, ivalid); pblock2->GetValue(pointobj_cross, t, cross, ivalid); pblock2->GetValue(pointobj_box, t, box, ivalid); pblock2->GetValue(pointobj_screensize, t, screenSize, ivalid); pblock2->GetValue(pointobj_drawontop, t, drawOnTop, ivalid); Matrix3 tm(1); Point3 pt(0,0,0); Point3 pts[5]; vpt->getGW()->setTransform(tm); tm = inode->GetObjectTM(t); int limits = vpt->getGW()->getRndLimits(); if (drawOnTop) vpt->getGW()->setRndLimits(limits & ~GW_Z_BUFFER); if (inode->Selected()) { vpt->getGW()->setColor( TEXT_COLOR, GetUIColor(COLOR_SELECTION) ); vpt->getGW()->setColor( LINE_COLOR, GetUIColor(COLOR_SELECTION) ); } else if (!inode->IsFrozen() && !inode->Dependent()) { //vpt->getGW()->setColor( TEXT_COLOR, GetUIColor(COLOR_POINT_AXES) ); //vpt->getGW()->setColor( LINE_COLOR, GetUIColor(COLOR_POINT_AXES) ); vpt->getGW()->setColor( TEXT_COLOR, color); vpt->getGW()->setColor( LINE_COLOR, color); } if (axisTripod) { DrawAxis(vpt, tm, size, screenSize); } size *= 0.5f; float zoom = vpt->GetScreenScaleFactor(tm.GetTrans())*ZFACT; if (screenSize) { tm.Scale(Point3(zoom,zoom,zoom)); } vpt->getGW()->setTransform(tm); if (!inode->IsFrozen() && !inode->Dependent() && !inode->Selected()) { //vpt->getGW()->setColor(LINE_COLOR, GetUIColor(COLOR_POINT_OBJ)); vpt->getGW()->setColor( LINE_COLOR, color); } if (centerMarker) { vpt->getGW()->marker(&pt,X_MRKR); } if (cross) { // X pts[0] = Point3(-size, 0.0f, 0.0f); pts[1] = Point3(size, 0.0f, 0.0f); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); // Y pts[0] = Point3(0.0f, -size, 0.0f); pts[1] = Point3(0.0f, size, 0.0f); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); // Z pts[0] = Point3(0.0f, 0.0f, -size); pts[1] = Point3(0.0f, 0.0f, size); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); } if (box) { // Make the box half the size size = size * 0.5f; // Bottom pts[0] = Point3(-size, -size, -size); pts[1] = Point3(-size, size, -size); pts[2] = Point3( size, size, -size); pts[3] = Point3( size, -size, -size); vpt->getGW()->polyline(4, pts, NULL, NULL, TRUE, NULL); // Top pts[0] = Point3(-size, -size, size); pts[1] = Point3(-size, size, size); pts[2] = Point3( size, size, size); pts[3] = Point3( size, -size, size); vpt->getGW()->polyline(4, pts, NULL, NULL, TRUE, NULL); // Sides pts[0] = Point3(-size, -size, -size); pts[1] = Point3(-size, -size, size); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); pts[0] = Point3(-size, size, -size); pts[1] = Point3(-size, size, size); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); pts[0] = Point3( size, size, -size); pts[1] = Point3( size, size, size); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); pts[0] = Point3( size, -size, -size); pts[1] = Point3( size, -size, size); vpt->getGW()->polyline(2, pts, NULL, NULL, FALSE, NULL); } vpt->getGW()->setRndLimits(limits); return 1; }
void Init(CompositeNode* root, MeshFileLoader* MeshLoader ) { // glDisable(GL_CULL_FACE); // glEnable(GL_CULL_FACE); // glCullFace(GL_BACK); // m = mfl->Load("Objects/cube.obj"); // g = new Geometry(m, "Geometry"); // g->SetMesh( m ); Mesh* Magnolia = MeshLoader->Load("Objects/magnolia.obj"); Magnolia->Scale(0.03f); Mesh* Rose = MeshLoader->Load("Objects/rose+vase.obj"); Rose->Scale(0.03f); //Mesh* Dolphins = MeshLoader->Load("Objects/dolphins.obj"); //Dolphins->Scale(0.01f); Mesh* Skyscraper = MeshLoader->Load("Objects/skyscraper.obj"); Skyscraper->Scale(0.04f); M3DVector3f pos; m3dLoadVector3( pos, 0.0f, 0.0f, 50.0f ); if (_camera) DLOG(INFO) << "_camera address: " << _camera << endl; _camera->SetPosition( pos ); Vector4 color( 1.0f, 1.0f, 1.0f, 1.0f ); _light->SetDiffuse( color ); _light->SetAmbient( color ); // M3DVector3f pos; // m3dLoadVector3( pos, 0.0f, 0.0f, 10.0f ); // Init Camera // Camera* c = reinterpret_cast<Camera*>(l->GetByName("GlobalCamera")); // c->SetPosition( pos ); // c->SetPerspective(45.0f,(GLfloat)800/(GLfloat)600,0.1f,100.0f); // Build Up Scenegraph _camera->AddChild( (new Transform(string("MagnoliaTransform")))->AddChild( (new Geometry(Magnolia, string("Magnolia"))) )); _camera->AddChild( (new Transform(string("RoseTransform")))->AddChild( (new Geometry(Rose, "Rose"))) ); _camera->AddChild( (new Transform(string("SkyscraperTransform")))->AddChild( (new Geometry(Skyscraper, "Skyscraper"))) ); Transform* t = dynamic_cast<Transform*>(root->GetByName("MagnoliaTransform")); t->Rotate(20.0f, 1.0f, 1.0f, 1.0f); t->Translate(-3.0f, 0.0f, 0.0f); t = dynamic_cast<Transform*>(root->GetByName("RoseTransform")); t->Translate(2.0f, 0.0f, 0.0f); t->Rotate(20.0f, 1.0f, 1.0f, 1.0f); t->Scale(1.6f, 1.2f, 1.2f); t = dynamic_cast<Transform*>(root->GetByName("SkyscraperTransform")); t->Rotate(50.0f, 1.0f, 1.0f, 1.0f); update = t; UpdateVisitorFactory fact; visitor = fact.CreateTransformationVisitor( ROTATE, 1.0f, 0.0f, 0.0f, 0.01f ); visitor2 = fact.CreateTransformationVisitor( SCALE, 1.002f, 1.0f, 1.0f ); };
void ADFun<Base>::SparseJacobianCase( bool set_type , const VectorBase& x , const VectorSet& p , VectorBase& jac ) { typedef CppAD::vector<size_t> SizeVector; typedef CppAD::vectorBool VectorBool; size_t i, j, k; size_t m = Range(); size_t n = Domain(); // some values const Base zero(0); const Base one(1); // check VectorSet is Simple Vector class with bool elements CheckSimpleVector<bool, VectorSet>(); // check VectorBase is Simple Vector class with Base type elements CheckSimpleVector<Base, VectorBase>(); CPPAD_ASSERT_KNOWN( x.size() == n, "SparseJacobian: size of x not equal domain dimension for f" ); CPPAD_ASSERT_KNOWN( p.size() == m * n, "SparseJacobian: using bool values and size of p " " not equal range dimension times domain dimension for f" ); CPPAD_ASSERT_UNKNOWN(jac.size() == m * n); // point at which we are evaluating the Jacobian Forward(0, x); // initialize the return value for(i = 0; i < m; i++) for(j = 0; j < n; j++) jac[i * n + j] = zero; if( n <= m ) { // use forward mode ---------------------------------------- // initial coloring SizeVector color(n); for(j = 0; j < n; j++) color[j] = j; // See GreedyPartialD2Coloring Algorithm Section 3.6.2 of // Graph Coloring in Optimization Revisited by // Assefaw Gebremedhin, Fredrik Maane, Alex Pothen VectorBool forbidden(n); for(j = 0; j < n; j++) { // initial all colors as ok for this column for(k = 0; k < n; k++) forbidden[k] = false; // for each row that is connected to column j for(i = 0; i < m; i++) if( p[i * n + j] ) { // for each column that is connected to row i for(k = 0; k < n; k++) if( p[i * n + k] & (j != k) ) forbidden[ color[k] ] = true; } k = 0; while( forbidden[k] && k < n ) { k++; CPPAD_ASSERT_UNKNOWN( k < n ); } color[j] = k; } size_t n_color = 1; for(k = 0; k < n; k++) n_color = std::max(n_color, color[k] + 1); // direction vector for calls to forward VectorBase dx(n); // location for return values from Reverse VectorBase dy(m); // loop over colors size_t c; for(c = 0; c < n_color; c++) { // determine all the colums with this color for(j = 0; j < n; j++) { if( color[j] == c ) dx[j] = one; else dx[j] = zero; } // call forward mode for all these columns at once dy = Forward(1, dx); // set the corresponding components of the result for(j = 0; j < n; j++) if( color[j] == c ) { for(i = 0; i < m; i++) if( p[ i * n + j ] ) jac[i * n + j] = dy[i]; } } } else { // use reverse mode ---------------------------------------- // initial coloring SizeVector color(m); for(i = 0; i < m; i++) color[i] = i; // See GreedyPartialD2Coloring Algorithm Section 3.6.2 of // Graph Coloring in Optimization Revisited by // Assefaw Gebremedhin, Fredrik Maane, Alex Pothen VectorBool forbidden(m); for(i = 0; i < m; i++) { // initial all colors as ok for this row for(k = 0; k < m; k++) forbidden[k] = false; // for each column that is connected to row i for(j = 0; j < n; j++) if( p[i * n + j] ) { // for each row that is connected to column j for(k = 0; k < m; k++) if( p[k * n + j] & (i != k) ) forbidden[ color[k] ] = true; } k = 0; while( forbidden[k] && k < m ) { k++; CPPAD_ASSERT_UNKNOWN( k < n ); } color[i] = k; } size_t n_color = 1; for(k = 0; k < m; k++) n_color = std::max(n_color, color[k] + 1); // weight vector for calls to reverse VectorBase w(m); // location for return values from Reverse VectorBase dw(n); // loop over colors size_t c; for(c = 0; c < n_color; c++) { // determine all the rows with this color for(i = 0; i < m; i++) { if( color[i] == c ) w[i] = one; else w[i] = zero; } // call reverse mode for all these rows at once dw = Reverse(1, w); // set the corresponding components of the result for(i = 0; i < m; i++) if( color[i] == c ) { for(j = 0; j < n; j++) if( p[ i * n + j ] ) jac[i * n + j] = dw[j]; } } } }
static void construct(QVariant::Private *x, const void *copy) { switch (x->type) { case QVariant::Bitmap: v_construct<QBitmap>(x, copy); break; case QVariant::Region: v_construct<QRegion>(x, copy); break; case QVariant::Polygon: v_construct<QPolygon>(x, copy); break; case QVariant::Font: v_construct<QFont>(x, copy); break; case QVariant::Pixmap: v_construct<QPixmap>(x, copy); break; case QVariant::Image: v_construct<QImage>(x, copy); break; case QVariant::Brush: v_construct<QBrush>(x, copy); break; case QVariant::Color: v_construct<QColor>(x, copy); break; case QVariant::Palette: v_construct<QPalette>(x, copy); break; #ifdef QT3_SUPPORT case QVariant::ColorGroup: v_construct<QColorGroup>(x, copy); break; #endif #ifndef QT_NO_ICON case QVariant::Icon: v_construct<QIcon>(x, copy); break; #endif case QVariant::Matrix: v_construct<QMatrix>(x, copy); break; case QVariant::Transform: v_construct<QTransform>(x, copy); break; case QVariant::TextFormat: v_construct<QTextFormat>(x, copy); break; case QVariant::TextLength: v_construct<QTextLength>(x, copy); break; #ifndef QT_NO_SHORTCUT case QVariant::KeySequence: v_construct<QKeySequence>(x, copy); break; #endif case QVariant::Pen: v_construct<QPen>(x, copy); break; case QVariant::SizePolicy: v_construct<QSizePolicy>(x, copy); break; #ifndef QT_NO_CURSOR case QVariant::Cursor: v_construct<QCursor>(x, copy); break; #endif case 62: { // small 'trick' to let a QVariant(Qt::blue) create a variant // of type QColor x->type = QVariant::Color; QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy)); v_construct<QColor>(x, &color); break; } #ifndef QT_NO_MATRIX4X4 case QVariant::Matrix4x4: v_construct<QMatrix4x4>(x, copy); break; #endif #ifndef QT_NO_VECTOR2D case QVariant::Vector2D: v_construct<QVector2D>(x, copy); break; #endif #ifndef QT_NO_VECTOR3D case QVariant::Vector3D: v_construct<QVector3D>(x, copy); break; #endif #ifndef QT_NO_VECTOR4D case QVariant::Vector4D: v_construct<QVector4D>(x, copy); break; #endif #ifndef QT_NO_QUATERNION case QVariant::Quaternion: v_construct<QQuaternion>(x, copy); break; #endif default: qcoreVariantHandler()->construct(x, copy); return; } x->is_null = !copy; }
static void createGtkrc( bool exportColors, const QPalette& cg, bool exportGtkTheme, const QString& gtkTheme, int version ) { // lukas: why does it create in ~/.kde/share/config ??? // pfeiffer: so that we don't overwrite the user's gtkrc. // it is found via the GTK_RC_FILES environment variable. QSaveFile saveFile( writableGtkrc(version) ); if ( !saveFile.open(QIODevice::WriteOnly) ) return; QTextStream t ( &saveFile ); t.setCodec( QTextCodec::codecForLocale () ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance -> Colors in the System Settings and disable the checkbox\n" "# \"Apply colors to non-KDE4 applications\"\n" "#\n" "#\n", QDateTime::currentDateTime().toString()); if ( 2==version ) { // we should maybe check for MacOS settings here t << endl; t << "gtk-alternative-button-order = 1" << endl; t << endl; } if (exportGtkTheme) { QString gtkStyle; if (gtkTheme.toLower() == QLatin1String("oxygen")) gtkStyle = QStringLiteral("oxygen-gtk"); else gtkStyle = gtkTheme; bool exist_gtkrc = false; QByteArray gtkrc = getenv(gtkEnvVar(version)); QStringList listGtkrc = QFile::decodeName(gtkrc).split(QStringLiteral(":")); if (listGtkrc.contains(saveFile.fileName())) listGtkrc.removeAll(saveFile.fileName()); listGtkrc.append(QDir::homePath() + userGtkrc(version)); listGtkrc.append(QDir::homePath() + "/.gtkrc-2.0-kde"); listGtkrc.append(QDir::homePath() + "/.gtkrc-2.0-kde4"); listGtkrc.removeAll(QLatin1String("")); listGtkrc.removeDuplicates(); for (int i = 0; i < listGtkrc.size(); ++i) { if ((exist_gtkrc = QFile::exists(listGtkrc.at(i)))) break; } if (!exist_gtkrc) { QString gtk2ThemeFilename; gtk2ThemeFilename = QStringLiteral("%1/.themes/%2/gtk-2.0/gtkrc").arg(QDir::homePath()).arg(gtkStyle); if (!QFile::exists(gtk2ThemeFilename)) { QStringList gtk2ThemePath; gtk2ThemeFilename.clear(); QByteArray xdgDataDirs = getenv("XDG_DATA_DIRS"); gtk2ThemePath.append(QDir::homePath() + "/.local"); gtk2ThemePath.append(QFile::decodeName(xdgDataDirs).split(QStringLiteral(":"))); gtk2ThemePath.removeDuplicates(); for (int i = 0; i < gtk2ThemePath.size(); ++i) { gtk2ThemeFilename = QStringLiteral("%1/themes/%2/gtk-2.0/gtkrc").arg(gtk2ThemePath.at(i)).arg(gtkStyle); if (QFile::exists(gtk2ThemeFilename)) break; else gtk2ThemeFilename.clear(); } } if (!gtk2ThemeFilename.isEmpty()) { t << "include \"" << gtk2ThemeFilename << "\"" << endl; t << endl; t << "gtk-theme-name=\"" << gtkStyle << "\"" << endl; t << endl; if (gtkStyle == QLatin1String("oxygen-gtk")) exportColors = false; } } } if (exportColors) { t << "style \"default\"" << endl; t << "{" << endl; t << " bg[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl; t << " bg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; t << " bg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl; t << " bg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl; t << " bg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Base ) ) << endl; t << " base[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; t << " base[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl; t << " base[ACTIVE] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; t << " base[PRELIGHT] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.color(QPalette::Active, QPalette::Text) ) << endl; t << " text[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; t << " text[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl; t << " text[ACTIVE] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; t << " text[PRELIGHT] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; t << endl; t << " fg[NORMAL] = " << color ( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl; t << " fg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::HighlightedText) ) << endl; t << " fg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl; t << " fg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl; t << " fg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl; t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; // tooltips don't have the standard background color t << "style \"ToolTip\"" << endl; t << "{" << endl; QPalette group = QToolTip::palette(); t << " bg[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Background ) ) << endl; t << " base[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Base ) ) << endl; t << " text[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Text ) ) << endl; t << " fg[NORMAL] = " << color( group.color( QPalette::Active, QPalette::Foreground ) ) << endl; t << "}" << endl; t << endl; t << "widget \"gtk-tooltip\" style \"ToolTip\"" << endl; t << "widget \"gtk-tooltips\" style \"ToolTip\"" << endl; t << endl; // highlight the current (mouse-hovered) menu-item // not every button, checkbox, etc. t << "style \"MenuItem\"" << endl; t << "{" << endl; t << " bg[PRELIGHT] = " << color( cg.color(QPalette::Highlight) ) << endl; t << " fg[PRELIGHT] = " << color( cg.color(QPalette::HighlightedText) ) << endl; t << "}" << endl; t << endl; t << "class \"*MenuItem\" style \"MenuItem\"" << endl; t << endl; } saveFile.commit(); }
PreviewBox(int x, int y, int w, int h) : Fl_Widget(x,y,w,h,0) { color(FL_WHITE); }
static void wt_status_print_change_data(struct wt_status *s, int change_type, struct string_list_item *it) { struct wt_status_change_data *d = it->util; const char *c = color(change_type, s); int status = 0; char *one_name; char *two_name; const char *one, *two; struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT; struct strbuf extra = STRBUF_INIT; one_name = two_name = it->string; switch (change_type) { case WT_STATUS_UPDATED: status = d->index_status; if (d->head_path) one_name = d->head_path; break; case WT_STATUS_CHANGED: if (d->new_submodule_commits || d->dirty_submodule) { strbuf_addstr(&extra, " ("); if (d->new_submodule_commits) strbuf_addf(&extra, _("new commits, ")); if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED) strbuf_addf(&extra, _("modified content, ")); if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED) strbuf_addf(&extra, _("untracked content, ")); strbuf_setlen(&extra, extra.len - 2); strbuf_addch(&extra, ')'); } status = d->worktree_status; break; } one = quote_path(one_name, -1, &onebuf, s->prefix); two = quote_path(two_name, -1, &twobuf, s->prefix); status_printf(s, color(WT_STATUS_HEADER, s), "\t"); switch (status) { case DIFF_STATUS_ADDED: status_printf_more(s, c, _("new file: %s"), one); break; case DIFF_STATUS_COPIED: status_printf_more(s, c, _("copied: %s -> %s"), one, two); break; case DIFF_STATUS_DELETED: status_printf_more(s, c, _("deleted: %s"), one); break; case DIFF_STATUS_MODIFIED: status_printf_more(s, c, _("modified: %s"), one); break; case DIFF_STATUS_RENAMED: status_printf_more(s, c, _("renamed: %s -> %s"), one, two); break; case DIFF_STATUS_TYPE_CHANGED: status_printf_more(s, c, _("typechange: %s"), one); break; case DIFF_STATUS_UNKNOWN: status_printf_more(s, c, _("unknown: %s"), one); break; case DIFF_STATUS_UNMERGED: status_printf_more(s, c, _("unmerged: %s"), one); break; default: die(_("bug: unhandled diff status %c"), status); } if (extra.len) { status_printf_more(s, color(WT_STATUS_HEADER, s), "%s", extra.buf); strbuf_release(&extra); } status_printf_more(s, GIT_COLOR_NORMAL, "\n"); strbuf_release(&onebuf); strbuf_release(&twobuf); }
void printLabel(std::ostream& os, const Block* block) { os << color(ANSI_COLOR_MAGENTA); os << "L" << block->getId(); if (block->getHint() == Block::Unlikely) os << "<Unlikely>"; os << color(ANSI_COLOR_END); }
void Clef::layout() { // determine current number of lines and line distance int lines = 5; // assume resonable defaults qreal lineDist = 1.0; Staff* stf = staff(); StaffType* staffType = nullptr; Segment* clefSeg = static_cast<Segment*>(parent()); // check clef visibility and type compatibility if (clefSeg && stf && stf->staffType()) { bool bHide; // check staff type allows clef display staffType = staff()->staffType(); #if 0 // <<<<<<< HEAD if (!staffType->genClef()) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } // tablatures: if (staffType->group() == StaffGroup::TAB) { // if current clef type not compatible with tablature, // set tab clef according to score style if (ClefInfo::staffGroup(clefType()) != StaffGroup::TAB) setClefType( ClefType(score()->styleI(StyleIdx::tabClef)) ); #else bHide = !staffType->genClef(); // check clef is compatible with staff type group int tick = clefSeg->tick(); if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it bHide = true; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = stf->clefTypeList(0); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // // courtesy clef // bool showClef = true; #if 0 // <<<<<<< HEAD Segment* clefSeg = static_cast<Segment*>(parent()); if (clefSeg) { int tick = clefSeg->tick(); // only if there is a clef change if (stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); if (!showClef) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } #else // only if there is a clef change if (!bHide && tick > 0 && stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); bHide |= !showClef; } // if clef not to show or not compatible with staff group if (bHide) { qDeleteAll(elements); // set empty bbox and do nothing elements.clear(); setbbox(QRectF()); return; } lines = staffType->lines(); // init values from staff type lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing //DEBUG if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) // return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); } //--------------------------------------------------------- // layout1 //--------------------------------------------------------- void Clef::layout1() { qreal smag = mag(); qreal _spatium = spatium(); // qreal msp = score()->spatium() * smag; qreal yoff = 0.0; qDeleteAll(elements); elements.clear(); Symbol* symbol = new Symbol(score()); switch (curClefType) { case ClefType::G: // G clef on 2nd line symbol->setSym(SymId::gClef); yoff = 3.0 * curLineDist; break; case ClefType::G1: // G clef 8va on 2nd line symbol->setSym(SymId::gClef8va); yoff = 3.0 * curLineDist; break; case ClefType::G2: // G clef 15ma on 2nd line symbol->setSym(SymId::gClef15ma); yoff = 3.0 * curLineDist; break; case ClefType::G3: // G clef 8vb on 2nd line symbol->setSym(SymId::gClef8vb); yoff = 3.0 * curLineDist; break; case ClefType::F: // F clef on penultimate line symbol->setSym(SymId::fClef); yoff = 1.0 * curLineDist; break; case ClefType::F8: // F clef 8va bassa on penultimate line symbol->setSym(SymId::fClef8vb); yoff = 1.0 * curLineDist; break; case ClefType::F15: // F clef 15ma bassa on penultimate line symbol->setSym(SymId::fClef15mb); yoff = 1.0 * curLineDist; break; case ClefType::F_B: // baritone clef symbol->setSym(SymId::fClef); yoff = 2.0 * curLineDist; break; case ClefType::F_C: // subbass clef symbol->setSym(SymId::fClef); yoff = 0.0; break; case ClefType::C1: // C clef in 1st line symbol->setSym(SymId::cClef); yoff = 4.0 * curLineDist; break; case ClefType::C2: // C clef on 2nd line symbol->setSym(SymId::cClef); yoff = 3.0 * curLineDist; break; case ClefType::C3: // C clef in 3rd line symbol->setSym(SymId::cClef); yoff = 2.0 * curLineDist; break; case ClefType::C4: // C clef on 4th line symbol->setSym(SymId::cClef); yoff = 1.0 * curLineDist; break; case ClefType::C5: // C clef on 5th line symbol->setSym(SymId::cClef); yoff = 0.0; break; case ClefType::TAB: // TAB clef symbol->setSym(SymId::sixStringTabClef); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::TAB2: // TAB clef alternate style symbol->setSym(SymId::sixStringTabClefSerif); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::PERC: // percussion clefs case ClefType::PERC2: // no longer supported: fall back to same glyph as PERC symbol->setSym(SymId::unpitchedPercussionClef1); yoff = curLineDist * (curLines - 1) * 0.5; break; case ClefType::G4: // G clef in 1st line symbol->setSym(SymId::gClef); yoff = 4.0 * curLineDist; break; case ClefType::F_8VA: // F clef 8va on penultimate line symbol->setSym(SymId::fClef8va); yoff = 1.0 * curLineDist; break; case ClefType::F_15MA: // F clef 15ma on penultimate line symbol->setSym(SymId::fClef15ma); yoff = 1.0 * curLineDist; break; case ClefType::INVALID: case ClefType::MAX: return; } symbol->setMag(smag); symbol->layout(); addElement(symbol, .0, yoff * _spatium); setbbox(QRectF()); for (auto i = elements.begin(); i != elements.end(); ++i) { Element* e = *i; e->setColor(curColor()); addbbox(e->bbox().translated(e->pos())); e->setSelected(selected()); } } //--------------------------------------------------------- // draw //--------------------------------------------------------- void Clef::draw(QPainter* painter) const { if (staff() && !staff()->staffType()->genClef()) return; QColor color(curColor()); foreach(Element* e, elements) { e->setColor(color); QPointF pt(e->pos()); painter->translate(pt); e->draw(painter); painter->translate(-pt); } }
void LabelColor::applyFormattedString(const std::string& str, Label* label) { LabelColor color(str); label->setString(color.getRawString()); color.applyColor(label); }
//! constructor CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) : IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true) { #ifdef _DEBUG setDebugName("CGUIWindow"); #endif IGUISkin* skin = 0; if (environment) skin = environment->getSkin(); IGUISpriteBank* sprites = 0; video::SColor color(255,255,255,255); s32 buttonw = 15; if (skin) { buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); sprites = skin->getSpriteBank(); color = skin->getColor(EGDC_WINDOW_SYMBOL); } s32 posx = RelativeRect.getWidth() - buttonw - 4; CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); CloseButton->setSubElement(true); CloseButton->setTabStop(false); CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); if (sprites) { CloseButton->setSpriteBank(sprites); CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); } posx -= buttonw + 2; RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" ); RestoreButton->setVisible(false); RestoreButton->setSubElement(true); RestoreButton->setTabStop(false); RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); if (sprites) { RestoreButton->setSpriteBank(sprites); RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), color); RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), color); } posx -= buttonw + 2; MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" ); MinButton->setVisible(false); MinButton->setSubElement(true); MinButton->setTabStop(false); MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); if (sprites) { MinButton->setSpriteBank(sprites); MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), color); } MinButton->grab(); RestoreButton->grab(); CloseButton->grab(); // this element is a tab group setTabGroup(true); setTabStop(true); setTabOrder(-1); }
static void area_tests(struct test *t, int reps, int sets, enum target target) { struct test_target tt; XImage image; uint32_t *cells = calloc(sizeof(uint32_t), t->real.width*t->real.height); int r, s, x, y; printf("Testing area sets (%s): ", test_target_name(target)); fflush(stdout); test_target_create_render(&t->real, target, &tt); clear(&t->real, &tt); test_init_image(&image, &t->real.shm, tt.format, tt.width, tt.height); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { int w = rand() % tt.width; int h = rand() % tt.height; int red = rand() % 0xff; int green = rand() % 0xff; int blue = rand() % 0xff; int alpha = rand() % 0xff; x = rand() % (2*tt.width) - tt.width; y = rand() % (2*tt.height) - tt.height; fill_rect(&t->real, tt.picture, PictOpSrc, x, y, w, h, 0, 0, MASK_NONE, red, green, blue, alpha); if (x < 0) w += x, x = 0; if (y < 0) h += y, y = 0; if (x >= tt.width || y >= tt.height) continue; if (x + w > tt.width) w = tt.width - x; if (y + h > tt.height) h = tt.height - y; if (w <= 0 || h <= 0) continue; pixman_fill(cells, tt.width, 32, x, y, w, h, color(red, green, blue, alpha)); } XShmGetImage(t->real.dpy, tt.draw, &image, 0, 0, AllPlanes); for (y = 0; y < tt.height; y++) { for (x = 0; x < tt.width; x++) { uint32_t result = *(uint32_t *)(image.data + y*image.bytes_per_line + image.bits_per_pixel*x/8); if (!pixel_equal(image.depth, result, cells[y*tt.width+x])) { uint32_t mask = depth_mask(image.depth); die("failed to set pixel (%d,%d) to %08x [%08x], found %08x [%08x] instead\n", x, y, cells[y*tt.width+x] & mask, cells[y*tt.width+x], result & mask, result); } } } } printf("passed [%d iterations x %d]\n", reps, sets); test_target_destroy_render(&t->real, &tt); free(cells); }
void ActivityActionCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QRect r = rect(); QBrush brsh = p.brush(); QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); p.setBackgroundColor(co); const ActivityActionData * data = (ActivityActionData *) browser_node->get_data(); const int shadow = the_canvas()->shadow(); int margin; FILE * fp = svg(); if (fp != 0) fputs("<g>\n", fp); switch (data->get_action_kind()) { case UmlAcceptEventAction: if (((AcceptEventAction *) data->get_action())->timeevent) { // don't draw shadow margin = (int) (21 * the_canvas()->zoom()); int t = (r.y() + r.bottom() - margin)/2; p.setPen(::Qt::SolidLine); p.setBackgroundMode(::Qt::TransparentMode); p.drawLine(r.right() - margin, t, r.right() - 1, t); //p.lineTo(r.right() - margin - 1, t + margin); p.drawLine( r.right() - 1, t, r.right() - margin - 1, t + margin); //p.lineTo(r.right() - 1, t + margin); p.drawLine(r.right() - margin - 1, t + margin, r.right() - 1, t + margin); //p.lineTo(r.right() - margin - 1, t); p.drawLine(r.right() - 1, t + margin, r.right() - margin - 1, t); if (fp != 0) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.right() - margin, t, r.right() - 1, t); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.right() - 1, t, r.right() - margin - 1, t + margin); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.right() - margin - 1, t + margin, r.right() - 1, t + margin); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.right() - 1, t + margin, r.right() - margin - 1, t); } r.setWidth(r.width() - margin - 1); margin = (int) (3 * the_canvas()->zoom()); } else { if ((used_color != UmlTransparent) && (shadow != 0)) { r.setRight(r.right() - shadow); r.setBottom(r.bottom() - shadow); } margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4; Q3PointArray a(6); a.setPoint(0, r.x(), r.y()); a.setPoint(1, r.right(), r.y()); a.setPoint(2, r.right(), r.bottom()); a.setPoint(3, r.x(), r.bottom()); a.setPoint(4, r.x() + margin, (r.y() + r.bottom())/2); a.setPoint(5, r.x(), r.y()); if (used_color == UmlTransparent) { p.drawPolyline(a); if (fp != 0) draw_poly(fp, a, UmlTransparent); } else { if (shadow != 0) { Q3PointArray b(6); b.setPoint(0, r.x() + shadow, r.y() + shadow); b.setPoint(1, r.right() + shadow, r.y() + shadow); b.setPoint(2, r.right() + shadow, r.bottom() + shadow); b.setPoint(3, r.x() + shadow, r.bottom() + shadow); b.setPoint(4, r.x() + margin + shadow, (r.y() + r.bottom())/2 + shadow); b.setPoint(5, r.x() + shadow, r.y() + shadow); p.setBrush(::Qt::darkGray); p.setPen(::Qt::NoPen); p.drawPolygon(b, TRUE, 0, 5); p.setPen(::Qt::SolidLine); if (fp != 0) draw_shadow(fp, b); } p.setBrush(co); p.drawPolygon(a, TRUE, 0, 5); if (fp != 0) draw_poly(fp, a, used_color); } r.setLeft(r.left() + margin); margin = (int) (6 * the_canvas()->zoom()); } break; case UmlSendSignalAction: case UmlBroadcastSignalAction: { if ((used_color != UmlTransparent) && (shadow != 0)) { r.setRight(r.right() - shadow); r.setBottom(r.bottom() - shadow); } margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4; Q3PointArray a(6); a.setPoint(0, r.x(), r.y()); a.setPoint(1, r.right() - margin, r.y()); a.setPoint(2, r.right(), (r.y() + r.bottom())/2); a.setPoint(3, r.right() - margin, r.bottom()); a.setPoint(4, r.x(), r.bottom()); a.setPoint(5, r.x(), r.y()); if (used_color == UmlTransparent) { p.drawPolyline(a); if (fp != 0) draw_poly(fp, a, UmlTransparent); } else { if (shadow != 0) { Q3PointArray b(6); b.setPoint(0, r.x() + shadow, r.y() + shadow); b.setPoint(1, r.right() - margin + shadow, r.y() + shadow); b.setPoint(2, r.right() + shadow, (r.y() + r.bottom())/2 + shadow); b.setPoint(3, r.right() - margin + shadow, r.bottom() + shadow); b.setPoint(4, r.x() + shadow, r.bottom() + shadow); b.setPoint(5, r.x() + shadow, r.y() + shadow); p.setBrush(::Qt::darkGray); p.setPen(::Qt::NoPen); p.drawPolygon(b, TRUE, 0, 5); p.setPen(::Qt::SolidLine); if (fp != 0) draw_shadow(fp, b); } p.setBrush(co); p.drawPolygon(a, TRUE, 0, 5); if (fp != 0) draw_poly(fp, a, used_color); } r.setWidth(r.width() - margin); margin = (int) (6 * the_canvas()->zoom()); } break; default: margin = (int) (9 * the_canvas()->zoom()); if ((used_color != UmlTransparent) && (shadow != 0)) { r.setRight(r.right() - shadow); r.setBottom(r.bottom() - shadow); p.setPen(::Qt::NoPen); p.setBrush(::Qt::darkGray); p.drawRoundRect(r.left() + shadow, r.top() + shadow, r.width(), r.height()); if (fp != 0) fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n", QColor(::Qt::darkGray).rgb()&0xffffff, r.left() + shadow, r.top() + shadow, r.width() - 1, r.height() - 1); p.setPen(::Qt::SolidLine); } p.setBrush(co); p.drawRoundRect(r); if (fp != 0) fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n", svg_color(used_color), r.left(), r.top(), r.width() - 1, r.height() - 1); if (data->get_action_kind() == UmlCallBehaviorAction) { BrowserNode * behavior = ((CallBehaviorAction *) data->get_action())->behavior; if ((behavior != 0) && (behavior->get_type() == UmlActivity)) { int l = (int) (6 * the_canvas()->zoom()); int lx = r.right() - margin - l; int ty = r.bottom() - margin - l; int mx = lx + l; int my = ty + l; int rx = mx + l; int by = my + l; p.drawLine(lx, my, rx, my); p.drawLine(mx, ty, mx, by); p.drawLine(lx, my, lx, by); p.drawLine(rx, my, rx, by); if (fp != 0) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", lx, my, rx, my); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", mx, ty, mx, by); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", lx, my, lx, by); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", rx, my, rx, by); } } } break; } p.setFont(the_canvas()->get_font(UmlNormalFont)); p.drawText(r.x() + margin, r.y() + margin, r.width() - margin - margin, r.height() - margin - margin, align, s); if (fp != 0) { fputs("</g>\n", fp); draw_text(r.x() + margin, r.y() + margin, r.width() - margin - margin, r.height() - margin - margin, align, s, p.font(), fp); } p.setBackgroundColor(bckgrnd); p.setBrush(brsh); if (selected()) show_mark(p, rect()); }
String CSSPrimitiveValue::cssText() const { // FIXME: return the original value instead of a generated one (e.g. color // name if it was specified) - check what spec says about this String text; switch (m_type) { case CSS_UNKNOWN: // FIXME break; case CSS_NUMBER: case CSS_PARSER_INTEGER: text = String::number(m_value.num); break; case CSS_PERCENTAGE: text = String::format("%.6lg%%", m_value.num); break; case CSS_EMS: text = String::format("%.6lgem", m_value.num); break; case CSS_EXS: text = String::format("%.6lgex", m_value.num); break; case CSS_PX: text = String::format("%.6lgpx", m_value.num); break; case CSS_CM: text = String::format("%.6lgcm", m_value.num); break; case CSS_MM: text = String::format("%.6lgmm", m_value.num); break; case CSS_IN: text = String::format("%.6lgin", m_value.num); break; case CSS_PT: text = String::format("%.6lgpt", m_value.num); break; case CSS_PC: text = String::format("%.6lgpc", m_value.num); break; case CSS_DEG: text = String::format("%.6lgdeg", m_value.num); break; case CSS_RAD: text = String::format("%.6lgrad", m_value.num); break; case CSS_GRAD: text = String::format("%.6lggrad", m_value.num); break; case CSS_MS: text = String::format("%.6lgms", m_value.num); break; case CSS_S: text = String::format("%.6lgs", m_value.num); break; case CSS_HZ: text = String::format("%.6lghz", m_value.num); break; case CSS_KHZ: text = String::format("%.6lgkhz", m_value.num); break; case CSS_DIMENSION: // FIXME break; case CSS_STRING: text = quoteStringIfNeeded(m_value.string); break; case CSS_URI: text = "url(" + quoteURLIfNeeded(m_value.string) + ")"; break; case CSS_IDENT: text = valueOrPropertyName(m_value.ident); break; case CSS_ATTR: // FIXME break; case CSS_COUNTER: text = "counter("; text += String::number(m_value.num); text += ")"; // FIXME: Add list-style and separator break; case CSS_RECT: { Rect* rectVal = getRectValue(); text = "rect("; text += rectVal->top()->cssText() + " "; text += rectVal->right()->cssText() + " "; text += rectVal->bottom()->cssText() + " "; text += rectVal->left()->cssText() + ")"; break; } case CSS_RGBCOLOR: { Color color(m_value.rgbcolor); text = (color.alpha() < 0xFF) ? "rgba(" : "rgb("; text += String::number(color.red()) + ", "; text += String::number(color.green()) + ", "; text += String::number(color.blue()); if (color.alpha() < 0xFF) text += ", " + String::number(static_cast<float>(color.alpha()) / 0xFF); text += ")"; break; } case CSS_PAIR: text = m_value.pair->first()->cssText(); text += " "; text += m_value.pair->second()->cssText(); break; #if ENABLE(DASHBOARD_SUPPORT) case CSS_DASHBOARD_REGION: for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) { if (!text.isEmpty()) text.append(' '); text += "dashboard-region("; text += region->m_label; if (region->m_isCircle) text += " circle"; else if (region->m_isRectangle) text += " rectangle"; else break; if (region->top()->m_type == CSS_IDENT && region->top()->getIdent() == CSSValueInvalid) { ASSERT(region->right()->m_type == CSS_IDENT); ASSERT(region->bottom()->m_type == CSS_IDENT); ASSERT(region->left()->m_type == CSS_IDENT); ASSERT(region->right()->getIdent() == CSSValueInvalid); ASSERT(region->bottom()->getIdent() == CSSValueInvalid); ASSERT(region->left()->getIdent() == CSSValueInvalid); } else { text.append(' '); text += region->top()->cssText() + " "; text += region->right()->cssText() + " "; text += region->bottom()->cssText() + " "; text += region->left()->cssText(); } text += ")"; } break; #endif case CSS_PARSER_VARIABLE: text = "-webkit-var("; text += m_value.string; text += ")"; break; case CSS_PARSER_OPERATOR: char c = static_cast<char>(m_value.ident); text = String(&c, 1U); break; } return text; }