Exemplo n.º 1
0
Arquivo: graph.c Projeto: crcox/lens
Trace createTrace(Graph G, char *object) {
  int t;
  Trace T = (Trace) safeCalloc(1, sizeof *T, "createTrace:T");
  for (t = 0; t < G->numTraces && G->trace[t]; t++);
  if (t >= G->numTraces) {
    int n = imax(t + 2, 2 * G->numTraces);
    G->trace = safeRealloc(G->trace, n * sizeof(Trace), "G->trace");
    memset(G->trace + G->numTraces, 0, (n - G->numTraces) * sizeof(Trace));
    G->numTraces = n;
  }
  G->trace[t] = T;
  T->num = t;

  T->graph = G;
  if (T->num == 0) T->color = copyString("black");
  else T->color = nextColor();
  T->maxVals = DEF_GR_values;
  T->active = TRUE;
  T->transient = FALSE;
  T->visible = TRUE;
  T->val = (point *) safeMalloc(T->maxVals * sizeof(point), "T->val");
  T->object = copyString(object);
  G->tracesChanged = TRUE;
  refreshPropsLater(G);
  return T;
}
Exemplo n.º 2
0
int main( int argc, char **argv )
{
    KApplication a( argc, argv );
    KTopLevelWidget ktw;
    QWidget qw;
    QTimer t_toggle, t_color, t_look;
    //KLed l(KLed::red, &qw);				// create lamp
    //KLed l(KLed::blue, &qw);				// create lamp
    KLed l(KLed::green, &qw);				// create lamp
    //KLed l(KLed::yellow, &qw);				// create lamp
    //KLed l(KLed::orange, &qw);				// create lamp
    l.resize(16,30);
    //l.setLook(KLed::flat);
    l.setLook(KLed::round);
    //l.setLook(KLed::sunken);
    //    l.flat = TRUE;
    ktmp tmpobj(&l);
    
    t_toggle.start(1000, FALSE);
    t_color.start(3500, FALSE);
    t_look.start(10000, FALSE);
    QObject::connect(&t_toggle, SIGNAL(timeout()), &l, SLOT(toggle()));
    QObject::connect(&t_color, SIGNAL(timeout()), &tmpobj, SLOT(nextColor()));
    QObject::connect(&t_look, SIGNAL(timeout()), &tmpobj, SLOT(nextLook()));


    a.setMainWidget( &qw );
    ktw.setView(&qw);
    qw.show();					// show widget
    return a.exec();				// go
}
Exemplo n.º 3
0
void AMTESTCentralWidgetView::onDataModelToBeAdded(const QString &name)
{
	AMTESTDataModel *dataModel = 0;
	QList<AMTESTServerConnection *> serverConnections = AMTESTStripTool::stripTool()->serverConnections();

	for (int i = 0, size = serverConnections.size(); i < size && dataModel == 0; i++)
		dataModel = serverConnections.at(i)->dataModelFromName(name);

	if (dataModel->isSeriesDataModel()){

		MPlotSeriesBasic *series = new MPlotSeriesBasic;
		series->setModel(dataModel->seriesDataModel());
		series->setDescription(dataModel->name());
		series->setMarker(MPlotMarkerShape::None);
		series->setLinePen(QPen(nextColor()));
		plot_->addItem(series);
	}

	else if (dataModel->isImageDataModel()){

		if (!imageDataModelName_.isEmpty())
			onDataModelToBeRemoved(imageDataModelName_);

		imageDataModelName_ = name;
		MPlotImageBasic *image = new MPlotImageBasic;
		image->setModel(dataModel->imageDataModel());
		image->setDescription(dataModel->name());
		image->setColorMap(MPlotColorMap::Jet);
		image->setZValue(-5);
		plot_->addItem(image);
	}
}
Exemplo n.º 4
0
/** Determine the number of colors in a group's menu.
 *  @param grp is a group number
 *  @return the number of colors in grp's menu
 */
int egcolor_menu::menuSize(int grp) const {
	int cnt = 0;
	for (int c = firstColor(grp); c != 0; c = nextColor(grp,c)) {
		cnt++;
	}
	return cnt;
}
Exemplo n.º 5
0
void ColorWidget::wheelEvent(QWheelEvent *event)
{
    if(event->delta() > 0)
        previousColor();
    else
        nextColor();
}
Exemplo n.º 6
0
/** Find and remove the least value color from a group's menu,
 *  updating all data structures.
 *  @param grp is a group number
 *  @return grp's deficit, after the update is complete
 */
int egcolor_menu::swapOut(int grp) {
	// find color of least value in grp's menu
	int c = firstColor(grp);
	if (c == 0) return 0;
	int cval = value(c,grp);
	for (int cc = firstColor(grp); cc != 0; cc = nextColor(grp,cc)) {
		int ccval = value(cc,grp);
		if (ccval < cval) { c = cc; cval = ccval; }
	}
	return shrinkMenu(grp, c);
}
Exemplo n.º 7
0
void physics(void)
{
    if((ball1.new_ycenter - ball1.radius) <= 1){
        ball1.speedy = -ball1.speedy; // Reflect From Top
        nextColor();
    }
    if(ball1.new_ycenter + ball1.radius >= ySize -1){
        ball1.speedy = -ball1.speedy; // Reflect From Bottom
        nextColor();
    }
    if(ball1.new_xcenter - ball1.radius < 1){
        ball1.speedx = - ball1.speedx;
        nextColor();
        return;
    }
    if(ball1.new_xcenter +  ball1.radius >= xSize -1){
        ball1.speedx = - ball1.speedx;
        nextColor();
        return;
    }
}
Exemplo n.º 8
0
// START OF RANDOMCIRCLECURSOR
CursorCircle RandomCircleCursor::addCircle(){
	int angle = rand() % 360;

	double distanceToNew = 3 * r / 2 / (rand() % 5 + 1);
	double newR = r / (rand() % 4 + 2);

	auto pt = jump({ x, y }, distanceToNew, angle);

	Color color = nextColor();

	return{ pt.first, pt.second, newR, color, { x, y }, (double)(rand() % 1000 + 500), distanceToNew, angle };
}
Exemplo n.º 9
0
void ColorWidget::mousePressEvent(QMouseEvent * event)
{
    switch(event->button())
    {
        case Qt::LeftButton:
            nextColor();
            break;
        case Qt::RightButton:
            previousColor();
            break;
        default:;
    }
}
Exemplo n.º 10
0
/*******************************************************************************
 * Parser Definitions
 ******************************************************************************/
bool KAbstractHdrParserPrivate::parse()
{
  // Initialize lexer
  nextChar();
  if(!readExpect("#?RADIANCE\n"))
  {
    qFatal("No #?RADIANCE header, the file may be corrupt or invalid.");
    return false;
  }
  forceValidate();
  nextToken();

  // Read the Key/Value pairs
  for (;;)
  {
    if (peekToken() == PT_ENDOFHEADER) break;
    switch (nextToken())
    {
    case PT_ERROR:
      qFatal("Encountered an error! Aborting");
      return false;
    case PT_EOF:
      return true;
    case PT_KEYVALUE:
      m_parser->onKeyValue(m_key.c_str(), m_value.c_str());
    case PT_ENDOFHEADER:
      break;
    }
  }

  // Read the data
  parseDimension();
  parseDimension();
  m_parser->onResolution(m_xOrder, m_yOrder, m_xSize, m_ySize);

  // Start parsing the data
  Rgbe color;
  RleCode rle;
  float *dest = m_parser->beginData();

  int count;
  size_t repeat = 0;
  unsigned invalidCount = 0;
  unsigned char *scanline = new unsigned char[4 * m_xSize];
  unsigned char *ptr, *end;

  int scanlines = 0;
  color = nextColor();
  while (scanlines != m_ySize)
  {
    // Check for invalid color which marks RLE pixel repeat
    // Consecutive repeat invalid pixels increments repeat count.
    if (color.r == 1 && color.g == 1 && color.b == 1)
    {
      qFatal("Untested! Possibly incorrect!");
      while (color.r == 1 && color.g == 1 && color.b == 1)
      {
        repeat += (color.e << (invalidCount * 8));
        color = nextColor();
        ++invalidCount;
      }
      while (repeat)
      {
        writeColor(dest, color);
        --repeat;
      }
    }

    // Check for invalid color which marks per-element RLE
    if (color.r == 2 && color.g == 2)
    {
      // Check scanline width
      if (((color.b << 8) | color.e) != m_xSize)
      {
        qFatal("Incorrect encoded scanline width! Expected `%d`, got `%d`", m_xSize, int((color.r << 8) | color.e));
      }

      // Read all channels
      ptr = &scanline[0];
      int written = 0;
      for (int channel = 0; channel < 4; ++channel)
      {
        end = &scanline[(channel+1)*m_xSize];
        while (ptr < end)
        {
          rle = nextRle();
          if (rle.run > 128)
          {
            count = int(rle.run) - 128;
            Q_ASSERT(count != 0);
            Q_ASSERT(count <= end - ptr);
            while (count > 0)
            {
              ++written;
              *ptr++ = rle.color;
              --count;
            }
          }
          else
          {
            count = int(rle.run) - 1;
            Q_ASSERT(count != -1);
            Q_ASSERT(count <= end - ptr);
            *ptr++ = rle.color;
            ++written;
            while (count > 0)
            {
              ++written;
              *ptr++ = nextChar();
              --count;
            }
          }
        }
      }

      // Output the scanline data
      writeScanline(dest, scanline, scanlines);
      ++scanlines;
    }

    color = nextColor();
  }
  m_parser->endData();

  delete [] scanline;

  return false;
}
//public
void RGBElement::stateMaschine()
{

    switch(m_state)
    {
    case 0:		//OFF
    {
        m_Rnext 		= 0;
        m_Gnext 		= 0;
        m_Bnext 		= 0;
        m_brightness 	= 1;
        m_fade 			= false;

        m_sync 			= false;

        break;
    }
    case 1:		//OFF_FADE_DOWN ==> STATE 0
    {
        m_Rnext 		= 0;
        m_Gnext 		= 0;
        m_Bnext 		= 0;
        m_brightness 	= 1;
        m_fade 			= true;

        m_sync			= true;

        if(isReady())
        {
            m_state = 0;
            m_out->pDln();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%M");
            m_out->pD(m_state);			//PROFILE/MODE
            m_out->pDln();

        }
        break;
    }
    case 2:		//ON_WHITE
    {
        m_Rnext 		= 255;
        m_Gnext 		= 255;
        m_Bnext 		= 255;
        m_brightness 	= 1;
        m_fade 			= false;

        m_sync 			= false;

        break;
    }
    case 3:		//ON_WHITE_FADE_UP  ==> STATE 2
    {
        m_Rnext 		= 255;
        m_Gnext 		= 255;
        m_Bnext 		= 255;
        m_brightness 	= 1;
        m_fade 			= true;
        m_uTime			= 5;

        m_sync 			= true;

        if(isReady())
        {
            m_state = 2;
            m_out->pDln();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%M");
            m_out->pD(m_state);			//PROFILE/MODE
            m_out->pDln();

        }
        break;
    }
    case 4:		//SELECTED_COLOR
    {
        break;
    }
    case 5:		//NEXT_COLOR
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            nextColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    case 6:		//SHUFFLE_COLOR
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            shuffleColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    case 7:		//PART_COLORS
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            partColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    case 8:		//RAND_COLOR
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            randColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    default:	//SWTICH_OFF
    {
        m_state = 0;
    }
    }
}
Exemplo n.º 12
0
void character::draw(){
	if(health <= 0) return;

    int ori_use_sphere = get_obj_type();

	int ori_color_i = getColorI();
	setColorI(color_i);

	sun_mode(false);

    glPushMatrix();

    switch(jumpping)
    {
    case 1:
        y += 0.1;
        if(y >= 1) jumpping = 2;
        break;
    case 2:
        y -= 0.1;
        if(y <= 0) jumpping = 0;
        break;
    }

    glTranslatef(x,y,z);
    glRotatef (-r, 0.0, 1.0, 0.0);

	glPushMatrix(); // health bar
    glTranslatef(0.0,3.0,0.0);
    glScalef (health / 100.0, 0.1,0.1);
	sun_mode(true);
    glutSolidCube(1.0);
    glPopMatrix();
	sun_mode(false);

    set_obj_type(is_sphere);

    glPushMatrix(); // body
    glScalef (1.6, 3.0, 0.75);
	nextColor();
    draw_obj();
    glPopMatrix();

    glPushMatrix(); // head
    glTranslatef(0.0,2.0,0.0);
	nextColor();
    draw_obj();
    glPopMatrix();

    glPushMatrix(); // right foot
    glTranslatef(0.8,-1.5,0.0);
	nextColor();
    draw_obj();
    glPopMatrix();

    glPushMatrix(); // left foot
    glTranslatef(-0.8,-1.5,0.0);
	nextColor();
    draw_obj();
    glPopMatrix();

    glPushMatrix(); // right hand
    glTranslatef(0.8,1.0,0.0);
    glScalef (0.4, 0.4, 0.4);
    glRotatef (75, 0.0, 0.0, 1.0);
    glRotatef (90, 0.0, 1.0, 0.0);
    right->draw();
    glPopMatrix();

    glPushMatrix(); // left hand
    glTranslatef(-0.8,1.0,0.0);
    glScalef (-0.4, 0.4, 0.4);
    glRotatef (75, 0.0, 0.0, 1.0);
    glRotatef (90, 0.0, 1.0, 0.0);
    left->draw();
    glPopMatrix();

    glPopMatrix();

	setColorI(ori_color_i);
    set_obj_type(ori_use_sphere);
}
Exemplo n.º 13
0
bool egcolor_menu::inMenu(int grp, int c) const {
	for (int cc = firstColor(grp); cc != 0; cc = nextColor(grp,cc)) {
		if (cc == c) return true;
	}
	return false;
}
Exemplo n.º 14
0
KLedTest::KLedTest(QWidget* parent)
  : QWidget(parent),
    LedWidth(16),
    LedHeight(10),
    Grid(3),
    ledcolor(0),
    ledlook(KLed::Flat),
    kled_round(true) // Switch HERE between rectangle and circular leds
{
  if (kled_round) {
    //KLed l(KLed::red, &qw);				// create lamp
    //KLed l(KLed::blue, &qw);				// create lamp
    l = new KLed(Qt::green, this);				// create lamp
    //KLed l(KLed::yellow, &qw);				// create lamp
    //KLed l(KLed::orange, &qw);				// create lamp


    l->resize(16,30);
    //l.setLook(KLed::flat);
    l->setShape(KLed::Circular);
    //l->setShape(KLed::Rectangular);

    //l->setLook(KLed::Flat);
    //l->setLook(KLed::Flat);
    //l->setLook(KLed::Flat);

    l->move(5,5);
    //    ktmp tmpobj(l);

    t_toggle.setSingleShot(false);
    t_toggle.start(1000);
    t_color.setSingleShot(false);
    t_color.start(3500);
    t_look.setSingleShot(false);
    t_look.start(3500);
    QObject::connect(&t_toggle, SIGNAL(timeout()), l, SLOT(toggle()));
    QObject::connect(&t_color, SIGNAL(timeout()), this, SLOT(nextColor()));
    QObject::connect(&t_look, SIGNAL(timeout()), this, SLOT(nextLook()));
    l->show();
    resize(240,140);
  }
  else {
    y=Grid; index=0;
    for( int shape=0; (int)shape<2; shape=(KLed::Shape)(shape+1)) {
      x=Grid;
      for( int look=0; (int)look<3; look=(KLed::Look)(look+1)) {
	for(state=KLed::Off; (int)state<2; state=(KLed::State)(state+1))
	    {
	      leds[index]=new KLed(Qt::yellow, state,
				   (KLed::Look)(look+1),
				   (KLed::Shape)(shape+1), this);
	      leds[index]->setGeometry(x, y, LedWidth, LedHeight);
	      ++index;
	      x+=Grid+LedWidth;
	    }
	}
      y+=Grid+LedHeight;
      }
    setFixedSize(x+Grid, y+Grid);
    connect(&timer, SIGNAL(timeout()), SLOT(timeout()));
    timer.start(500);
  }
}