//! Draw the sky grid in the current frame void SkyGrid::draw(const StelCore* core) const { const StelProjectorP prj = core->getProjection(frameType, frameType!=StelCore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff); if (!fader.getInterstate()) return; bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();; // Look for all meridians and parallels intersecting with the disk bounding the viewport // Check whether the pole are in the viewport bool northPoleInViewport = false; bool southPoleInViewport = false; Vec3f win; if (prj->project(Vec3f(0,0,1), win) && prj->checkInViewport(win)) northPoleInViewport = true; if (prj->project(Vec3f(0,0,-1), win) && prj->checkInViewport(win)) southPoleInViewport = true; // Get the longitude and latitude resolution at the center of the viewport Vec3d centerV; prj->unProject(prj->getViewportPosX()+prj->getViewportWidth()/2., prj->getViewportPosY()+prj->getViewportHeight()/2.+1., centerV); double lon2, lat2; StelUtils::rectToSphe(&lon2, &lat2, centerV); const double gridStepParallelRad = M_PI/180.*getClosestResolutionDMS(prj->getPixelPerRadAtCenter()); double gridStepMeridianRad; if (northPoleInViewport || southPoleInViewport) gridStepMeridianRad = (frameType==StelCore::FrameAltAz || frameType==StelCore::FrameGalactic) ? M_PI/180.* 10. : M_PI/180.* 15.; else { const double closestResLon = (frameType==StelCore::FrameAltAz || frameType==StelCore::FrameGalactic) ? getClosestResolutionDMS(prj->getPixelPerRadAtCenter()*std::cos(lat2)) : getClosestResolutionHMS(prj->getPixelPerRadAtCenter()*std::cos(lat2)); gridStepMeridianRad = M_PI/180.* ((northPoleInViewport || southPoleInViewport) ? 15. : closestResLon); } // Get the bounding halfspace const SphericalCap& viewPortSphericalCap = prj->getBoundingCap(); // Compute the first grid starting point. This point is close to the center of the screen // and lies at the intersection of a meridian and a parallel lon2 = gridStepMeridianRad*((int)(lon2/gridStepMeridianRad+0.5)); lat2 = gridStepParallelRad*((int)(lat2/gridStepParallelRad+0.5)); Vec3d firstPoint; StelUtils::spheToRect(lon2, lat2, firstPoint); firstPoint.normalize(); // Q_ASSERT(viewPortSphericalCap.contains(firstPoint)); // Initialize a painter and set OpenGL state StelPainter sPainter(prj); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glEnable(GL_LINE_SMOOTH); #endif // make text colors just a bit brighter. (But if >1, QColor::setRgb fails and makes text invisible.) Vec4f textColor(qMin(1.0f, 1.25f*color[0]), qMin(1.0f, 1.25f*color[1]), qMin(1.0f, 1.25f*color[2]), fader.getInterstate()); sPainter.setColor(color[0],color[1],color[2], fader.getInterstate()); sPainter.setFont(font); ViewportEdgeIntersectCallbackData userData(&sPainter); userData.textColor = textColor; userData.frameType = frameType; ///////////////////////////////////////////////// // Draw all the meridians (great circles) SphericalCap meridianSphericalCap(Vec3d(1,0,0), 0); Mat4d rotLon = Mat4d::zrotation(gridStepMeridianRad); Vec3d fpt = firstPoint; Vec3d p1, p2; int maxNbIter = (int)(M_PI/gridStepMeridianRad); int i; for (i=0; i<maxNbIter; ++i) { StelUtils::rectToSphe(&lon2, &lat2, fpt); userData.raAngle = lon2; meridianSphericalCap.n = fpt^Vec3d(0,0,1); meridianSphericalCap.n.normalize(); if (!SphericalCap::intersectionPoints(viewPortSphericalCap, meridianSphericalCap, p1, p2)) { if (viewPortSphericalCap.d<meridianSphericalCap.d && viewPortSphericalCap.contains(meridianSphericalCap.n)) { // The meridian is fully included in the viewport, draw it in 3 sub-arcs to avoid length > 180. const Mat4d& rotLon120 = Mat4d::rotation(meridianSphericalCap.n, 120.*M_PI/180.); Vec3d rotFpt=fpt; rotFpt.transfo4d(rotLon120); Vec3d rotFpt2=rotFpt; rotFpt2.transfo4d(rotLon120); sPainter.drawGreatCircleArc(fpt, rotFpt, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt, rotFpt2, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt2, fpt, NULL, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); continue; } else break; } Vec3d middlePoint = p1+p2; middlePoint.normalize(); if (!viewPortSphericalCap.contains(middlePoint)) middlePoint*=-1.; // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); } if (i!=maxNbIter) { rotLon = Mat4d::zrotation(-gridStepMeridianRad); fpt = firstPoint; fpt.transfo4d(rotLon); for (int j=0; j<maxNbIter-i; ++j) { StelUtils::rectToSphe(&lon2, &lat2, fpt); userData.raAngle = lon2; meridianSphericalCap.n = fpt^Vec3d(0,0,1); meridianSphericalCap.n.normalize(); if (!SphericalCap::intersectionPoints(viewPortSphericalCap, meridianSphericalCap, p1, p2)) break; Vec3d middlePoint = p1+p2; middlePoint.normalize(); if (!viewPortSphericalCap.contains(middlePoint)) middlePoint*=-1; sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); } } ///////////////////////////////////////////////// // Draw all the parallels (small circles) SphericalCap parallelSphericalCap(Vec3d(0,0,1), 0); rotLon = Mat4d::rotation(firstPoint^Vec3d(0,0,1), gridStepParallelRad); fpt = firstPoint; maxNbIter = (int)(M_PI/gridStepParallelRad)-1; for (i=0; i<maxNbIter; ++i) { StelUtils::rectToSphe(&lon2, &lat2, fpt); if (withDecimalDegree) userData.text = StelUtils::radToDecDegStr(lat2); else userData.text = StelUtils::radToDmsStrAdapt(lat2); parallelSphericalCap.d = fpt[2]; if (parallelSphericalCap.d>0.9999999) break; const Vec3d rotCenter(0,0,parallelSphericalCap.d); if (!SphericalCap::intersectionPoints(viewPortSphericalCap, parallelSphericalCap, p1, p2)) { if ((viewPortSphericalCap.d<parallelSphericalCap.d && viewPortSphericalCap.contains(parallelSphericalCap.n)) || (viewPortSphericalCap.d<-parallelSphericalCap.d && viewPortSphericalCap.contains(-parallelSphericalCap.n))) { // The parallel is fully included in the viewport, draw it in 3 sub-arcs to avoid lengths >= 180 deg static const Mat4d rotLon120 = Mat4d::zrotation(120.*M_PI/180.); Vec3d rotFpt=fpt; rotFpt.transfo4d(rotLon120); Vec3d rotFpt2=rotFpt; rotFpt2.transfo4d(rotLon120); sPainter.drawSmallCircleArc(fpt, rotFpt, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(rotFpt, rotFpt2, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(rotFpt2, fpt, rotCenter, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); continue; } else break; } // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg Vec3d middlePoint = p1-rotCenter+p2-rotCenter; middlePoint.normalize(); middlePoint*=(p1-rotCenter).length(); middlePoint+=rotCenter; if (!viewPortSphericalCap.contains(middlePoint)) { middlePoint-=rotCenter; middlePoint*=-1.; middlePoint+=rotCenter; } sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); } if (i!=maxNbIter) { rotLon = Mat4d::rotation(firstPoint^Vec3d(0,0,1), -gridStepParallelRad); fpt = firstPoint; fpt.transfo4d(rotLon); for (int j=0; j<maxNbIter-i; ++j) { StelUtils::rectToSphe(&lon2, &lat2, fpt); if (withDecimalDegree) userData.text = StelUtils::radToDecDegStr(lat2); else userData.text = StelUtils::radToDmsStrAdapt(lat2); parallelSphericalCap.d = fpt[2]; const Vec3d rotCenter(0,0,parallelSphericalCap.d); if (!SphericalCap::intersectionPoints(viewPortSphericalCap, parallelSphericalCap, p1, p2)) { if ((viewPortSphericalCap.d<parallelSphericalCap.d && viewPortSphericalCap.contains(parallelSphericalCap.n)) || (viewPortSphericalCap.d<-parallelSphericalCap.d && viewPortSphericalCap.contains(-parallelSphericalCap.n))) { // The parallel is fully included in the viewport, draw it in 3 sub-arcs to avoid lengths >= 180 deg static const Mat4d rotLon120 = Mat4d::zrotation(120.*M_PI/180.); Vec3d rotFpt=fpt; rotFpt.transfo4d(rotLon120); Vec3d rotFpt2=rotFpt; rotFpt2.transfo4d(rotLon120); sPainter.drawSmallCircleArc(fpt, rotFpt, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(rotFpt, rotFpt2, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(rotFpt2, fpt, rotCenter, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); continue; } else break; } // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg Vec3d middlePoint = p1-rotCenter+p2-rotCenter; middlePoint.normalize(); middlePoint*=(p1-rotCenter).length(); middlePoint+=rotCenter; if (!viewPortSphericalCap.contains(middlePoint)) { middlePoint-=rotCenter; middlePoint*=-1.; middlePoint+=rotCenter; } sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, viewportEdgeIntersectCallback, &userData); fpt.transfo4d(rotLon); } } // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif }
void Minitel::useDefaultColors() { bgColor(BLACK); textColor(WHITE); }
bool InstrumentCluster::Init(const Rect& boxIn) { bool res = false; do { Trig::BuildTrigTabs(); Rect box(boxIn); mExtents = box; // The primary surface is where we draw images to the screen mPrimarySurface.Init(box, true, true); // We draw to the back surface to get double buffering mPrimarySurface.GetGraphicsContext().SetSurfaceSelection(ePrimaryBack); // Background - we use a cluster element so that we get all the graphics functions mBackground.Init(box); mBackground.SetGradientAngle(0); mBackground.AddGradientStop(0.0, eOpaque, 0, 0, 64); mBackground.AddGradientStop(1.0, eOpaque, 0, 0, 0); mBackground.GetGraphicsContext().SetSurfaceSelection(eFront); mElements.push_back(&mBackground); Color32 textColor(200,200,200,eOpaque); // Speedometer box.x = box.y = 0; box.w = box.h = 360; Point point; point.x = 200; point.y = 50; mSpeedo.Init(box); mSpeedo.SetMinMax(0, 160, 5, 10, -120, 120); mSpeedo.SetLocation(point); mSpeedo.SetTextColor(textColor); mSpeedo.SetLabelText("miles/hour"); mSpeedo.SetLabelCenter(Point(180, 75)); mSpeedo.SetFullCircle(true); mElements.push_back(&mSpeedo); // Tachometer point.x = 1280 - 200 - box.w; point.y = 50; mTach.Init(box); mTach.SetValue(0); mTach.SetMinMax(0, 8000, 250, 1000, -120, 120); mTach.AddColorRange(Color32(200, 0, 0, eOpaque), 7000, 8000); mTach.AddColorRange(Color32(0xff, 0x33, 0, eOpaque), 6500, 7000); mTach.SetLocation(point); mTach.SetTextColor(textColor); mTach.SetLabelText("revs/min"); mTach.SetLabelCenter(Point(180, 75)); mTach.SetFullCircle(true); mElements.push_back(&mTach); // Water temp guage point.x = 100; point.y = 300; box.w = box.h = 150; mWaterTemp.Init(box); mWaterTemp.SetMinMax('C', 'H', 0, 100, 25, 100, -150, -30); mWaterTemp.SetValue(50); mWaterTemp.AddColorRange(Color32(200, 200, 200, eOpaque), 0, 80); mWaterTemp.AddColorRange(Color32(200, 0, 0, eOpaque), 85, 100); mWaterTemp.SetLocation(point); mWaterTemp.SetLabelImage(gWaterTempImage); // mWaterTemp.SetLabelImageCenter(Point(35, 75)); mWaterTemp.SetLabelImageCenter(Point(70, 90)); mWaterTemp.SetFullCircle(false); mElements.push_back(&mWaterTemp); // Fuel guage point.x = 1280 - 100 - box.w; point.y = 300; box.w = box.h = 150; mFuel.Init(box); mFuel.SetValue(50); mFuel.SetMinMax('F', 'E', 100, 0, 25, 100, 30, 150); mFuel.AddColorRange(Color32(200, 200, 200, eOpaque), 100, 0); mFuel.AddColorRange(Color32(200, 0, 0, eOpaque), 10, 0); mFuel.SetLocation(point); mFuel.SetLabelImage(gFuelImage); // mFuel.SetLabelImageCenter(Point(90, 75)); mFuel.SetLabelImageCenter(Point(50, 90)); mFuel.SetFullCircle(false); mElements.push_back(&mFuel); // Caps for dials int16_t capRadius = 30; box.x = 0; box.y = 0; box.w = capRadius * 2; box.h = capRadius * 2; // Speedo cap point.x = 200 + 180 - capRadius; point.y = 50 + 180 - capRadius; mSpeedoCap.Init(box); mSpeedoCap.SetLocation(point); mSpeedoCap.GetGraphicsContext().SetSurfaceSelection(eFront); //mElements.push_back(&mSpeedoCap); // Tach cap point.x = 1280 - 200 - 180 - capRadius; point.y = 50 + 180 - capRadius; mTachCap.Init(box); mTachCap.SetLocation(point); mTachCap.GetGraphicsContext().SetSurfaceSelection(eFront); //mElements.push_back(&mTachCap); // Water temp cap capRadius = 25; box.w = capRadius * 2; box.h = capRadius * 2; point.x = 175 - capRadius; point.y = 300 + 75 - capRadius; mWaterTempCap.Init(box); mWaterTempCap.SetLocation(point); mWaterTempCap.GetGraphicsContext().SetSurfaceSelection(eFront); //mElements.push_back(&mWaterTempCap); // Fuel cap point.x = 1280 - 175 - capRadius; point.y = 300 + 75 - capRadius; mFuelCap.Init(box); mFuelCap.SetLocation(point); mFuelCap.GetGraphicsContext().SetSurfaceSelection(eFront); //mElements.push_back(&mFuelCap); // InfoCenter - top view of our car + information display box.w = 192; box.h = 192; mInfoCenter.Init(box); point.x = 544; point.y = 100; mInfoCenter.SetLocation(point); mInfoCenter.SetMode(eInfoModeTirePressure); mInfoCenter.SetTextColor(textColor); mElements.push_back(&mInfoCenter); // Left turn signal box.w = 48; box.h = 48; mLeftArrow.Init(box); point.x = 500; point.y = 30; mLeftArrow.SetLocation(point); mLeftArrow.SetImage(gLeftArrowImage); mElements.push_back(&mLeftArrow); // Right turn signal mRightArrow.Init(box); point.x = 732; point.y = 30; mRightArrow.SetLocation(point); mRightArrow.SetImage(gRightArrowImage); mElements.push_back(&mRightArrow); res = true; } while (false); return res; }
void WindowEdit::onRender( RenderContext & context, const RectInt & window ) { if (! windowStyle() ) return; DisplayDevice * pDisplay = context.display(); ASSERT( pDisplay ); Font * pFont = windowStyle()->font(); ASSERT( pFont ); // calculate the total text size SizeInt textSize( pFont->size( WideString( m_Text ) ) ); // get the text color Color textColor( windowStyle()->color() ); textColor.m_A = m_Editing ? ACTIVE_ALPHA : INACTIVE_ALPHA; SizeInt windowSize( window.size() ); // check the size of the window compared to the text size m_EditBegin = 0; m_EditEnd = m_Text.length() - 1; while ( textSize.m_Width > windowSize.m_Width ) { if ( m_EditBegin < m_Cursor ) { textSize.m_Width -= pFont->characterWidth( m_Text[ m_EditBegin ] ); m_EditBegin++; } else if ( m_EditEnd > m_Cursor ) { textSize.m_Width -= pFont->characterWidth( m_Text[ m_EditEnd ] ); m_EditEnd--; } else // not enough room, the font is probably too large so just return return; } // extract the displayable part of the text WideString display( m_Text ); display.mid( m_EditBegin, (m_EditEnd - m_EditBegin) + 1 ); // draw text left justified and centered vertically PointInt ptText( window.m_Left, window.m_Top + ((windowSize.m_Height / 2) - (textSize.m_Height / 2)) ); // draw the text, construct another PointInt on the stack because Font::push will modify the point PointInt ptText2 = ptText; Font::push( pDisplay, pFont, ptText2, display, textColor ); // display cursor if editing if ( m_Editing ) { // draw cursor for(int i=m_EditBegin;i<m_Cursor;i++) ptText.m_X += pFont->characterWidth( m_Text[i] ); Color cursorColor( textColor ); cursorColor.m_A = (u8)(fmod( m_ActiveTime, CURSOR_BLINK_RATE ) * 255); RectInt cursorRect( ptText, SizeInt( CURSOR_WIDTH, textSize.height ) ); PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::ADDITIVE ); PrimitiveWindow::push( pDisplay, cursorRect , RectFloat(0,0,0,0), cursorColor ); } }
/** * Overrides the standard paint event. */ void StateWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); const qreal w = width(); const qreal h = height(); if (w == 0 || h == 0) return; setPenFromSettings(painter); switch (m_stateType) { case StateWidget::Normal: { if (UMLWidget::useFillColor()) { painter->setBrush(UMLWidget::fillColor()); } const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing(); int textStartY = (h / 2) - (fontHeight / 2); const int count = m_Activities.count(); if (count == 0) { painter->drawRoundRect(0, 0, w, h, (h*40)/w, (w*40)/h); painter->setPen(textColor()); QFont font = UMLWidget::font(); font.setBold(false); painter->setFont(font); painter->drawText(STATE_MARGIN, textStartY, w - STATE_MARGIN * 2, fontHeight, Qt::AlignCenter, name()); setPenFromSettings(painter); } else { painter->drawRoundRect(0, 0, w, h, (h*40)/w, (w*40)/h); textStartY = STATE_MARGIN; painter->setPen(textColor()); QFont font = UMLWidget::font(); font.setBold(true); painter->setFont(font); painter->drawText(STATE_MARGIN, textStartY, w - STATE_MARGIN * 2, fontHeight, Qt::AlignCenter, name()); font.setBold(false); painter->setFont(font); setPenFromSettings(painter); int linePosY = textStartY + fontHeight; QStringList::Iterator end(m_Activities.end()); for(QStringList::Iterator it(m_Activities.begin()); it != end; ++it) { textStartY += fontHeight; painter->drawLine(0, linePosY, w, linePosY); painter->setPen(textColor()); painter->drawText(STATE_MARGIN, textStartY, w - STATE_MARGIN * 2, fontHeight, Qt::AlignCenter, *it); setPenFromSettings(painter); linePosY += fontHeight; }//end for }//end else } break; case StateWidget::Initial : painter->setBrush(WidgetBase::lineColor()); painter->drawEllipse(0, 0, w, h); break; case StateWidget::End : painter->setBrush(WidgetBase::lineColor()); painter->drawEllipse(0, 0, w, h); painter->setBrush(Qt::white); painter->drawEllipse(1, 1, w - 2, h - 2); painter->setBrush(WidgetBase::lineColor()); painter->drawEllipse(3, 3, w - 6, h - 6); break; case StateWidget::Fork: case StateWidget::Join: { painter->setPen(Qt::black); painter->setBrush(Qt::black); painter->drawRect(rect()); } break; case StateWidget::Junction: { painter->setPen(Qt::black); painter->setBrush(Qt::black); painter->drawEllipse(rect()); } break; case StateWidget::DeepHistory: { painter->setBrush(Qt::white); painter->drawEllipse(rect()); painter->setPen(Qt::black); painter->setFont(UMLWidget::font()); const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing() / 2; const int xStar = fm.boundingRect(QLatin1String("H")).width(); const int yStar = fontHeight / 4; painter->drawText((w / 6), (h / 4) + fontHeight, QLatin1String("H")); painter->drawText((w / 6) + xStar, (h / 4) + fontHeight - yStar, QLatin1String("*")); } break; case StateWidget::ShallowHistory: { painter->setBrush(Qt::white); painter->drawEllipse(rect()); painter->setPen(Qt::black); painter->setFont(UMLWidget::font()); const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing() / 2; painter->drawText((w / 6), (h / 4) + fontHeight, QLatin1String("H")); } break; case StateWidget::Choice: { const qreal x = w / 2; const qreal y = h / 2; QPolygonF polygon; polygon << QPointF(x, 0) << QPointF(w, y) << QPointF(x, h) << QPointF(0, y); painter->setBrush(UMLWidget::fillColor()); painter->drawPolygon(polygon); } break; default: uWarning() << "Unknown state type: " << stateTypeStr(); break; } UMLWidget::paint(painter, option, widget); }
void programCloseUI(void) // 프로그램 종료 UI { cursorOff(); system("cls"); textColor(16 * 14); printf(" < 프로그램 종료 > "); Sleep(TIME_OF_DELAY); textColor(15); printf(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" @@@@@@@@@@@@@@@@@***.....*@@@@@@*@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" @@@@@@@@@@@***... ..****@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" *@*@@@@@@@*.... .**. *@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" @@@@@@*.... ........... .@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" *@@@@@@*.. ..*********...... .*@@@@@@@@@@@@@@@@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" ****@@@@@@*.. .... .@@@@@@@**. ..@@@\n"); Sleep(TIME_OF_DELAY); printf(" @@******.. ...*.****.. .@@@@*. ..@@\n"); Sleep(TIME_OF_DELAY); printf(" ***.*..** ..*..***. .*@@*.. ... ..@@\n"); Sleep(TIME_OF_DELAY); printf(" ***.****. .. .*@*. .. *@@\n"); Sleep(TIME_OF_DELAY); printf(" ***...** .**. . .@@@\n"); Sleep(TIME_OF_DELAY); printf(" *....** .*. *@@@@\n"); Sleep(TIME_OF_DELAY); printf(" *..** ... .. ..@@@@@\n"); Sleep(TIME_OF_DELAY); printf(" **@@*. . ..........@@@@\n"); Sleep(TIME_OF_DELAY); printf(" @***@. . ... ....***@\n"); Sleep(TIME_OF_DELAY); printf(" @*@*.... ... ...........\n"); Sleep(TIME_OF_DELAY); printf(" @*@@*.***...* ............ .\n"); Sleep(TIME_OF_DELAY); printf(" @@@*.*... .... ....... .\n"); Sleep(TIME_OF_DELAY); printf(" @@*.... ..... . .\n"); Sleep(TIME_OF_DELAY); printf(" *@.. ........... .\n"); Sleep(TIME_OF_DELAY); printf(" .@*.. ...****.......... .. .\n"); Sleep(TIME_OF_DELAY); printf(" ........ .@@****......... .\n"); Sleep(TIME_OF_DELAY); printf(" *******...** .\n"); Sleep(TIME_OF_DELAY); printf(" .*@@**@@@* . ..\n"); Sleep(TIME_OF_DELAY); printf(" ..........................................@@@@@@@@* . ..\n"); Sleep(TIME_OF_DELAY); textColor(7); gotoxy(4, 25); printf(" made by YG & Kyung"); textColor(14); gotoxy(4, 17); printf("G"); Sleep(TIME_OF_DELAY); printf("O"); Sleep(TIME_OF_DELAY); printf("O"); Sleep(TIME_OF_DELAY); printf("D"); Sleep(TIME_OF_DELAY); gotoxy(9, 17); printf("B"); Sleep(TIME_OF_DELAY); printf("Y"); Sleep(TIME_OF_DELAY); printf("E"); Sleep(TIME_OF_DELAY); gotoxy(4, 18); printf("S"); Sleep(TIME_OF_DELAY); printf("E"); Sleep(TIME_OF_DELAY); printf("E"); Sleep(TIME_OF_DELAY); gotoxy(8, 18); printf("Y"); Sleep(TIME_OF_DELAY); printf("O"); Sleep(TIME_OF_DELAY); printf("U"); Sleep(TIME_OF_DELAY); gotoxy(12, 18); printf("L"); Sleep(TIME_OF_DELAY); printf("A"); Sleep(TIME_OF_DELAY); printf("T"); Sleep(TIME_OF_DELAY); printf("E"); Sleep(TIME_OF_DELAY); printf("R"); Sleep(TIME_OF_DELAY); gotoxy(31, 18); textColor(12); printf("♡"); Sleep(TIME_OF_DELAY * 3); textColor(15); gotoxy(31, 18); printf("*."); textColor(12); gotoxy(25, 18); printf("\b\b♥"); Sleep(TIME_OF_DELAY); printf("\b\b\b♥"); Sleep(TIME_OF_DELAY); printf("\b\b\b♥"); Sleep(TIME_OF_DELAY); printf("\b\b\b♥"); Sleep(TIME_OF_DELAY); printf("\b\b\b♥"); Sleep(TIME_OF_DELAY); printf("\b\b\b♥"); Sleep(TIME_OF_DELAY); printf("\b\b\b♥"); Sleep(TIME_OF_DELAY); textColor(7); gotoxy(4, 28); }
void RichTextEdit::setupActions() { EditMenu *menu = Controller::create()->getEditMenu(); toolbar->setWindowTitle(tr("Edit Actions")); actionSave = toolbar->addAction(QIcon("icons/document-save.png"), tr("Save")); actionSave->setShortcut(QKeySequence::Save); toolbar->addSeparator(); actionUndo = toolbar->addAction(QIcon("icons/edit-undo.png"), tr("Undo")); menu->addAction(actionUndo); actionUndo->setShortcut(QKeySequence::Undo); actionRedo = toolbar->addAction(QIcon("icons/edit-redo.png"), tr("Redo")); menu->addAction(actionRedo); actionRedo->setShortcut(QKeySequence::Redo); actionCut = toolbar->addAction(QIcon("icons/edit-cut.png"), tr("Cut")); menu->addAction(actionCut); actionCut->setShortcut(QKeySequence::Cut); actionCopy = toolbar->addAction(QIcon("icons/edit-copy.png"), tr("Copy")); menu->addAction(actionCopy); actionCopy->setShortcut(QKeySequence::Copy); actionPaste = toolbar->addAction(QIcon("icons/edit-paste.png"), tr("Paste")); menu->addAction(actionPaste); actionPaste->setShortcut(QKeySequence::Paste); toolbar->addSeparator(); actionTextBold = toolbar->addAction(QIcon("icons/format-text-bold.png"), tr("Bold")); menu->addAction(actionTextBold); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); actionTextBold->setCheckable(true); actionTextItalic = toolbar->addAction(QIcon("icons/format-text-italic.png"), tr("Italic")); menu->addAction(actionTextItalic); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); actionTextItalic->setCheckable(true); actionTextUnderline = toolbar->addAction(QIcon("icons/format-text-underline.png"), tr("Underline")); menu->addAction(actionTextUnderline); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); actionTextUnderline->setCheckable(true); toolbar->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *))); actionAlignLeft = new QAction(QIcon("icons/format-justify-left.png"), tr("&Left"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignCenter = new QAction(QIcon("icons/format-justify-center.png"), tr("C&enter"), grp); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignRight = new QAction(QIcon("icons/format-justify-right.png"), tr("&Right"), grp); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignJustify = new QAction(QIcon("icons/format-justify-fill.png"), tr("&Justify"), grp); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); toolbar->addActions(grp->actions()); menu->addActions(grp->actions()); toolbar->addSeparator(); // color QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); toolbar->addAction(actionTextColor); menu->addAction(actionTextColor); actionFind = toolbar->addAction(QIcon("icons/edit-find.png"), tr("Find")); actionFind->setShortcut(QKeySequence::Find); menu->addAction(actionFind); }
void BBTCOView::paintEvent( QPaintEvent * ) { QPainter p( this ); QColor col; if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() ) { col = QColor( 160, 160, 160 ); } else if ( m_bbTCO->m_useStyleColor ) { col = p.pen().brush().color(); } else { col = m_bbTCO->colorObj(); } if( isSelected() == true ) { col.setRgb( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 ); } QLinearGradient lingrad( 0, 0, 0, height() ); lingrad.setColorAt( 0, col.light( 130 ) ); lingrad.setColorAt( 1, col.light( 70 ) ); p.fillRect( rect(), lingrad ); tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() ); if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 ) { for( int x = static_cast<int>( t * pixelsPerTact() ); x < width()-2; x += static_cast<int>( t * pixelsPerTact() ) ) { p.setPen( col.light( 80 ) ); p.drawLine( x, 1, x, 5 ); p.setPen( col.light( 120 ) ); p.drawLine( x, height() - 6, x, height() - 2 ); } } p.setPen( col.lighter( 130 ) ); p.drawRect( 1, 1, rect().right()-2, rect().bottom()-2 ); p.setPen( col.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); p.setFont( pointSize<8>( p.font() ) ); p.setPen( QColor( 0, 0, 0 ) ); p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() ); p.setPen( textColor() ); p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() ); if( m_bbTCO->isMuted() ) { p.drawPixmap( 3, p.fontMetrics().height() + 1, embed::getIconPixmap( "muted", 16, 16 ) ); } }
void SampleTCOView::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); const QColor styleColor = p.pen().brush().color(); QColor c; if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) ) c = isSelected() ? QColor( 0, 0, 224 ) : styleColor; else c = QColor( 80, 80, 80 ); QLinearGradient grad( 0, 0, 0, height() ); grad.setColorAt( 1, c.darker( 300 ) ); grad.setColorAt( 0, c ); p.setBrush( grad ); p.setPen( c.lighter( 160 ) ); p.drawRect( 1, 1, width()-3, height()-3 ); p.setBrush( QBrush() ); p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, width()-1, height()-1 ); if( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) { p.setPen( QColor( 128, 128, 128 ) ); } else { p.setPen( fgColor() ); } QRect r = QRect( 1, 1, qMax( static_cast<int>( m_tco->sampleLength() * pixelsPerTact() / DefaultTicksPerTact ), 1 ), height() - 4 ); p.setClipRect( QRect( 1, 1, width() - 2, height() - 2 ) ); m_tco->m_sampleBuffer->visualize( p, r, _pe->rect() ); if( r.width() < width() - 1 ) { p.drawLine( r.x() + r.width(), r.y() + r.height() / 2, width() - 2, r.y() + r.height() / 2 ); } p.translate( 0, 0 ); if( m_tco->isMuted() ) { p.drawPixmap( 3, 8, embed::getIconPixmap( "muted", 16, 16 ) ); } if( m_tco->isRecord() ) { p.setFont( pointSize<7>( p.font() ) ); p.setPen( QColor( 0, 0, 0 ) ); p.drawText( 10, p.fontMetrics().height()+1, "Rec" ); p.setPen( textColor() ); p.drawText( 9, p.fontMetrics().height(), "Rec" ); p.setBrush( QBrush( textColor() ) ); p.drawEllipse( 4, 5, 4, 4 ); } }
/** * Overrides standard method. */ void NodeWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); setPenFromSettings(painter); if (UMLWidget::useFillColor()) { painter->setBrush(UMLWidget::fillColor()); } else { painter->setBrush(m_scene->backgroundColor()); } const int w = width(); const int h = height(); const int wDepth = (w/3 > DEPTH ? DEPTH : w/3); const int hDepth = (h/3 > DEPTH ? DEPTH : h/3); const int bodyOffsetY = hDepth; const int bodyWidth = w - wDepth; const int bodyHeight = h - hDepth; QFont font = UMLWidget::font(); font.setBold(true); const QFontMetrics &fm = getFontMetrics(FT_BOLD); const int fontHeight = fm.lineSpacing(); QString nameStr = name(); QPolygon pointArray(5); pointArray.setPoint(0, 0, bodyOffsetY); pointArray.setPoint(1, wDepth, 0); pointArray.setPoint(2, w, 0); pointArray.setPoint(3, w, bodyHeight); pointArray.setPoint(4, bodyWidth, h); painter->drawPolygon(pointArray); painter->drawRect(0, bodyOffsetY, bodyWidth, bodyHeight); painter->drawLine(w, 0, bodyWidth, bodyOffsetY); painter->setPen(textColor()); painter->setFont(font); int lines = 1; if (m_umlObject) { QString stereotype = m_umlObject->stereotype(); if (!stereotype.isEmpty()) { painter->drawText(0, bodyOffsetY + (bodyHeight/2) - fontHeight, bodyWidth, fontHeight, Qt::AlignCenter, m_umlObject->stereotype(true)); lines = 2; } } if (UMLWidget::isInstance()) { font.setUnderline(true); painter->setFont(font); nameStr = UMLWidget::instanceName() + QLatin1String(" : ") + nameStr; } if (lines == 1) { painter->drawText(0, bodyOffsetY + (bodyHeight/2) - (fontHeight/2), bodyWidth, fontHeight, Qt::AlignCenter, nameStr); } else { painter->drawText(0, bodyOffsetY + (bodyHeight/2), bodyWidth, fontHeight, Qt::AlignCenter, nameStr); } UMLWidget::paint(painter, option, widget); }
void CreateBlogMsg::setupTextActions() { QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon(":/images/textedit/textbold.png"),tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); //actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); ui.toolBar_2->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon(":/images/textedit/textitalic.png"),tr("&Italic"), this); //actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); ui.toolBar_2->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon(":/images/textedit/textunder.png"),tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); //actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); ui.toolBar_2->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"),tr("&Left"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); //actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); //actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); //actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); //actionAlignJustify->setPriority(QAction::LowPriority); ui.toolBar_2->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Text Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); ui.toolBar_2->addAction(actionTextColor); menu->addAction(actionTextColor); menu->addAction(ui.actionOrderedlist); menu->addAction(ui.actionUnorderedlist); menu->addAction(ui.actionBlockquoute); /*comboStyle = new QComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboStyle); comboStyle->addItem("Paragraph"); comboStyle->addItem("Heading 1"); comboStyle->addItem("Heading 2"); comboStyle->addItem("Heading 3"); comboStyle->addItem("Heading 4"); comboStyle->addItem("Heading 5"); comboStyle->addItem("Heading 6"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(changeFormatType(int)));*/ comboFont = new QFontComboBox(ui.toolBar_2); ui.toolBar_2->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(ui.toolBar_2); comboSize->setObjectName("comboSize"); ui.toolBar_2->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
//---------------------------------------------------------------------------------------------------------------------- // CTRNNNeuronViz implementation //---------------------------------------------------------------------------------------------------------------------- void CTRNNNeuronViz::update() { glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glDisable(GL_CULL_FACE); int N = m_ctrnn->getSize(); // left upper corner of circle's bounding box at 0,0: const float segmentSize = TWO_PI / N; const float networkRadius = m_width / 2.5; const float neuronRadius = networkRadius / N; glPushMatrix(); glMultMatrixf(*m_pTM); // connectivity if(m_renderConnections) { for(int i = 0; i < N; i++) { float angle = -((float)i + 0.5f) * segmentSize + PI_OVER_TWO; Vec3f midPoint (networkRadius * cosf(angle), networkRadius * sinf(angle), 0.0f); // draw only the selected neuron's connections if(i == m_selected || m_selected == -1) { // draw connections for(int j = 0; j < N; j++) { const double eps = 0.001; const float weight = m_ctrnn->getWeight(j,i); if(fabs(weight) > eps) { float otherAngle = -((float)j + 0.5f) * segmentSize + PI_OVER_TWO; Vec3f otherMidPoint (networkRadius * cosf(otherAngle), networkRadius * sinf(otherAngle), 0.0f); glLineWidth(fabs(weight)); if(weight < 0) glColor3f(235.0/255.0, 0.0/255.0, 103.0/255.0); else glColor3f(0,0,0); ci::gl::drawLine(midPoint, otherMidPoint); } } // render text if(m_renderText && i == m_selected) { // box glColor4f(0,0,0, 0.5f); const float lineHeight = 13; const float padding = 3; const float textBoxH = 3 * lineHeight + 2 * padding; ci::Vec2f textBoxPos = ci::Vec2f(&midPoint.x); ci::gl::drawSolidRect(ci::Rectf(textBoxPos.x, textBoxPos.y, textBoxPos.x + m_width, textBoxPos.y + textBoxH)); // text ci::Color textColor(1,1,1); ci::Vec2f textPos = textBoxPos + ci::Vec2f(padding, padding); char str [128]; sprintf(str, "Node: %i", i); ci::gl::drawString(str, textPos, textColor, m_font); sprintf(str, "b: %2.2f | t: %2.2f | g: %2.2f", m_ctrnn->getBias(i), m_ctrnn->getTimeConstant(i), m_ctrnn->getGain(i)); ci::gl::drawString(str, textPos + ci::Vec2f(0, lineHeight), textColor, m_font); sprintf(str, "in: %1.3f | out: %1.3f", m_ctrnn->getExternalInput(i), m_ctrnn->getOutput(i)); ci::gl::drawString(str, textPos + ci::Vec2f(0, 2 * lineHeight), textColor, m_font); } } } } glLineWidth(1.0f); float outerRadius = neuronRadius + (neuronRadius * 0.5); for(int i = 0; i < N; i++) { ci::Color col = m_ctrnn->getState(i) > 0 ? ci::Color(0,0,0) : ci::Color(235.0/255.0, 0.0/255.0, 103.0/255.0); float angle = -((float)i + 0.5f) * segmentSize + PI_OVER_TWO; Vec3f midPoint (networkRadius * cosf(angle), networkRadius * sinf(angle), 0.0f); glPushMatrix(); glTranslatef(midPoint); // white background glColor3f(1,1,1); drawDisk(outerRadius, 0.0, 32, 1); ci::gl::color(col); // disk size indicating output value drawDisk(neuronRadius * clamp(m_ctrnn->getOutput(i),0.0,1.0), 0.0, 32, 1); // ring size indicating external input value glColor3f(181.0/255.0, 206.0/255.0, 26.0/255.0); float width = radiansToDegrees(m_ctrnn->getExternalInput(i) * TWO_PI); dmx::drawPartialDisk(neuronRadius, outerRadius, 32, 1, 0, width, GLU_FILL); glColor3f(0,0,0); ci::gl::drawStrokedCircle(ci::Vec2f(0,0), outerRadius, 32); ci::gl::drawStrokedCircle(ci::Vec2f(0,0), neuronRadius, 32); glPopMatrix(); } glPopMatrix(); glPopAttrib(); }
void errorSearchChoice(void) { textColor(12 * 16); gotoxy(0, 28); printf(" Warning: 1 ~ 4번 사이의 숫자를 입력하세요 "); textColor(7); }
void SkyLine::draw(StelCore *core) const { if (!fader.getInterstate()) return; StelProjectorP prj = core->getProjection(frameType, frameType!=StelCore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff); // Get the bounding halfspace const SphericalCap& viewPortSphericalCap = prj->getBoundingCap(); // Initialize a painter and set openGL state StelPainter sPainter(prj); sPainter.setColor(color[0], color[1], color[2], fader.getInterstate()); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glEnable(GL_LINE_SMOOTH); #endif Vec4f textColor(color[0], color[1], color[2], 0); textColor[3]=fader.getInterstate(); ViewportEdgeIntersectCallbackData userData(&sPainter); sPainter.setFont(font); userData.textColor = textColor; userData.text = label; ///////////////////////////////////////////////// // Draw the line // Precession circles are Small Circles, all others are Great Circles. if (line_type==PRECESSIONCIRCLE_N || line_type==PRECESSIONCIRCLE_S) { const double lat=(line_type==PRECESSIONCIRCLE_S ? -1.0 : 1.0) * (M_PI/2.0-getPrecessionAngleVondrakCurrentEpsilonA()); SphericalCap declinationCap(Vec3d(0,0,1), std::sin(lat)); const Vec3d rotCenter(0,0,declinationCap.d); Vec3d p1, p2; if (!SphericalCap::intersectionPoints(viewPortSphericalCap, declinationCap, p1, p2)) { if ((viewPortSphericalCap.d<declinationCap.d && viewPortSphericalCap.contains(declinationCap.n)) || (viewPortSphericalCap.d<-declinationCap.d && viewPortSphericalCap.contains(-declinationCap.n))) { // The line is fully included in the viewport, draw it in 3 sub-arcs to avoid length > 180. Vec3d pt1; Vec3d pt2; Vec3d pt3; const double lon1=0.0; const double lon2=120.0*M_PI/180.0; const double lon3=240.0*M_PI/180.0; StelUtils::spheToRect(lon1, lat, pt1); pt1.normalize(); StelUtils::spheToRect(lon2, lat, pt2); pt2.normalize(); StelUtils::spheToRect(lon3, lat, pt3); pt3.normalize(); sPainter.drawSmallCircleArc(pt1, pt2, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(pt2, pt3, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(pt3, pt1, rotCenter, viewportEdgeIntersectCallback, &userData); #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); return; } else { #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); return; } } // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg Vec3d middlePoint = p1-rotCenter+p2-rotCenter; middlePoint.normalize(); middlePoint*=(p1-rotCenter).length(); middlePoint+=rotCenter; if (!viewPortSphericalCap.contains(middlePoint)) { middlePoint-=rotCenter; middlePoint*=-1.; middlePoint+=rotCenter; } sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter,viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, viewportEdgeIntersectCallback, &userData); // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); return; } // All the other "lines" are Great Circles SphericalCap meridianSphericalCap(Vec3d(0,0,1), 0); Vec3d fpt(1,0,0); if ((line_type==MERIDIAN) || (line_type==COLURE_1)) { meridianSphericalCap.n.set(0,1,0); } if ((line_type==PRIME_VERTICAL) || (line_type==COLURE_2)) { meridianSphericalCap.n.set(1,0,0); fpt.set(0,0,1); } if (line_type==LONGITUDE) { Vec3d coord; double lambda, beta; StelUtils::rectToSphe(&lambda, &beta, core->getCurrentPlanet()->getHeliocentricEclipticPos()); StelUtils::spheToRect(lambda + M_PI/2., 0., coord); meridianSphericalCap.n.set(coord[0],coord[1],coord[2]); fpt.set(0,0,1); } Vec3d p1, p2; if (!SphericalCap::intersectionPoints(viewPortSphericalCap, meridianSphericalCap, p1, p2)) { if ((viewPortSphericalCap.d<meridianSphericalCap.d && viewPortSphericalCap.contains(meridianSphericalCap.n)) || (viewPortSphericalCap.d<-meridianSphericalCap.d && viewPortSphericalCap.contains(-meridianSphericalCap.n))) { // The meridian is fully included in the viewport, draw it in 3 sub-arcs to avoid length > 180. const Mat4d& rotLon120 = Mat4d::rotation(meridianSphericalCap.n, 120.*M_PI/180.); Vec3d rotFpt=fpt; rotFpt.transfo4d(rotLon120); Vec3d rotFpt2=rotFpt; rotFpt2.transfo4d(rotLon120); sPainter.drawGreatCircleArc(fpt, rotFpt, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt, rotFpt2, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt2, fpt, NULL, viewportEdgeIntersectCallback, &userData); return; } else return; } Vec3d middlePoint = p1+p2; middlePoint.normalize(); if (!viewPortSphericalCap.contains(middlePoint)) middlePoint*=-1.; // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); // // Johannes: use a big radius as a dirty workaround for the bug that the // // ecliptic line is not drawn around the observer, but around the sun: // const Vec3d vv(1000000,0,0); }
static int32_t showResultsRequestSense(void* addr) { uint32_t Valid = getField(addr, 0, 7, 1); // byte 0, bit 7 uint32_t ResponseCode = getField(addr, 0, 0, 7); // byte 0, bit 6:0 uint32_t SenseKey = getField(addr, 2, 0, 4); // byte 2, bit 3:0 textColor(IMPORTANT); printf("\n\nResults of \"request sense\":\n"); if (ResponseCode >= 0x70 && ResponseCode <= 0x73) { textColor(TEXT); printf("Valid:\t\t"); if (Valid == 0) { printf("Sense data are not SCSI compliant"); } else { printf("Sense data are SCSI compliant"); } printf("\nResponse Code:\t"); switch (ResponseCode) { case 0x70: printf("Current errors, fixed format"); break; case 0x71: printf("Deferred errors, fixed format"); break; case 0x72: printf("Current error, descriptor format"); break; case 0x73: printf("Deferred error, descriptor format"); break; default: printf("No valid response code!"); break; } static const char* const SenseKeys[] = { "No Sense", "Recovered Error - last command completed with some recovery action", "Not Ready - logical unit addressed cannot be accessed", "Medium Error - command terminated with a non-recovered error condition", "Hardware Error", "Illegal Request - illegal parameter in the command descriptor block", "Unit Attention - disc drive may have been reset.", "Data Protect - command read/write on a protected block", "not defined", "Firmware Error", "not defined", "Aborted Command - disc drive aborted the command", "Equal - SEARCH DATA command has satisfied an equal comparison", "Volume Overflow - buffered peripheral device has reached the end of medium partition", "Miscompare - source data did not match the data read from the medium", "not defined" }; printf("\nSense Key:\t"); if(SenseKey < sizeof(SenseKeys)) puts(SenseKeys[SenseKey]); else printf("sense key not known!"); return SenseKey; } textColor(ERROR); printf("No vaild response code!"); textColor(TEXT); return -1; }
void BpDocument::composeFireCharacteristicsDiagram( void ) { // Surface Module must be active and using fuel model inputs PropertyDict *prop = m_eqTree->m_propDict; if ( ! prop->boolean( "surfaceModuleActive" ) || ! prop->boolean( "surfaceCalcFireCharacteristicsDiagram" ) ) { return; } // Graph fonts. QFont textFont( property()->string( "graphTextFontFamily" ), property()->integer( "graphTextFontSize" ) ); QColor textColor( property()->color( "graphTextFontColor" ) ); QPen textPen( textColor ); QFont subTitleFont( property()->string( "graphSubtitleFontFamily" ), property()->integer( "graphSubtitleFontSize" ) ); QColor subTitleColor( property()->color( "graphSubtitleFontColor" ) ); // Open the result file QString resultFile = m_eqTree->m_resultFile; FILE *fptr = 0; if ( ! ( fptr = fopen( resultFile.latin1(), "r" ) ) ) // This code block should never be executed! { QString text(""); translate( text, "BpDocument:FireCharacteristicsDiagram:NoLogOpen", resultFile ); error( text ); return; } // Allocate ros and hpua data arrays int rows = tableRows(); int cols = tableCols(); int cells = rows * cols; double *hpua = new double[ cells ]; checkmem( __FILE__, __LINE__, hpua, "double hpua", cells ); double *ros = new double[ cells ]; checkmem( __FILE__, __LINE__, ros, "double ros", cells ); // Set the variable names we're looking for const char* hpuaName = "vSurfaceFireHeatPerUnitArea"; const char* rosName = "vSurfaceFireSpreadAtHead"; if ( prop->boolean( "surfaceConfSpreadDirInput" ) ) { rosName = "vSurfaceFireSpreadAtVector"; } // Read and store the ros and hpua values char buffer[1024], varName[128], varUnits[128]; int row, col, cell; double value; double rosMax = 0.0; double hpuaMax = 0.0; while ( fgets( buffer, sizeof(buffer), fptr ) ) { if ( strncmp( buffer, "CELL", 4 ) == 0 ) { if ( strstr( buffer, hpuaName ) ) { sscanf( buffer, "CELL %d %d %s cont %lf %s", &row, &col, varName, &value, varUnits ); cell = ( col - 1 ) + ( cols * ( row - 1) ); if ( ( hpua[ cell ] = value ) > hpuaMax ) { hpuaMax = value; } } else if ( strstr( buffer, rosName ) ) { sscanf( buffer, "CELL %d %d %s cont %lf %s", &row, &col, varName, &value, varUnits ); cell = ( col - 1 ) + ( cols * ( row - 1) ); if ( ( ros[ cell ] = value ) > rosMax ) { rosMax = value; } } } } fclose( fptr ); // Get variable pointers EqVar *hpuaVar = m_eqTree->m_varDict->find( "vSurfaceFireHeatPerUnitArea" ); EqVar *rosVar = m_eqTree->m_varDict->find( "vSurfaceFireSpreadAtHead" ); EqVar *fliVar = m_eqTree->m_varDict->find( "vSurfaceFireLineIntAtHead" ); EqVar *flVar = m_eqTree->m_varDict->find( "vSurfaceFireFlameLengAtHead" ); // Conversion factor double flFactor, fliFactor, rosFactor, hpuaFactor, offset; appSiUnits()->conversionFactorOffset( flVar->m_nativeUnits, flVar->m_displayUnits, &flFactor, &offset ); appSiUnits()->conversionFactorOffset( fliVar->m_nativeUnits, fliVar->m_displayUnits, &fliFactor, &offset ); appSiUnits()->conversionFactorOffset( hpuaVar->m_nativeUnits, hpuaVar->m_displayUnits, &hpuaFactor, &offset ); appSiUnits()->conversionFactorOffset( rosVar->m_nativeUnits, rosVar->m_displayUnits, &rosFactor, &offset ); // Determine which of four different chart scales to use static const int Scales = 4; static double RosScale[Scales] = { 100., 200., 400., 800. }; // ft/min static double HpuaScale[Scales] = { 2000., 4000., 8000., 16000. }; // Btu/ft2 double rosScale = 0.; // Max y-axis ros double hpuaScale = 0.; // Max x-axis hpua int scale; for ( scale=0; scale<Scales; scale++ ) { if ( rosMax < ( rosScale = RosScale[ scale ] ) ) { break; } } for ( scale=0; scale<Scales; scale++ ) { if ( hpuaMax < ( hpuaScale = HpuaScale[scale] ) ) { break; } } // Set axis maximums to appropriate predefined scale in display units rosMax = rosFactor * rosScale; hpuaMax = hpuaFactor * hpuaScale; double ratio = rosMax / hpuaMax; // Create the graph Graph graph; GraphLine *graphLine; GraphMarker *graphMarker; static const int Points = 100; double l_x[Points]; double l_y[Points]; // Draw the four standard hauling chart fli-fl levels static const int Lines = 4; static const double Fli[Lines] = { 100., 500., 1000., 2000. }; // Btu/ft/s static const double Fl[Lines] = { 4., 8., 11., 15. }; // ft // Create the hauling chart lines // Put Fireline Int label 65% of the way along the HPUA axis (display units) double xPosFli = 0.65 * hpuaMax; // Put Flame Length label 85% of the way along the HPUA axis (display units) double xPosFl = 0.85 * hpuaMax; // Fireline Int and Flame Length label Y positions (display units) double yPosFl[Lines], yPosFli[Lines]; // Icon locations (in display units) double xIcon[Lines+1], yIcon[Lines+1]; double diff, minDiff; QString label; QPen redPen( "red", 1 ); QColor blackColor( "black" ); int alignCenter = Qt::AlignHCenter | Qt::AlignVCenter; // Fireline intensity - flame length curves int line, point; for ( line = 0; line < Lines; line++ ) { minDiff = 999999999.; for ( point = 0; point < Points; point++ ) { // Hpua value in native units (Btu/ft2) l_x[point] = ( (point+1) * hpuaScale ) / (double) Points; // Ros value in native units (ft/min) l_y[point] = 60. * Fli[line] / l_x[point]; // Convert to display units l_x[point] *= hpuaFactor; l_y[point] *= rosFactor; // Check for curve inflection point (for icon placement) if ( ( diff = fabs( l_y[point]/l_x[point] - ratio ) ) < minDiff ) { minDiff = diff; xIcon[line+1] = l_x[point]; yIcon[line+1] = l_y[point]; } } // Create a graph line (with its own copy of the data). graphLine = graph.addGraphLine( Points, l_x, l_y, redPen ); // Fireline intensity label label = QString( "%1" ).arg( ( Fli[line] * fliFactor ), 0, 'f', 0 ); yPosFli[line] = rosFactor * ( 60. * Fli[line] / ( xPosFli / hpuaFactor ) ); graph.addGraphMarker( xPosFli, yPosFli[line], label, textFont, blackColor, alignCenter ); // Flame length label label = QString( "%1" ).arg( ( Fl[line] * flFactor ), 0, 'f', 0 ); yPosFl[line] = rosFactor * ( 60. * Fli[line] / ( xPosFl / hpuaFactor ) ); graph.addGraphMarker( xPosFl, yPosFl[line], label, textFont, blackColor, alignCenter ); } // Next line // Fireline intensity label and units translate( label, "BpDocument:FireCharacteristicsDiagram:FLI" ); graph.addGraphMarker( xPosFli, ( yPosFli[Lines-1] + 0.10 * rosMax ), label, textFont, blackColor, alignCenter ); graph.addGraphMarker( xPosFli, ( yPosFli[Lines-1] + 0.05 * rosMax ), fliVar->m_displayUnits, textFont, blackColor, alignCenter ); // Flame length label and units translate( label, "BpDocument:FireCharacteristicsDiagram:FL" ); graph.addGraphMarker( xPosFl, ( yPosFl[Lines-1] + 0.10 * rosMax ), label, textFont, blackColor, alignCenter ); graph.addGraphMarker( xPosFl, ( yPosFl[Lines-1] + 0.05 * rosMax ), flVar->m_displayUnits, textFont, blackColor, alignCenter ); // Add icons QPixmap pixmap[Lines]; pixmap[0] = QPixmap( fireman_xpm ); pixmap[1] = QPixmap( dozer_xpm ); pixmap[2] = QPixmap( torchtree_xpm ); pixmap[3] = QPixmap( mtnfire_xpm ); xIcon[0] = yIcon[0] = 0.0; for ( line=0; line<Lines; line++ ) { graphMarker = graph.addGraphMarker( xIcon[line] + ( 0.5 * ( xIcon[line+1] - xIcon[line] ) ), yIcon[line] + ( 0.5 * ( yIcon[line+1] - yIcon[line] ) ), "", textFont, blackColor, alignCenter ); graphMarker->setGraphMarkerPixmap( pixmap[line] ); } // Finally, add a marker for each output result QColor bluePen( "blue" ); for ( cell=0; cell<cells; cell++ ) { //fprintf( stderr, "%02d: %3.2f %3.2f\n", i, hpua[i], ros[i] ); graph.addGraphMarker( hpua[cell], ros[cell], QString( "%1" ).arg( cell + 1 ), textFont, bluePen, alignCenter ); } // Compose the graph EqVar *zVar = 0; GraphAxleParms xParms( 0.0, hpuaMax, 11 ); GraphAxleParms yParms( 0.0, rosMax, 11 ); composeGraphBasics( &graph, true, hpuaVar, rosVar, zVar, Lines, &xParms, &yParms ); // Create a separate page for this graph. translate( label, "BpDocument:FireCharacteristicsDiagram:Caption" ); graph.setSubTitle( label, subTitleFont, subTitleColor ); startNewPage( label, TocHaulChart ); // This is how we save the graph and its composer. m_composer->graph( graph, m_pageSize->m_marginLeft + m_pageSize->m_bodyWd * property()->real( "graphXOffset" ), m_pageSize->m_marginTop + m_pageSize->m_bodyHt * property()->real( "graphYOffset" ), m_pageSize->m_bodyWd * property()->real( "graphScaleWidth" ), m_pageSize->m_bodyHt * property()->real( "graphScaleHeight" ) ); // Be polite and stop the composer. m_composer->end(); delete[] ros; ros = 0; delete[] hpua; hpua = 0; return; }
Theme* Theme::create(const char* url) { GP_ASSERT(url); // Search theme cache first. for (size_t i = 0, count = __themeCache.size(); i < count; ++i) { Theme* t = __themeCache[i]; if (t->_url == url) { // Found a match. t->addRef(); return t; } } // Load theme properties from file path. Properties* properties = Properties::create(url); GP_ASSERT(properties); if (properties == NULL) { return NULL; } // Check if the Properties is valid and has a valid namespace. Properties* themeProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace(); GP_ASSERT(themeProperties); if (!themeProperties || !(strcmp(themeProperties->getNamespace(), "theme") == 0)) { SAFE_DELETE(properties); return NULL; } // Create a new theme. Theme* theme = new Theme(); theme->_url = url; // Parse the Properties object and set up the theme. const char* textureFile = themeProperties->getString("texture"); theme->_texture = Texture::create(textureFile, false); GP_ASSERT(theme->_texture); theme->_spriteBatch = SpriteBatch::create(theme->_texture); GP_ASSERT(theme->_spriteBatch); theme->_spriteBatch->getSampler()->setFilterMode(Texture::NEAREST, Texture::NEAREST); float tw = 1.0f / theme->_texture->getWidth(); float th = 1.0f / theme->_texture->getHeight(); Properties* space = themeProperties->getNextNamespace(); while (space != NULL) { // First load all cursors, checkboxes etc. that can be referred to by styles. const char* spacename = space->getNamespace(); if (strcmp(spacename, "image") == 0) { theme->_images.push_back(ThemeImage::create(tw, th, space, Vector4::one())); } else if (strcmp(spacename, "imageList") == 0) { theme->_imageLists.push_back(ImageList::create(tw, th, space)); } else if (strcmp(spacename, "skin") == 0) { Theme::Border border; Properties* innerSpace = space->getNextNamespace(); if (innerSpace) { const char* innerSpacename = innerSpace->getNamespace(); if (strcmp(innerSpacename, "border") == 0) { border.top = innerSpace->getFloat("top"); border.bottom = innerSpace->getFloat("bottom"); border.left = innerSpace->getFloat("left"); border.right = innerSpace->getFloat("right"); } } Vector4 regionVector; space->getVector4("region", ®ionVector); const Rectangle region(regionVector.x, regionVector.y, regionVector.z, regionVector.w); Vector4 color(1, 1, 1, 1); if (space->exists("color")) { space->getColor("color", &color); } Skin* skin = Skin::create(space->getId(), tw, th, region, border, color); GP_ASSERT(skin); theme->_skins.push_back(skin); } space = themeProperties->getNextNamespace(); } themeProperties->rewind(); space = themeProperties->getNextNamespace(); while (space != NULL) { const char* spacename = space->getNamespace(); if (strcmp(spacename, "style") == 0) { // Each style contains up to MAX_OVERLAYS overlays, // as well as Border and Padding namespaces. Theme::Margin margin; Theme::Padding padding; Theme::Style::Overlay* normal = NULL; Theme::Style::Overlay* focus = NULL; Theme::Style::Overlay* active = NULL; Theme::Style::Overlay* disabled = NULL; Theme::Style::Overlay* hover = NULL; // Need to load OVERLAY_NORMAL first so that the other overlays can inherit from it. Properties* innerSpace = space->getNextNamespace(); while (innerSpace != NULL) { const char* innerSpacename = innerSpace->getNamespace(); if (strcmp(innerSpacename, "stateNormal") == 0) { Vector4 textColor(0, 0, 0, 1); if (innerSpace->exists("textColor")) { innerSpace->getColor("textColor", &textColor); } const char* fontPath = innerSpace->getString("font"); Font* font = NULL; if (fontPath) { font = Font::create(fontPath); } unsigned int fontSize = innerSpace->getInt("fontSize"); const char* textAlignmentString = innerSpace->getString("textAlignment"); Font::Justify textAlignment = Font::ALIGN_TOP_LEFT; if (textAlignmentString) { textAlignment = Font::getJustify(textAlignmentString); } bool rightToLeft = innerSpace->getBool("rightToLeft"); float opacity = 1.0f; if (innerSpace->exists("opacity")) { opacity = innerSpace->getFloat("opacity"); } ImageList* imageList = NULL; ThemeImage* cursor = NULL; Skin* skin = NULL; theme->lookUpSprites(innerSpace, &imageList, &cursor, &skin); normal = Theme::Style::Overlay::create(); GP_ASSERT(normal); normal->setSkin(skin); normal->setCursor(cursor); normal->setImageList(imageList); normal->setTextColor(textColor); normal->setFont(font); normal->setFontSize(fontSize); normal->setTextAlignment(textAlignment); normal->setTextRightToLeft(rightToLeft); normal->setOpacity(opacity); if (font) { theme->_fonts.insert(font); font->release(); } // Done with this pass. break; } innerSpace = space->getNextNamespace(); } // At least the OVERLAY_NORMAL is required. if (!normal) GP_ERROR("All themes require the normal state overlay to be defined."); space->rewind(); innerSpace = space->getNextNamespace(); while (innerSpace != NULL) { const char* innerSpacename = innerSpace->getNamespace(); if (strcmp(innerSpacename, "margin") == 0) { margin.top = innerSpace->getFloat("top"); margin.bottom = innerSpace->getFloat("bottom"); margin.left = innerSpace->getFloat("left"); margin.right = innerSpace->getFloat("right"); } else if (strcmp(innerSpacename, "padding") == 0) { padding.top = innerSpace->getFloat("top"); padding.bottom = innerSpace->getFloat("bottom"); padding.left = innerSpace->getFloat("left"); padding.right = innerSpace->getFloat("right"); } else if (strcmp(innerSpacename, "stateNormal") != 0) { // Either OVERLAY_FOCUS or OVERLAY_ACTIVE. // If a property isn't specified, it inherits from OVERLAY_NORMAL. Vector4 textColor; if (!innerSpace->getColor("textColor", &textColor)) { textColor.set(normal->getTextColor()); } const char* fontPath = innerSpace->getString("font"); Font* font = NULL; if (fontPath) { font = Font::create(fontPath); } if (!font) { font = normal->getFont(); if (font) font->addRef(); } unsigned int fontSize; if (innerSpace->exists("fontSize")) { fontSize = innerSpace->getInt("fontSize"); } else { fontSize = normal->getFontSize(); } const char* textAlignmentString = innerSpace->getString("textAlignment"); Font::Justify textAlignment; if (textAlignmentString) { textAlignment = Font::getJustify(textAlignmentString); } else { textAlignment = normal->getTextAlignment(); } bool rightToLeft; if (innerSpace->exists("rightToLeft")) { rightToLeft = innerSpace->getBool("rightToLeft"); } else { rightToLeft = normal->getTextRightToLeft(); } float opacity; if (innerSpace->exists("opacity")) { opacity = innerSpace->getFloat("opacity"); } else { opacity = normal->getOpacity(); } ImageList* imageList = NULL; ThemeImage* cursor = NULL; Skin* skin = NULL; theme->lookUpSprites(innerSpace, &imageList, &cursor, &skin); if (!imageList) { imageList = normal->getImageList(); } if (!cursor) { cursor = normal->getCursor(); } if (!skin) { skin = normal->getSkin(); } if (strcmp(innerSpacename, "stateFocus") == 0) { focus = Theme::Style::Overlay::create(); GP_ASSERT(focus); focus->setSkin(skin); focus->setCursor(cursor); focus->setImageList(imageList); focus->setTextColor(textColor); focus->setFont(font); focus->setFontSize(fontSize); focus->setTextAlignment(textAlignment); focus->setTextRightToLeft(rightToLeft); focus->setOpacity(opacity); if (font) { theme->_fonts.insert(font); font->release(); } } else if (strcmp(innerSpacename, "stateActive") == 0) { active = Theme::Style::Overlay::create(); GP_ASSERT(active); active->setSkin(skin); active->setCursor(cursor); active->setImageList(imageList); active->setTextColor(textColor); active->setFont(font); active->setFontSize(fontSize); active->setTextAlignment(textAlignment); active->setTextRightToLeft(rightToLeft); active->setOpacity(opacity); if (font) { theme->_fonts.insert(font); font->release(); } } else if (strcmp(innerSpacename, "stateDisabled") == 0) { disabled = Theme::Style::Overlay::create(); GP_ASSERT(disabled); disabled->setSkin(skin); disabled->setCursor(cursor); disabled->setImageList(imageList); disabled->setTextColor(textColor); disabled->setFont(font); disabled->setFontSize(fontSize); disabled->setTextAlignment(textAlignment); disabled->setTextRightToLeft(rightToLeft); disabled->setOpacity(opacity); if (font) { theme->_fonts.insert(font); font->release(); } } else if (strcmp(innerSpacename, "stateHover") == 0) { hover = Theme::Style::Overlay::create(); GP_ASSERT(hover); hover->setSkin(skin); hover->setCursor(cursor); hover->setImageList(imageList); hover->setTextColor(textColor); hover->setFont(font); hover->setFontSize(fontSize); hover->setTextAlignment(textAlignment); hover->setTextRightToLeft(rightToLeft); hover->setOpacity(opacity); if (font) { theme->_fonts.insert(font); font->release(); } } } innerSpace = space->getNextNamespace(); } if (!focus) { focus = normal; focus->addRef(); } if (!disabled) { disabled = normal; disabled->addRef(); } // Note: The hover and active states have their overlay left NULL if unspecified. // Events will still be triggered, but a control's overlay will not be changed. Theme::Style* s = new Theme::Style(theme, space->getId(), tw, th, margin, padding, normal, focus, active, disabled, hover); GP_ASSERT(s); theme->_styles.push_back(s); } space = themeProperties->getNextNamespace(); } // Add this theme to the cache. __themeCache.push_back(theme); SAFE_DELETE(properties); return theme; }
void SAGraphicsLabelItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->setRenderHints(painter->renderHints() | QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter->setFont(mShrift); QRectF r = rect(); r.setWidth(r.width() - 1); if (!mFone) { painter->setPen(mCvet); #if defined(Q_OS_UNIX) painter->drawText(r.adjusted(0, 5, 0, 0), mVyiravn, mPodpis); #elif defined(Q_OS_WIN) painter->drawText(r.adjusted(0, 0, 0, 0), mVyiravn, mPodpis); #endif return; } QColor bgColor(mCvet); bool black = bgColor == Qt::black; if (black) bgColor = QColor(30, 30, 30); QColor lighter1 = bgColor.lighter(black ? 400 : 200); QColor lighter2 = bgColor.lighter(black ? 320 : 120); QColor darker1 = bgColor.darker(115); QLinearGradient lgr(r.topLeft(), r.bottomLeft()); lgr.setColorAt(0, lighter1); lgr.setColorAt(0.4, darker1); lgr.setColorAt(0.6, darker1); lgr.setColorAt(1, lighter2); painter->setPen(bgColor); painter->setBrush(QBrush(lgr)); painter->drawRoundedRect(r, 3, 3); painter->setBrush(Qt::white); painter->setPen(QPen(Qt::white, 0.01)); painter->setOpacity(0.3); painter->drawRoundedRect(r.x(), r.y(), r.width(), r.height() / 2 - 2, 3, 3); painter->setPen(mCvet); painter->setBrush(QBrush(QColor(mCvet))); painter->setOpacity(1); QColor textColor(bgColor); if (mCvet == "#ffffff") textColor = Qt::darkRed; else if (mCvet == "#000000") textColor = QColor(240, 240, 240); else textColor = QColor(mCvet).darker(200); painter->setPen(textColor); #if defined(Q_OS_UNIX) painter->drawText(r.adjusted(0, 5, 0, 0), mVyiravn, mPodpis); #elif defined(Q_OS_WIN) painter->drawText(r.adjusted(0, 0, 0, 0), mVyiravn, mPodpis); #endif }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar(this); tb->setWindowTitle(tr("Format Actions")); addToolBar(tb); QMenu *menu = new QMenu(tr("F&ormat"), this); menuBar()->addMenu(menu); actionTextBold = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")), tr("&Bold"), this); actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B); actionTextBold->setPriority(QAction::LowPriority); QFont bold; bold.setBold(true); actionTextBold->setFont(bold); connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold())); tb->addAction(actionTextBold); menu->addAction(actionTextBold); actionTextBold->setCheckable(true); actionTextItalic = new QAction(QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png")), tr("&Italic"), this); actionTextItalic->setPriority(QAction::LowPriority); actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I); QFont italic; italic.setItalic(true); actionTextItalic->setFont(italic); connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic())); tb->addAction(actionTextItalic); menu->addAction(actionTextItalic); actionTextItalic->setCheckable(true); actionTextUnderline = new QAction(QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png")), tr("&Underline"), this); actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U); actionTextUnderline->setPriority(QAction::LowPriority); QFont underline; underline.setUnderline(true); actionTextUnderline->setFont(underline); connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline())); tb->addAction(actionTextUnderline); menu->addAction(actionTextUnderline); actionTextUnderline->setCheckable(true); menu->addSeparator(); QActionGroup *grp = new QActionGroup(this); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*))); // Make sure the alignLeft is always left of the alignRight if (QApplication::isLeftToRight()) { actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); } else { actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp); actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp); actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp); } actionAlignJustify = new QAction(QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png")), tr("&Justify"), grp); actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L); actionAlignLeft->setCheckable(true); actionAlignLeft->setPriority(QAction::LowPriority); actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E); actionAlignCenter->setCheckable(true); actionAlignCenter->setPriority(QAction::LowPriority); actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R); actionAlignRight->setCheckable(true); actionAlignRight->setPriority(QAction::LowPriority); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); actionAlignJustify->setPriority(QAction::LowPriority); tb->addActions(grp->actions()); menu->addActions(grp->actions()); menu->addSeparator(); QPixmap pix(16, 16); pix.fill(Qt::black); actionTextColor = new QAction(pix, tr("&Color..."), this); connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor())); tb->addAction(actionTextColor); menu->addAction(actionTextColor); tb = new QToolBar(this); tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); tb->setWindowTitle(tr("Format Actions")); addToolBarBreak(Qt::TopToolBarArea); addToolBar(tb); comboStyle = new QComboBox(tb); tb->addWidget(comboStyle); comboStyle->addItem("Standard"); comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); comboStyle->addItem("Ordered List (Roman lower)"); comboStyle->addItem("Ordered List (Roman upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); connect(comboFont, SIGNAL(activated(QString)), this, SLOT(textFamily(QString))); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); tb->addWidget(comboSize); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font() .pointSize()))); }
void FadePedal::paintEvent(QPaintEvent* /*event*/) { float lastValue = (m_Ticks.empty() ? 0 : m_Ticks.back().value); float angle = (35 * lastValue); QRectF r( rect() ); r.adjust(1, 1, -1, -1); QPainter painter; m_Canvas.fill(0); if( painter.begin(&m_Canvas) ) { painter.setRenderHints(QPainter::Antialiasing); float brightness = m_Click; if(m_Hover > 0) brightness += (m_Hover*0.2f); if( !m_Image.isNull() ) { painter.setOpacity(1.0-(brightness*0.5)); painter.drawPixmap( r.x() + qRound((r.width()-m_Image.width())*0.5), r.y() + qRound((r.height()-m_Image.height())*0.5), m_Image ); painter.setOpacity(1.0); } QColor brushColor( palette().color(QPalette::Button) ); if(m_Hover > 0) { qreal t = (brightness * BUTTON_BRIGHTESS); brushColor.setRedF( qMin(brushColor.redF()+t,1.0) ); brushColor.setGreenF( qMin(brushColor.greenF()+t,1.0) ); brushColor.setBlueF( qMin(brushColor.blueF()+t,1.0) ); } QColor lineColor(brushColor); Utils::MakeContrastingColor(1.0f, lineColor); if( !m_Image.isNull() ) { QPainterPath clip; clip.addRoundedRect(r, ROUNDED, ROUNDED); painter.setClipPath(clip); painter.drawPixmap( r.x() + qRound((r.width()-m_Image.width())*0.5), r.y() + qRound((r.height()-m_Image.height())*0.5), m_Image ); painter.setClipping(false); } painter.setBrush(brushColor); painter.setPen( QPen(lineColor,BORDER) ); painter.drawRoundedRect(r, ROUNDED, ROUNDED); if( m_Ticks.empty() ) m_Points.clear(); else m_Points.resize(m_Ticks.size() + 1); // end point if( !m_Points.empty() ) { float lineHeight = (r.height() * 0.8f); float lineX = (r.right() + HALF_BORDER); float lineY = (r.bottom() - 0.5f*(r.height()-lineHeight)); float lineWidth = (r.width() + BORDER); float toPercent = 1.0f/PEDAL_TIMEFRAME; for(size_t i=0; i<m_Ticks.size(); i++) { const sTick &t = m_Ticks[i]; QPointF &p = m_Points[i]; // end point float percent = (t.elapsed * toPercent); p.setX(lineX - lineWidth*percent); p.setY(lineY - lineHeight*t.value); } // end point m_Points[m_Points.size()-1] = QPointF(lineX, m_Points[m_Points.size()-2].y()); painter.drawPolyline(m_Points); } if(m_Hover > 0) { qreal dy = (-m_Hover * BUTTON_RAISE); if(dy != 0) r.adjust(0, 0, 0, dy); } QColor textColor( palette().color(QPalette::ButtonText) ); if( !isEnabled() ) textColor = textColor.darker(150); if( !text().isEmpty() ) { if( m_Label.isEmpty() ) { // just text centered painter.setFont( font() ); painter.setPen(textColor); painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap, text()); } else { // both text and label text QRectF textRect; painter.setFont( font() ); painter.setPen(textColor); painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontPrint, text(), &textRect); QRectF labelRect; painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap|Qt::TextDontPrint, m_Label, &labelRect); qreal h = (r.height() * 0.5 * (textRect.height()/labelRect.height())); painter.drawText(QRectF(r.x(),r.y(),r.width(),h), Qt::AlignCenter|Qt::TextWordWrap, text()); painter.drawText(QRectF(r.x(),r.y()+h,r.width(),r.height()-h), Qt::AlignCenter|Qt::TextWordWrap, m_Label); } } else if( !m_Label.isEmpty() ) { // just label text centered painter.setFont( font() ); painter.setPen(textColor); painter.drawText(r, Qt::AlignCenter|Qt::TextWordWrap, m_Label); } painter.end(); } if( painter.begin(this) ) { if(angle > 0.00001) { qreal center = (m_Canvas.width() * 0.5); QMatrix4x4 matrix; matrix.translate(-center, m_Canvas.height()); matrix.rotate(angle, 1.0, 0, 0); painter.translate(center, 0); painter.setTransform(matrix.toTransform(300.0), /*combine*/true); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.drawImage(0, -m_Canvas.height(), m_Canvas); } else painter.drawImage(0, 0, m_Canvas); painter.end(); } }
void SimpleText::draw(QPainter* p) const { p->setFont(textStyle().fontPx(spatium())); p->setBrush(Qt::NoBrush); p->setPen(textColor()); int rows = _layout.size(); if (_editMode && _cursor.hasSelection()) { int r1 = _cursor.selectLine; int r2 = _cursor.line; int c1 = _cursor.selectColumn; int c2 = _cursor.column; if (r1 > r2) { qSwap(r1, r2); qSwap(c1, c2); } else if (r1 == r2) { if (c1 > c2) qSwap(c1, c2); } for (int row = 0; row < rows; ++row) { const TLine& t = _layout.at(row); p->drawText(t.pos, t.text); if (row >= r1 && row <= r2) { QBrush bg(QColor("steelblue")); QFontMetricsF fm(_textStyle.fontPx(spatium())); QRectF br; if (row == r1 && r1 == r2) { QString left = t.text.left(c1); QString mid = t.text.mid(c1, c2 - c1); QString right = t.text.mid(c2); QPointF r (fm.width(left), 0.0); br = fm.boundingRect(mid).translated(t.pos + r); br.setWidth(fm.width(mid)); } else if (row == r1) { QString left = t.text.left(c1); QString right = t.text.mid(c1); QPointF r (fm.width(left), 0.0); br = fm.boundingRect(right).translated(t.pos + r); br.setWidth(fm.width(right)); } else if (row == r2) { QString left = t.text.left(c2); br = fm.boundingRect(left).translated(t.pos); br.setWidth(fm.width(left)); } else { br = fm.boundingRect(t.text).translated(t.pos); br.setWidth(fm.width(t.text)); } drawSelection(p, br); } } } else { for (int row = 0; row < rows; ++row) { const TLine& t = _layout.at(row); p->drawText(t.pos, t.text); } } if (_editMode) { p->setBrush(QColor("steelblue")); p->drawRect(cursorRect()); } }
static int checkSCSICommand(void* MSDStatus, usb_device_t* device, uint16_t TransferLength, uint8_t SCSIOpcode) { // CSW Status #ifdef _USB_DIAGNOSIS_ putch('\n'); memshow(MSDStatus,13, false); putch('\n'); #endif int error = 0; // check signature 0x53425355 // DWORD 0 (byte 0:3) uint32_t CSWsignature = *(uint32_t*)MSDStatus; // DWORD 0 if (CSWsignature == CSWMagicOK) { #ifdef _USB_DIAGNOSIS_ textColor(SUCCESS); printf("\nCSW signature OK "); textColor(TEXT); #endif } else if (CSWsignature == CSWMagicNotOK) { textColor(ERROR); printf("\nCSW signature wrong (not processed)"); textColor(TEXT); return -1; } else { textColor(ERROR); printf("\nCSW signature wrong (processed, but wrong value)"); textColor(TEXT); error = -2; } // check matching tag uint32_t CSWtag = *(((uint32_t*)MSDStatus)+1); // DWORD 1 (byte 4:7) if ((BYTE1(CSWtag) == SCSIOpcode) && (BYTE2(CSWtag) == 0x42) && (BYTE3(CSWtag) == 0x42) && (BYTE4(CSWtag) == 0x42)) { #ifdef _USB_DIAGNOSIS_ textColor(SUCCESS); printf("CSW tag %yh OK ",BYTE1(CSWtag)); textColor(TEXT); #endif } else { textColor(ERROR); printf("\nError: CSW tag wrong"); textColor(TEXT); error = -3; } // check CSWDataResidue uint32_t CSWDataResidue = *(((uint32_t*)MSDStatus)+2); // DWORD 2 (byte 8:11) if (CSWDataResidue == 0) { #ifdef _USB_DIAGNOSIS_ textColor(SUCCESS); printf("\tCSW data residue OK "); textColor(TEXT); #endif } else { textColor(0x06); printf("\nCSW data residue: %u", CSWDataResidue); textColor(TEXT); } // check status byte // DWORD 3 (byte 12) uint8_t CSWstatusByte = *(((uint8_t*)MSDStatus)+12); // byte 12 (last byte of 13 bytes) textColor(ERROR); switch (CSWstatusByte) { case 0x00: #ifdef _USB_DIAGNOSIS_ textColor(SUCCESS); printf("\tCSW status OK"); #endif break; case 0x01: printf("\nCommand failed"); error = -4; break; case 0x02: printf("\nPhase Error"); textColor(IMPORTANT); printf("\nReset recovery is needed"); usb_resetRecoveryMSD(device, device->numInterfaceMSD); error = -5; break; default: printf("\nCSW status byte: undefined value (error)"); error = -6; break; } textColor(TEXT); return error; }
// This takes a very naive approach to producing at 'C' in a contrasting // color. For a much more effective technique, see: // http://qt.nokia.com/doc/qq/qq26-adaptivecoloring.html QPixmap colorSwatch(const QColor &color, const QSize &size) { QString key = QString("COLORSWATCH:%1:%2x%3").arg(color.name()) .arg(size.width()).arg(size.height()); QPixmap pixmap(size); #if QT_VERSION >= 0x040600 if (!QPixmapCache::find(key, &pixmap)) { #else if (!QPixmapCache::find(key, pixmap)) { #endif pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHints(QPainter::Antialiasing| QPainter::TextAntialiasing); painter.setPen(Qt::NoPen); painter.setBrush(color); painter.drawEllipse(0, 0, size.width(), size.height()); if (size.width() > 32) { painter.setFont(QFont("Helvetica", qMax(8, size.height() - 6), QFont::Black)); QColor textColor(color.darker()); if (color.red() == color.green() && color.red() == color.blue()) textColor = (color.red() > 90 ? Qt::black : Qt::white); painter.setPen(textColor); painter.drawText( QRectF(0, 0, size.width(), size.height()), QObject::tr("C"), QTextOption(Qt::AlignCenter)); } painter.end(); QPixmapCache::insert(key, pixmap); } return pixmap; } QPixmap brushSwatch(const Qt::BrushStyle style, const QColor &color, const QSize &size) { QString key = QString("BRUSHSTYLESWATCH:%1:%2:%3x%4") .arg(static_cast<int>(style)).arg(color.name()) .arg(size.width()).arg(size.height()); QPixmap pixmap(size); #if QT_VERSION >= 0x040600 if (!QPixmapCache::find(key, &pixmap)) { #else if (!QPixmapCache::find(key, pixmap)) { #endif pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); painter.setBrush(QBrush(color, style)); painter.drawRect(0, 0, size.width(), size.height()); painter.end(); QPixmapCache::insert(key, pixmap); } return pixmap; } QPixmap penStyleSwatch(const Qt::PenStyle style, const QColor &color, const QSize &size) { QString key = QString("PENSTYLESWATCH:%1:%2:%3x%4") .arg(static_cast<int>(style)).arg(color.name()) .arg(size.width()).arg(size.height()); QPixmap pixmap(size); #if QT_VERSION >= 0x040600 if (!QPixmapCache::find(key, &pixmap)) { #else if (!QPixmapCache::find(key, pixmap)) { #endif pixmap.fill(Qt::transparent); QPainter painter(&pixmap); QPen pen(style); pen.setColor(color); pen.setWidth(2); painter.setPen(pen); const int Y = size.height() / 2; painter.drawLine(0, Y, size.width(), Y); painter.end(); QPixmapCache::insert(key, pixmap); } return pixmap; } QPixmap penCapSwatch(const Qt::PenCapStyle capStyle, const QColor &color, const QSize &size) { QString key = QString("PENCAPSTYLESWATCH:%1:%2:%3x%4") .arg(static_cast<int>(capStyle)).arg(color.name()) .arg(size.width()).arg(size.height()); QPixmap pixmap(size); #if QT_VERSION >= 0x040600 if (!QPixmapCache::find(key, &pixmap)) { #else if (!QPixmapCache::find(key, pixmap)) { #endif pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); QPen pen; pen.setCapStyle(Qt::SquareCap); pen.setWidthF(size.height() / 2.5); pen.setColor(Qt::white); painter.setPen(pen); const int Y = size.height() / 2; painter.drawLine(0, Y, size.width(), Y); pen.setColor(color); pen.setCapStyle(capStyle); painter.setPen(pen); painter.drawLine(size.width() / 2.5, Y, size.width(), Y); painter.end(); QPixmapCache::insert(key, pixmap); } return pixmap; } QPixmap penJoinSwatch(const Qt::PenJoinStyle joinStyle, const QColor &color, const QSize &size) { QString key = QString("PENJOINSTYLESWATCH:%1:%2:%3x%4") .arg(static_cast<int>(joinStyle)).arg(color.name()) .arg(size.width()).arg(size.height()); QPixmap pixmap(size); #if QT_VERSION >= 0x040600 if (!QPixmapCache::find(key, &pixmap)) { #else if (!QPixmapCache::find(key, pixmap)) { #endif const double Indent = size.width() / 5.0; QPolygonF polygon; polygon << QPointF(Indent, Indent) << QPointF(Indent, size.height() - Indent) << QPointF(size.width() - Indent, size.height() - Indent); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); QPen pen; pen.setJoinStyle(joinStyle); pen.setColor(color); pen.setWidthF(size.height() / 2.5); painter.setPen(pen); painter.drawPolyline(polygon); painter.end(); QPixmapCache::insert(key, pixmap); } return pixmap; }
/// cf. http://www.beyondlogic.org/usbnutshell/usb4.htm#Bulk void usb_sendSCSICommand(usb_device_t* device, uint32_t interface, uint32_t endpointOut, uint32_t endpointIn, uint8_t SCSIcommand, uint32_t LBA, uint16_t TransferLength, void* dataBuffer, void* statusBuffer) { #ifdef _USB_DIAGNOSIS_ printf("\nOUT part"); textColor(0x03); printf("\ntoggle OUT %u", device->ToggleEndpointOutMSD); textColor(TEXT); #endif struct usb_CommandBlockWrapper cbw; formatSCSICommand(SCSIcommand, &cbw, LBA, TransferLength); usb_transfer_t transfer; usb_setupTransfer(device->disk->port, &transfer, USB_BULK, endpointOut, 512); usb_outTransaction(&transfer, false, &cbw, 31); usb_issueTransfer(&transfer); if (SCSIcommand == 0x28 || SCSIcommand == 0x2A) // read(10) and write(10) { TransferLength *= 512; // byte = 512 * block } /**************************************************************************************************************************************/ #ifdef _USB_DIAGNOSIS_ printf("\nIN part"); #endif uint32_t timeout = 0; char tempStatusBuffer[13]; if(statusBuffer == 0) statusBuffer = tempStatusBuffer; usb_setupTransfer(device->disk->port, &transfer, USB_BULK, endpointIn, 512); if (TransferLength > 0) { usb_inTransaction(&transfer, false, dataBuffer, TransferLength); usb_inTransaction(&transfer, false, statusBuffer, 13); } else { usb_inTransaction(&transfer, false, statusBuffer, 13); } usb_issueTransfer(&transfer); #ifdef _USB_DIAGNOSIS_ if (TransferLength) // byte { putch('\n'); memshow(dataBuffer, TransferLength, false); putch('\n'); if ((TransferLength==512) || (TransferLength==36)) // data block (512 byte), inquiry feedback (36 byte) { memshow(dataBuffer, TransferLength, true); // alphanumeric putch('\n'); } } #endif if(checkSCSICommand(statusBuffer, device, TransferLength, SCSIcommand) != 0 && timeout < 5) { timeout++; } // TODO: Handle failure/timeout }
void seStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { #if 0 case CC_TitleBar: if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { painter->save(); bool active = (titleBar->titleBarState & State_Active); QRect fullRect = titleBar->rect; // ### use palette colors instead //QColor titleBarGradientStart(active ? 0x3b508a : 0x6e6e6e); //QColor titleBarGradientStop(active ? 0x5d6e9e : 0x818181); //QColor titleBarFrameBorder(0x393939); //QColor titleBarAlphaCorner(active ? 0x4b5e7f : 0x6a6a6a); //QColor titleBarInnerTopLine(active ? 0x8e98ba : 0xa4a4a4); //QColor titleBarInnerInnerTopLine(active ? 0x57699b : 0x808080); //QColor leftCorner(active ? 0x6f7ea8 : 0x8e8e8e); //QColor rightCorner(active ? 0x44537d : 0x676767); QColor textColor(active ? 0x282e40 : 0x282e40); QColor textAlphaColor(active ? 0x3f4862 : 0x3f4862); // max button if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && !(titleBar->titleBarState & Qt::WindowMaximized)) { bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); QImage image(Maximize_xpm); //qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); painter->drawImage(maxButtonRect, image); //int xoffset = maxButtonRect.width() / 3; //int yoffset = maxButtonRect.height() / 3; //QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset, // maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2); //painter->setPen(textColor); //painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); //painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, // maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); //painter->setPen(textAlphaColor); //const QPoint points[4] = { // maxButtonIconRect.topLeft(), maxButtonIconRect.topRight(), // maxButtonIconRect.bottomLeft(), maxButtonIconRect.bottomRight() }; //painter->drawPoints(points, 4); } // close button if (titleBar->subControls & SC_TitleBarCloseButton && titleBar->titleBarFlags & Qt::WindowSystemMenuHint) { bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); QImage image(Office2007_FrameCaptionClose23_xpm); //qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); painter->drawImage(closeButtonRect, image); //int xoffset = closeButtonRect.width() / 3; //int yoffset = closeButtonRect.height() / 3; //QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset, // closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2); //painter->setPen(textAlphaColor); //{ // const QLine lines[4] = { // QLine(closeIconRect.left() + 1, closeIconRect.top(), // closeIconRect.right(), closeIconRect.bottom() - 1), // QLine(closeIconRect.left(), closeIconRect.top() + 1, // closeIconRect.right() - 1, closeIconRect.bottom()), // QLine(closeIconRect.right() - 1, closeIconRect.top(), // closeIconRect.left(), closeIconRect.bottom() - 1), // QLine(closeIconRect.right(), closeIconRect.top() + 1, // closeIconRect.left() + 1, closeIconRect.bottom()) }; // painter->drawLines(lines, 4); // const QPoint points[4] = { // closeIconRect.topLeft(), closeIconRect.topRight(), // closeIconRect.bottomLeft(), closeIconRect.bottomRight() }; // painter->drawPoints(points, 4); //} //painter->setPen(textColor); //{ // const QLine lines[2] = { // QLine(closeIconRect.left() + 1, closeIconRect.top() + 1, // closeIconRect.right() - 1, closeIconRect.bottom() - 1), // QLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1, // closeIconRect.right() - 1, closeIconRect.top() + 1) }; // painter->drawLines(lines, 2); //} } // from qwindowsstyle.cpp if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { bool hover = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken); QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); if (hover) qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken); if (!titleBar->icon.isNull()) { titleBar->icon.paint(painter, iconRect); } else { QStyleOption tool(0); tool.palette = titleBar->palette; QPixmap pm = standardPixmap(SP_TitleBarMenuButton, &tool, widget); tool.rect = iconRect; painter->save(); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); painter->restore(); } } painter->restore(); } break; #endif default: QPlastiqueStyle::drawComplexControl(control, option, painter, widget); break; } }
void usb_setupDevice(usb_device_t* device, uint8_t address) { device->num = 0; // device number has to be set to 0 bool success = false; success = usb_getDeviceDescriptor(device); if (!success) { success = usb_getDeviceDescriptor(device); } if (!success) { textColor(ERROR); printf("\nSetup Device interrupted!"); textColor(TEXT); return; } waitForKeyStroke(); device->num = usb_setDeviceAddress(device->disk->port, address); success = usb_getConfigDescriptor(device); if (!success) { success = usb_getConfigDescriptor(device); } if (!success) { textColor(ERROR); printf("\nSetup Device interrupted!"); textColor(TEXT); return; } waitForKeyStroke(); usb_getStringDescriptor(device); waitForKeyStroke(); for (uint8_t i=1; i<4; i++) // fetch 3 strings { usb_getUnicodeStringDescriptor(device, i); waitForKeyStroke(); } usb_setConfiguration(device, 1); // set first configuration waitForKeyStroke(); #ifdef _USB_DIAGNOSIS_ uint8_t config = usb_getConfiguration(device); printf("\nconfiguration: %u", config); // check configuration waitForKeyStroke(); #endif if (device->InterfaceClass != 0x08) { textColor(ERROR); printf("\nThis is no Mass Storage Device! MSD test and addition to device manager will not be carried out."); textColor(TEXT); waitForKeyStroke(); } else { // Disk device->disk->type = &USB_MSD; device->disk->sectorSize = 512; strcpy(device->disk->name, device->productName); attachDisk(device->disk); #ifdef _USB_DIAGNOSIS_ showPortList(); // TEST showDiskList(); // TEST // device, interface, endpoints textColor(HEADLINE); printf("\n\nMSD test now with device: %X interface: %u endpOUT: %u endpIN: %u\n", device, device->numInterfaceMSD, device->numEndpointOutMSD, device->numEndpointInMSD); textColor(TEXT); #endif testMSD(device); // test with some SCSI commands } }
void csv(TString input="tmva.csvoutput.txt", TString par1="par2", TString par2="par3", TString par3="", TString value="eventEffScaled_5") { std::cout << "Usage:" << std::endl << ".x scripts/csv.C with default arguments" << std::endl << ".x scripts/csv.C(filename, par1, par2, value)" << std::endl << std::endl << " Optional arguments:" << std::endl << " filename path to CSV file" << std::endl << " par1 name of X-parameter branch" << std::endl << " par2 name of Y-parameter branch (if empty, efficiency is drawn as a function of par1)" << std::endl << " value name of result (efficiency) branch" << std::endl << std::endl; TTree *tree = new TTree("data", "data"); tree->ReadFile(input); gStyle->SetPalette(1); gStyle->SetPadRightMargin(0.14); TCanvas *canvas = new TCanvas("csvoutput", "CSV Output", 1200, 900); tree->SetMarkerStyle(kFullDotMedium); tree->SetMarkerColor(kRed); if(par2.Length() > 0) { //tree->Draw(Form("%s:%s", par2.Data(), par1.Data())); if(par3.Length() > 0) tree->Draw(Form("%s:%s:%s:%s", par1.Data(), par2.Data(), par3.Data(), value.Data()), "", "COLZ"); //, "", "Z"); else tree->Draw(Form("%s:%s:%s", par2.Data(), par1.Data(), value.Data()), "", "COLZ"); //, "", "Z"); TH1 *histo = tree->GetHistogram(); if(!histo) return; histo->SetTitle(Form("%s with different classifier parameters", value.Data())); histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data())); histo->GetYaxis()->SetTitle(Form("Classifier parameter %s", par2.Data())); if(par3.Length() > 0) histo->GetZaxis()->SetTitle(Form("Classifier parameter %s", par3.Data())); else histo->GetZaxis()->SetTitle(""); if(par3.Length() == 0) { float x = 0; float y = 0; float val = 0; double maxVal = tree->GetMaximum(value); double minVal = tree->GetMinimum(value); tree->SetBranchAddress(par1, &x); tree->SetBranchAddress(par2, &y); tree->SetBranchAddress(value, &val); TLatex l; l.SetTextSize(0.03); Long64_t nentries = tree->GetEntries(); for(Long64_t entry=0; entry < nentries; ++entry) { tree->GetEntry(entry); l.SetTextColor(textColor(val, maxVal, minVal)); l.DrawLatex(x, y, Form("%.3f", val*100)); } } } else { tree->Draw(Form("%s:%s", value.Data(), par1.Data())); TH1 *histo = tree->GetHistogram(); if(!histo) return; histo->SetTitle(Form("%s with different classifier parameters", value.Data())); histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data())); histo->GetYaxis()->SetTitle(value); } }
// http://en.wikipedia.org/wiki/SCSI_Inquiry_Command static void analyzeInquiry(void* addr) { // cf. Jan Axelson, USB Mass Storage, page 140 uint8_t PeripheralDeviceType = getField(addr, 0, 0, 5); // byte, shift, len // uint8_t PeripheralQualifier = getField(addr, 0, 5, 3); // uint8_t DeviceTypeModifier = getField(addr, 1, 0, 7); uint8_t RMB = getField(addr, 1, 7, 1); #ifdef _USB_DIAGNOSIS_ uint8_t ANSIapprovedVersion = getField(addr, 2, 0, 3); #endif // uint8_t ECMAversion = getField(addr, 2, 3, 3); // uint8_t ISOversion = getField(addr, 2, 6, 2); uint8_t ResponseDataFormat = getField(addr, 3, 0, 4); uint8_t HISUP = getField(addr, 3, 4, 1); uint8_t NORMACA = getField(addr, 3, 5, 1); // uint8_t AdditionalLength = getField(addr, 4, 0, 8); uint8_t CmdQue = getField(addr, 7, 1, 1); uint8_t Linked = getField(addr, 7, 3, 1); char vendorID[9]; memcpy(vendorID, addr+8, 8); vendorID[8]=0; char productID[17]; memcpy(productID, addr+16, 16); productID[16]=0; #ifdef _USB_DIAGNOSIS_ char productRevisionLevel[5]; memcpy(productRevisionLevel, addr+32, 4); productRevisionLevel[4]=0; #endif printf("\nVendor ID: %s", vendorID); printf("\nProduct ID: %s", productID); #ifdef _USB_DIAGNOSIS_ printf("\nRevision: %s", productRevisionLevel); // Book of Jan Axelson, "USB Mass Storage", page 140: // printf("\nVersion ANSI: %u ECMA: %u ISO: %u", ANSIapprovedVersion, ECMAversion, ISOversion); printf("\nVersion: %u (4: SPC-2, 5: SPC-3)", ANSIapprovedVersion); #endif // Jan Axelson, USB Mass Storage, page 140 if (ResponseDataFormat == 2) { textColor(SUCCESS); printf("\nResponse Data Format OK"); } else { textColor(ERROR); printf("\nResponse Data Format is not OK: %u (should be 2)", ResponseDataFormat); } textColor(TEXT); printf("\nRemovable device type: %s", RMB ? "yes" : "no"); printf("\nSupports hierarch. addr. support: %s", HISUP ? "yes" : "no"); printf("\nSupports normal ACA bit support: %s", NORMACA ? "yes" : "no"); printf("\nSupports linked commands: %s", Linked ? "yes" : "no"); printf("\nSupports tagged command queuing: %s", CmdQue ? "yes" : "no"); switch (PeripheralDeviceType) { case 0x00: printf("\ndirect-access device (e.g., magnetic disk)"); break; case 0x01: printf("\nsequential-access device (e.g., magnetic tape)"); break; case 0x02: printf("\nprinter device"); break; case 0x03: printf("\nprocessor device"); break; case 0x04: printf("\nwrite-once device"); break; case 0x05: printf("\nCD/DVD device"); break; case 0x06: printf("\nscanner device"); break; case 0x07: printf("\noptical memory device (non-CD optical disk)"); break; case 0x08: printf("\nmedium Changer (e.g. jukeboxes)"); break; case 0x09: printf("\ncommunications device"); break; case 0x0A: printf("\ndefined by ASC IT8 (Graphic arts pre-press devices)"); break; case 0x0B: printf("\ndefined by ASC IT8 (Graphic arts pre-press devices)"); break; case 0x0C: printf("\nStorage array controller device (e.g., RAID)"); break; case 0x0D: printf("\nEnclosure services device"); break; case 0x0E: printf("\nSimplified direct-access device (e.g., magnetic disk)"); break; case 0x0F: printf("\nOptical card reader/writer device"); break; case 0x10: printf("\nReserved for bridging expanders"); break; case 0x11: printf("\nObject-based Storage Device"); break; case 0x12: printf("\nAutomation/Drive Interface"); break; case 0x13: case 0x1D: printf("\nReserved"); break; case 0x1E: printf("\nReduced block command (RBC) direct-access device"); break; case 0x1F: printf("\nUnknown or no device type"); break; } }
void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) { //--------------------font chooser------------------------- m_fontFamilyChooser = new QFontComboBox(this); actions->addAction(CResMgr::displaywindows::writeWindow::fontFamily::actionName, m_fontFamilyChooser); m_fontFamilyChooser->setToolTip( tr("Font") ); bar->addWidget(m_fontFamilyChooser); bool ok = connect(m_fontFamilyChooser, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(slotFontFamilyChoosen(const QFont&))); Q_ASSERT(ok); //--------------------font size chooser------------------------- m_fontSizeChooser = new BtFontSizeWidget(this); m_fontSizeChooser->setToolTip( tr("Font size") ); bar->addWidget(m_fontSizeChooser); ok = connect(m_fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int))); Q_ASSERT(ok); //--------------------color button------------------------- m_colorChooser = new BtColorWidget(); m_colorChooser->setToolTip(tr("Font color")); bar->addWidget(m_colorChooser); ok = connect(m_colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&))); Q_ASSERT(ok); bar->addSeparator(); //--------------------bold toggle------------------------- m_actions.bold = new QAction( util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon), tr("Bold"), actions); m_actions.bold->setCheckable(true); m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel); actions->addAction(CResMgr::displaywindows::writeWindow::boldText::actionName, m_actions.bold); m_actions.bold->setToolTip( tr("Bold") ); connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool))); bar->addAction(m_actions.bold); //--------------------italic toggle------------------------- m_actions.italic = new QAction( util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon), tr("Italic"), actions ); m_actions.italic->setCheckable(true); m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel); actions->addAction(CResMgr::displaywindows::writeWindow::italicText::actionName, m_actions.italic); connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool))); m_actions.italic->setToolTip( tr("Italic") ); bar->addAction(m_actions.italic); //--------------------underline toggle------------------------- m_actions.underline = new QAction( util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon), tr("Underline"), actions ); m_actions.underline->setCheckable(true); m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel); actions->addAction(CResMgr::displaywindows::writeWindow::underlinedText::actionName, m_actions.underline); connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool))); m_actions.underline->setToolTip( tr("Underline") ); bar->addAction(m_actions.underline); //seperate formatting from alignment buttons bar->addSeparator(); //--------------------align left toggle------------------------- m_actions.alignLeft = new QAction( util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon), tr("Left"), actions); m_actions.alignLeft->setCheckable(true); m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel); actions->addAction(CResMgr::displaywindows::writeWindow::alignLeft::actionName, m_actions.alignLeft); connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool))); m_actions.alignLeft->setToolTip( tr("Align left") ); bar->addAction(m_actions.alignLeft); //--------------------align center toggle------------------------- m_actions.alignCenter = new QAction( util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon), tr("Center"), actions); m_actions.alignCenter->setCheckable(true); m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel); actions->addAction(CResMgr::displaywindows::writeWindow::alignCenter::actionName, m_actions.alignCenter); connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool))); m_actions.alignCenter->setToolTip( tr("Center") ); bar->addAction(m_actions.alignCenter); //--------------------align right toggle------------------------- m_actions.alignRight = new QAction( util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon), tr("Right"), actions); m_actions.alignRight->setCheckable(true); m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel); actions->addAction(CResMgr::displaywindows::writeWindow::alignRight::actionName, m_actions.alignRight); connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool))); m_actions.alignRight->setToolTip( tr("Align right") ); bar->addAction(m_actions.alignRight); connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&))); connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int))); connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&))); //set initial values for toolbar items slotFontChanged( font() ); slotAlignmentChanged( alignment() ); slotColorChanged( textColor() ); }
void video_test(void) { extern BMPInfo_t bmp_start; textColor(LIGHT_BLUE); printf(" >>>>> Press 's' to skip video test or any key to continue <<<<<\n\n"); textColor(TEXT); if (getch() == 's') { return; } video_install(); list_t* modelist = list_create(); video_createModeList(modelist); textColor(TABLE_HEADING); printf("\nID\tDriver\tResolution\tColor depth\tType\n"); puts("----------------------------------------------------------------------"); textColor(TEXT); size_t id = 0; for (dlelement_t* e = modelist->head; e != 0; e = e->next, id++) { videoMode_t* mode = e->data; printf("\n%u\t%s\t", id, mode->device->driver->driverName); if (printf("%ux%u\t", mode->xRes, mode->yRes) <= 8) putch('\t'); switch (mode->colorMode) { case CM_2COL: puts("2 colors"); break; case CM_16COL: puts("16 colors"); break; case CM_256COL: puts("256 colors"); break; case CM_15BIT: puts("15 bit\t"); break; case CM_16BIT: puts("16 bit\t"); break; case CM_24BIT: puts("24 bit\t"); break; case CM_32BIT: puts("32 bit\t"); break; } printf("\t%s", mode->type==VMT_GRAPHIC?"Graphic":"Text"); if (id % 40 == 0 && id != 0) waitForKeyStroke(); // Slow down } textColor(TABLE_HEADING); puts("\n----------------------------------------------------------------------\n\n"); textColor(TEXT); videoMode_t* mode = 0; while (true) { textColor(YELLOW); printf("Type in the ID of the mode: "); textColor(TEXT); char temp[20]; gets(temp); if (strcmp(temp, "exit") == 0) return; uint16_t modenumber = atoi(temp); dlelement_t* e = list_getElement(modelist, modenumber); if (e != 0) { mode = e->data; break; } } printf("\n1. Start Graphical Tests\n"); printf("2. Start GUI\n"); printf("3. Start VBE-Shell\n\n"); uint16_t whatToStart = 0; while (whatToStart == 0) { textColor(YELLOW); printf("Type in the number: "); textColor(TEXT); char num[3]; gets(num); whatToStart = atoi(num); } video_setMode(mode); if (whatToStart == 1) { uint16_t width = video_currentMode->xRes; uint16_t height = video_currentMode->yRes; uint16_t radius = min(width, height)/2; for (uint16_t i = 0; i < radius; i++) { BGRA_t color = {i*64/radius, i*256/radius, 128-(i*128/radius), 0}; // Create gradient video_drawCartesianCircle(video_currentMode->device, width/2, height/2, radius-i, color); // FPU sleepMilliSeconds(5); } BGRA_t bright_blue = {255, 75, 75, 0}; video_drawLine(video_currentMode->device, 0, height/2, width, height/2, bright_blue); video_drawLine(video_currentMode->device, 0, height/2 + 1, width, height/2 + 1, bright_blue); video_drawLine(video_currentMode->device, width/2, 0, width/2, height, bright_blue); video_drawLine(video_currentMode->device, width/2+1, 0, width/2+1, height, bright_blue); video_drawCartesianCircle(video_currentMode->device, width/2, height/2, height/2, bright_blue); // FPU video_drawCartesianCircle(video_currentMode->device, width/2, height/2, height/2-1, bright_blue); // FPU waitForKeyStroke(); video_drawBitmap(video_currentMode->device, 0, 0, &bmp_start); waitForKeyStroke(); video_printPalette(video_currentMode->device); video_drawString(video_currentMode->device, "PrettyOS started in March 2009.\nThis hobby OS tries to be a possible access for beginners in this area.", 0, 400); waitForKeyStroke(); video_drawScaledBitmap(video_currentMode->device, width, height, &bmp_start); waitForKeyStroke(); video_clearScreen(video_currentMode->device, black); waitForKeyStroke(); } else if (whatToStart == 2) { StartGUI(); } else if (whatToStart == 3) { startVBEShell(); } video_setMode(0); // Return to 80x50 text mode video_freeModeList(modelist); for (dlelement_t* e = basicVideoDevices->head; e != 0; e = e->next) { video_freeDevice(e->data); } list_free(basicVideoDevices); basicVideoDevices = 0; }