Exemplo n.º 1
0
void ItemView::drawReminderIcon(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
    cr->save();

    //draw reminder icon
    cr->set_antialias(Cairo::ANTIALIAS_NONE);

    if (data.isReminder())
    {
        Gtk::Image* image = Resources::res->imgReminderIcon;

        if (getColorMode() == COLOR_ALARM)
            image = Resources::res->imgReminderOnIcon;

        const Glib::RefPtr<Gdk::Pixbuf> icon = image->get_pixbuf();

        const int iconLeft = (TIME_WIDTH * 0.5) - (icon->get_width() * 0.5);
        const int iconTop = (height - icon->get_height()) - (PADDING * 3);

        Gdk::Cairo::set_source_pixbuf(cr, icon, iconLeft, iconTop);

        cr->rectangle(iconLeft, iconTop, icon->get_width(), icon->get_height());
        cr->fill();
    }

    cr->restore();
}
Exemplo n.º 2
0
		std::string ContextGen::printable(const SourceMap& val)
		{
			Color col(getColorMode());
			std::string ret;

			if(val.empty())
				return "(empty map)";
			else
				ret = "(map)";

			for(SourceMap::const_iterator it = val.begin(); it != val.end(); ++it)
			{
				ret.append("\n   * ");
				switch(it->second)
				{
				case LanguageAsssembler:
					ret.append(col.blue("[ASM] "));
					break;
				case LanguageC:
					ret.append(col.blue("[ C ] "));
					break;
				case LanguageCpp:
					ret.append(col.blue("[C++] "));
					break;
				default:
					throw Exception("disallowed source file type found in %s: %d", it->first.get().c_str(), it->second);
				}
				ret.append(it->first.get());
			}

			return ret;
		}
Exemplo n.º 3
0
		std::string ContextGen::printable(const DefineMap& val)
		{
			std::string res;

			if(val.empty())
				return "(empty map)";
			else {
				res = "(map)";
			}

			Color col(getColorMode());

			for(DefineMap::const_iterator it = val.begin(); it != val.end(); ++it)
			{
				res.append(col.red("\n   * "));
				res.append(col.cyan("<"));
				res.append(it->first);
				if(it->second.empty()) {
					res.append(col.cyan(">"));
				} else {
					res.append(", ");
					res.append(it->second);
					res.append(col.cyan(">"));
				}
			}

			return res;
		}
Exemplo n.º 4
0
GdkPixbuf * newPixbufFromSEXP (SEXP xx, int index) {
  GdkPixbuf * pixbuf;
  int width, height, rowstride, x, y;
  numeric *dx,dr,dg,db;
  unsigned char *dpixbuf,*data;
  int colorMode;
  int *ix,*idata;
  int redstride=-1,greenstride=-1,bluestride=-1;

  width=INTEGER(GET_DIM(xx))[0];
  height=INTEGER(GET_DIM(xx))[1];
   
  colorMode=getColorMode(xx);

  pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
  rowstride = gdk_pixbuf_get_rowstride (pixbuf);
  dpixbuf=(unsigned char *)gdk_pixbuf_get_pixels(pixbuf);

  // TrueColor
  if (colorMode==MODE_TRUECOLOR) {
    ix=INTEGER(xx);
    for (y=0;y<height;y++) {
      idata=(int *)(dpixbuf+y*rowstride);
      for (x=0;x<width;x++) {
	*idata=ix[x+y*width+index*width*height] | 0xff000000;
	idata++;
      }
    }
  } else {
    dx=REAL(xx);
    
    getColorStrides(xx,index,&redstride,&greenstride,&bluestride);

    for (y=0;y<height;y++) {
      data=dpixbuf+y*rowstride;
      for (x=0;x<width;x++) {
	if (redstride!=-1) dr=256*dx[x+y*width+redstride];	
	else dr=0;
	if (greenstride!=-1) dg=256*dx[x+y*width+greenstride];	
	else dg=0;
	if (bluestride!=-1) db=256*dx[x+y*width+bluestride];
	else db=0;
	if (dr<0.0) dr=0.0;
	if (dr>255.0) dr=255.0;
	if (dg<0.0) dg=0.0;
	if (dg>255.0) dg=255.0;
	if (db<0.0) db=0.0;
	if (db>255.0) db=255.0;
	*data++=(unsigned char)dr;   // R
	*data++=(unsigned char)dg;   // G
	*data++=(unsigned char)db;   // B
	*data++=255;                 // A
      }
    }
  } 
    
  return pixbuf;
}
Exemplo n.º 5
0
int caTable::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTableWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPVS(); break;
        case 1: *reinterpret_cast< QString*>(_v) = getColumnSizes(); break;
        case 2: *reinterpret_cast< colMode*>(_v) = getColorMode(); break;
        case 3: *reinterpret_cast< int*>(_v) = getPrecision(); break;
        case 4: *reinterpret_cast< SourceMode*>(_v) = getPrecisionMode(); break;
        case 5: *reinterpret_cast< SourceMode*>(_v) = getLimitsMode(); break;
        case 6: *reinterpret_cast< double*>(_v) = getMaxValue(); break;
        case 7: *reinterpret_cast< double*>(_v) = getMinValue(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPVS(*reinterpret_cast< QString*>(_v)); break;
        case 1: setColumnSizes(*reinterpret_cast< QString*>(_v)); break;
        case 2: setColorMode(*reinterpret_cast< colMode*>(_v)); break;
        case 3: setPrecision(*reinterpret_cast< int*>(_v)); break;
        case 4: setPrecisionMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 5: setLimitsMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 6: setMaxValue(*reinterpret_cast< double*>(_v)); break;
        case 7: setMinValue(*reinterpret_cast< double*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 6
0
void ItemView::drawBackground(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
    //fill background
    if (isSelected())
    {
        cr->set_source_rgb(1, 1, 1);
        cr->rectangle(0, 0, width, height);
        cr->fill();
    }
    else
    {
        cr->set_source_rgb(0.98, 0.98, 0.98);
        cr->rectangle(0, 0, width, height);
        cr->fill();
    }

    //time area
    Cairo::RefPtr<Cairo::LinearGradient> linearGradientTime = Cairo::LinearGradient::create(0, 0, 0, height);

    //set color by status
    ColorMode colorMode = getColorMode();

    if (colorMode == COLOR_INACTIVE)
    {
        //gray
        linearGradientTime->add_color_stop_rgb(0, 0.75, 0.75, 0.75);
        linearGradientTime->add_color_stop_rgb(1, 0.65, 0.65, 0.65);
    }

    if (colorMode == COLOR_ALARM)
    {
        //orange
        linearGradientTime->add_color_stop_rgb(0, 1.00, 0.60, 0.30);
        linearGradientTime->add_color_stop_rgb(1, 0.90, 0.50, 0.20);
    }

    if (colorMode == COLOR_OK)
    {
        //green
        linearGradientTime->add_color_stop_rgb(0, 0.40, 0.70, 0.45);
        linearGradientTime->add_color_stop_rgb(1, 0.30, 0.60, 0.35);
    }

    cr->set_source(linearGradientTime);
    cr->rectangle(0, 0, TIME_WIDTH, height);
    cr->fill();

    if (isSelected())
        drawInnerShadow(cr, width, height);
}
Exemplo n.º 7
0
int caClock::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QwtAnalogClock::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPV(); break;
        case 1: *reinterpret_cast< timeType*>(_v) = getTimeType(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = getBaseColor(); break;
        case 3: *reinterpret_cast< bool*>(_v) = getScaleDefaultColor(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = getScaleColor(); break;
        case 5: *reinterpret_cast< colMode*>(_v) = getColorMode(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPV(*reinterpret_cast< QString*>(_v)); break;
        case 1: setTimeType(*reinterpret_cast< timeType*>(_v)); break;
        case 2: setBaseColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setScaleDefaultColor(*reinterpret_cast< bool*>(_v)); break;
        case 4: setScaleColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setColorMode(*reinterpret_cast< colMode*>(_v)); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 6;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 8
0
void ItemView::drawTime(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
    int text_width;
    int text_height;

    Glib::RefPtr<Pango::Layout> layTime = Pango::Layout::create(cr);
    layTime->set_font_description(fontTime);
    layTime->set_text(data.getTimeText());
    layTime->get_pixel_size(text_width, text_height);

    rectTime.set_x((TIME_WIDTH * 0.5) - (text_width * 0.5));
    rectTime.set_y((int)PADDING);
    rectTime.set_width(text_width);
    rectTime.set_height(text_height);

    //highlight
    const int highlightSize = 1;

    cr->move_to(rectTime.get_x(), rectTime.get_y() - highlightSize);

    //set colors
    ColorMode colorMode = getColorMode();

    if (colorMode == COLOR_INACTIVE)
    {
        //gray
        cr->set_source_rgb(0.6, 0.6, 0.6);
    }

    if (colorMode == COLOR_ALARM)
    {
        //orange
        cr->set_source_rgb(0.8, 0.40, 0.0);
    }

    if (colorMode == COLOR_OK)
    {
        //green
        cr->set_source_rgb(0.0, 0.55, 0.0);
    }

    layTime->show_in_cairo_context(cr);

    //inner color
    cr->move_to(rectTime.get_x(), rectTime.get_y());
    cr->set_source_rgb(1.0, 1.0, 1.0);
    layTime->show_in_cairo_context(cr);
}
Exemplo n.º 9
0
static int vcfHapClusterTotalHeight(struct track *tg, enum trackVisibility vis)
/* Return height of haplotype graph (2 * #samples * lineHeight);
 * 2 because we're assuming diploid genomes here, no XXY, tetraploid etc. */
{
const struct vcfFile *vcff = tg->extraUiData;
if (vcff->records == NULL)
    return 0;
int ploidy = sameString(chromName, "chrY") ? 1 : 2;
int simpleHeight = ploidy * vcff->genotypeCount * tg->lineHeight;
int defaultHeight = min(simpleHeight, VCF_DEFAULT_HAP_HEIGHT);
char *tdbHeight = trackDbSettingOrDefault(tg->tdb, VCF_HAP_HEIGHT_VAR, NULL);
if (isNotEmpty(tdbHeight))
    defaultHeight = atoi(tdbHeight);
int cartHeight = cartOrTdbInt(cart, tg->tdb, VCF_HAP_HEIGHT_VAR, defaultHeight);
if (tg->visibility == tvSquish)
    cartHeight /= 2;
int extraPixel = (getColorMode(tg->tdb) == altOnlyMode) ? 1 : 0;
int totalHeight = cartHeight + CLIP_PAD + 2*extraPixel;
tg->height = min(totalHeight, maximumTrackHeight(tg));
return tg->height;
}
Exemplo n.º 10
0
		std::string ContextGen::printable(const PathVector& val)
		{
			std::string res;

			if(val.empty())
				return "(empty vector)";
			else
				res = "(vector)";

			Color col(getColorMode());

			for(PathVector::const_iterator it = val.begin(); it != val.end(); ++it)
			{
				res.append(col.red("\n   * "));
				if(it->isNative()) res.append(col.yellow("[NATIVE] "));
				else if(it->isForeign()) res.append(col.yellow("[FOREIGN] "));
				else res.append(col.yellow("[NEITHER] ")); // is ok, if windows parity build and unix path with windows backend
				res.append(it->get());
			}

			return res;
		}
Exemplo n.º 11
0
static void vcfHapClusterDraw(struct track *tg, int seqStart, int seqEnd,
			      struct hvGfx *hvg, int xOff, int yOff, int width,
			      MgFont *font, Color color, enum trackVisibility vis)
/* Split samples' chromosomes (haplotypes), cluster them by center-weighted
 * alpha similarity, and draw in the order determined by clustering. */
{
struct vcfFile *vcff = tg->extraUiData;
if (vcff->records == NULL)
    return;
purple = hvGfxFindColorIx(hvg, 0x99, 0x00, 0xcc);
undefYellow = hvGfxFindRgb(hvg, &undefinedYellowColor);
enum hapColorMode colorMode = getColorMode(tg->tdb);
pushWarnHandler(ignoreEm);
struct vcfRecord *rec;
for (rec = vcff->records;  rec != NULL;  rec = rec->next)
    vcfParseGenotypes(rec);
popWarnHandler();
unsigned short gtHapCount = 0;
int nRecords = slCount(vcff->records);
int centerIx = getCenterVariantIx(tg, seqStart, seqEnd, vcff->records);
// Limit the number of variants that we compare, to keep from timing out:
// (really what we should limit is the number of distinct haplo's passed to hacTree!)
// In the meantime, this should at least be a cart var...
int maxVariantsPerSide = 50;
int startIx = max(0, centerIx - maxVariantsPerSide);
int endIx = min(nRecords, centerIx+1 + maxVariantsPerSide);
struct hacTree *ht = NULL;
unsigned short *gtHapOrder = clusterHaps(vcff, centerIx, startIx, endIx, &gtHapCount, &ht);
struct vcfRecord *centerRec = NULL;
int ix;
// Unlike drawing order (last drawn is on top), the first mapBox gets priority,
// so map center variant before drawing & mapping other variants!
for (rec = vcff->records, ix=0;  rec != NULL;  rec = rec->next, ix++)
    {
    if (ix == centerIx)
	{
	centerRec = rec;
	mapBoxForCenterVariant(rec, hvg, tg, xOff, yOff, width);
	break;
	}
    }
for (rec = vcff->records, ix=0;  rec != NULL;  rec = rec->next, ix++)
    {
    boolean isClustered = (ix >= startIx && ix < endIx);
    if (ix != centerIx)
	drawOneRec(rec, gtHapOrder, gtHapCount, tg, hvg, xOff, yOff, width, isClustered, FALSE,
		   colorMode);
    }
// Draw the center rec on top, outlined with black lines, to make sure it is very visible:
drawOneRec(centerRec, gtHapOrder, gtHapCount, tg, hvg, xOff, yOff, width, TRUE, TRUE,
	   colorMode);
// Draw as much of the tree as can fit in the left label area:
int extraPixel = (colorMode == altOnlyMode) ? 1 : 0;
int hapHeight = tg->height- CLIP_PAD - 2*extraPixel;
struct yFromNodeHelper yHelper = {0, NULL, NULL};
initYFromNodeHelper(&yHelper, yOff+extraPixel, hapHeight, gtHapCount, gtHapOrder,
		    vcff->genotypeCount);
struct titleHelper titleHelper = { NULL, 0, 0, 0, 0, NULL, NULL };
initTitleHelper(&titleHelper, tg->track, startIx, centerIx, endIx, nRecords, vcff);
char *treeAngle = cartOrTdbString(cart, tg->tdb, VCF_HAP_TREEANGLE_VAR, VCF_DEFAULT_HAP_TREEANGLE);
boolean drawRectangle = sameString(treeAngle, VCF_HAP_TREEANGLE_RECTANGLE);
drawTreeInLabelArea(ht, hvg, yOff+extraPixel, hapHeight+CLIP_PAD, &yHelper, &titleHelper,
		    drawRectangle);
}