void doubleslider::mouseMoveEvent(QMouseEvent* event) { if (bewegeLinks) { float temp = (event->x()*1.0) / width(); if (temp < wert2) { wert1 = temp; paintAll(); emit value1Changed(wert1); } } if (bewegeRechts) { float temp = (event->x()*1.0) / width(); if (temp > wert1) { wert2 = temp; paintAll(); emit value2Changed(wert2); } } }
doubleslider::doubleslider(float val1, float val2 , QWidget* parent, const char* name): QWidget(parent, name) { bewegeLinks = false; bewegeRechts = false; min_ = val1; max_ = val2; diff_ = max_ - min_; buffer = new QPixmap(width(), height()); setMinimumWidth (100); paintAll(); }
void CShowGrafView::OnDraw(CDC *pDC) { try { if(m_firstDraw) { m_coordinateSystem.substituteControl(this, IDC_SYSTEMPANEL); m_firstDraw = false; } const CRect rect = getClientRect(this); if(paintAll(*pDC, rect, &m_axisFont, &m_buttonFont)) { DoubleInterval maxNormInterval(0,1); const DataRange dr = m_coordinateSystem.getDataRange(); enableMenuItem(ID_VIEW_SCALE_X_LOGARITHMIC , dr.getMinX() > 0); enableMenuItem(ID_VIEW_SCALE_Y_LOGARITHMIC , dr.getMinY() > 0); enableMenuItem(ID_VIEW_SCALE_X_NORMALDIST , maxNormInterval.contains(dr.getXInterval())); enableMenuItem(ID_VIEW_SCALE_Y_NORMALDIST , maxNormInterval.contains(dr.getYInterval())); checkMenuItem( ID_VIEW_RETAINASPECTRATIO , m_coordinateSystem.isRetainingAspectRatio()); enableMenuItem(ID_VIEW_RETAINASPECTRATIO , m_coordinateSystem.canRetainAspectRatio() ); checkMenuItem( ID_VIEW_ROLLAVG , getDoc()->getRollAvg() ); } } catch(Exception e) { showException(e); } }
void doubleslider::resizeEvent(QResizeEvent* event){ buffer->resize(event->size().width(), event->size().height()); paintAll(); }
void doubleslider::setWert2(const QString& val2) { wert2 = (val2.toFloat()-min_)/diff_; //cout <<"#s#:"<< wert2<<" = ("<<val2.toFloat()<<" - "<<min_<<") / "<<diff_<<endl; paintAll(); }
void doubleslider::setWert2(float val2) { wert2 = (val2-min_)/diff_; //cout <<"#f#:"<< wert2<<" = ("<<val2<<" - "<<min_<<") / "<<diff_<<endl; paintAll(); }
void doubleslider::setWert1(const QString& val1) { wert1 = (val1.toFloat()-min_)/diff_; paintAll(); }
void doubleslider::setWert1(float val1) { wert1 = (val1-min_)/diff_; paintAll(); }
void TableBehaviorSnake::doLoop() { paintAll(CRGB::Black, false); int newPosX = -1; int newPosY = -1; int randomTryCount = 0; while(newPosX == -1 && randomTryCount < 500){ switch (mDirection) { case 0: if(isPositionEmpty(mSnake[0]->x - 1, mSnake[0]->y) == 1){ newPosX = mSnake[0]->x - 1; newPosY = mSnake[0]->y; } break; case 1: if(isPositionEmpty(mSnake[0]->x + 1, mSnake[0]->y) == 1){ newPosX = mSnake[0]->x + 1; newPosY = mSnake[0]->y; } break; case 2: if(isPositionEmpty(mSnake[0]->x, mSnake[0]->y - 1) == 1){ newPosX = mSnake[0]->x; newPosY = mSnake[0]->y - 1; } break; case 3: if(isPositionEmpty(mSnake[0]->x, mSnake[0]->y + 1) == 1){ newPosX = mSnake[0]->x; newPosY = mSnake[0]->y + 1; } break; default: break; } if (newPosX == -1){ mDirection = random(4); randomTryCount++; } } // Gameover ? if (newPosX == -1 || newPosY == -1){ delay(1000); mSnakeSize = 3; mSnake[0]->set(9, 4); mSnake[1]->set(9, 3); mSnake[2]->set(9, 2); }else{ // move the snake SnakeUnit previousValues; SnakeUnit newValues; for (int i = 0; i < mSnakeSize; ++i) { int tmpX = mSnake[i]->x; int tmpY = mSnake[i]->y; // if 'head' else 'body' if (i == 0){ newValues.x = newPosX; newValues.y = newPosY; }else{ newValues.x = previousValues.x; newValues.y = previousValues.y; } // Apply new values mSnake[i]->x = newValues.x; mSnake[i]->y = newValues.y; // Store old values previousValues.x = tmpX; previousValues.y = tmpY; setCorrectColor(mSnake[i]->x, mSnake[i]->y, mSnakeColor); } } // Sometimes change the direction if (random(100) > 80){ mDirection = random(4); } // Sometimes growup if (random(100) > 95){ growUp(); } FastLED.show(); delay(50); // read any changes on Potentiometer and Button B readInputs(); }
void Board::paintEvent( QPaintEvent * ) { paintAll(); }