void AnalogClock::paintEvent(QPaintEvent *event) { (void)event; // we need not `event` static const QPoint hourHand[3] = { QPoint(7, 8), QPoint(-7, 8), QPoint(0, -40) }; static const QPoint minuteHand[3] = { QPoint(7, 8), QPoint(-7, 8), QPoint(0, -70) }; static const QPoint secondHand[3] = { QPoint(3, 8), QPoint(-3, 8), QPoint(0, -75), }; QColor hourColor(127, 0, 127); QColor minuteColor(0, 127, 127, 190); QColor secondColor(0, 100, 255, 180); int side = qMin(width(), height()); QTime time = QTime::currentTime(); // setup painter QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); painter.scale(side / 200.0, side / 200.0); // draw clock hour degree painter.setPen(hourColor); for (int i = -1; i < 12; i++) { painter.drawLine(88, 0, 96, 0); painter.rotate(30.0); } // draw clock second degree painter.setPen(minuteColor); for(int j = 0; j < 60; ++j) { if ((j % 5) != 0) painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } // draw hour hand float rotateDegree = 30.0 * ((time.hour() + time.minute() / 60.0)); drawClockHand(painter, rotateDegree, hourHand, 3, hourColor); // draw minute hand rotateDegree = 6.0 * (time.minute() + time.second() / 60.0); drawClockHand(painter, rotateDegree, minuteHand, 3, minuteColor); // draw second hand rotateDegree = 6.0 * time.second(); drawClockHand(painter, rotateDegree, secondHand, 3, secondColor); }
QColor HighlighterGradientSelector::highlightedColor() const { QColor tmpColor = ColorUtil::triadicColors(firstColor())[0]; if (tmpColor.saturation() < 64) tmpColor = ColorUtil::triadicColors(secondColor())[1]; if (tmpColor.saturation() < 64) tmpColor = Qt::darkBlue; if (tmpColor.value() < 64) tmpColor = Qt::yellow; return tmpColor; }
void AnalogClock::paintEvent(QPaintEvent *) { static const QPoint hourHand[3] = { QPoint(6, 7), QPoint(-6, 7), QPoint(0, -40) }; static const QPoint minuteHand[3] = { QPoint(6, 7), QPoint(-6, 7), QPoint(0, -70) }; static const QPoint secondHand[3] = { QPoint(2, 3), QPoint(-2, 3), QPoint(0, -90) }; QColor hourColor(127, 0, 127); QColor minuteColor(0, 127, 127, 191); QColor secondColor(40, 40, 40, 127); int side = qMin(width(), height()); QTime time = QTime::currentTime(); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); painter.scale(side / 200.0, side / 200.0); painter.setPen(Qt::NoPen); painter.setBrush(hourColor); painter.save(); painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); painter.drawConvexPolygon(hourHand, 3); painter.restore(); painter.setPen(hourColor); for (int i = 0; i < 12; ++i) { painter.drawLine(88, 0, 96, 0); painter.rotate(30.0); } painter.setPen(Qt::NoPen); painter.setBrush(minuteColor); painter.save(); painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); painter.drawConvexPolygon(minuteHand, 3); painter.restore(); painter.setPen(minuteColor); for (int j = 0; j < 60; ++j) { if ((j % 5) != 0) painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } painter.setPen(Qt::NoPen); painter.setBrush(secondColor); painter.save(); painter.rotate(6.0 * time.second() ); painter.drawConvexPolygon(secondHand, 3); painter.restore(); painter.setPen(secondColor); for (int j = 0; j < 360; ++j) { if ((j % 5) != 0) painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } }
void QmitkStdMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* prefs) { // Enable change of logo. If no DepartmentLogo was set explicitly, MBILogo is used. // Set new department logo by prefs->Set("DepartmentLogo", "PathToImage"); // If no logo was set for this plug-in specifically, walk the parent preference nodes // and lookup a logo value there. const berry::IPreferences* currentNode = prefs; while(currentNode) { std::vector<std::string> keys = currentNode->Keys(); bool logoFound = false; for( std::size_t i = 0; i < keys.size(); ++i ) { if( keys[i] == "DepartmentLogo") { std::string departmentLogoLocation = currentNode->Get("DepartmentLogo", ""); if (departmentLogoLocation.empty()) { d->m_StdMultiWidget->DisableDepartmentLogo(); } else { // we need to disable the logo first, otherwise setting a new logo will have // no effect due to how mitkManufacturerLogo works... d->m_StdMultiWidget->DisableDepartmentLogo(); d->m_StdMultiWidget->SetDepartmentLogoPath(departmentLogoLocation.c_str()); d->m_StdMultiWidget->EnableDepartmentLogo(); } logoFound = true; break; } } if (logoFound) break; currentNode = currentNode->Parent().GetPointer(); } // preferences for gradient background float color = 255.0; QString firstColorName = QString::fromStdString (prefs->GetByteArray("first background color", "")); QColor firstColor(firstColorName); mitk::Color upper; if (firstColorName=="") // default values { upper[0] = 0.1; upper[1] = 0.1; upper[2] = 0.1; } else { upper[0] = firstColor.red() / color; upper[1] = firstColor.green() / color; upper[2] = firstColor.blue() / color; } QString secondColorName = QString::fromStdString (prefs->GetByteArray("second background color", "")); QColor secondColor(secondColorName); mitk::Color lower; if (secondColorName=="") // default values { lower[0] = 0.5; lower[1] = 0.5; lower[2] = 0.5; } else { lower[0] = secondColor.red() / color; lower[1] = secondColor.green() / color; lower[2] = secondColor.blue() / color; } d->m_StdMultiWidget->SetGradientBackgroundColors(upper, lower); d->m_StdMultiWidget->EnableGradientBackground(); // Set preferences respecting zooming and padding bool constrainedZooming = prefs->GetBool("Use constrained zooming and padding", false); mitk::RenderingManager::GetInstance()->SetConstrainedPaddingZooming(constrainedZooming); mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" , mitk::BoolProperty::New(false))); mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetDataStorage()->GetSubset(pred); // calculate bounding geometry of these nodes mitk::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); // initialize the views to the bounding geometry mitk::RenderingManager::GetInstance()->InitializeViews(bounds); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // level window setting bool showLevelWindowWidget = prefs->GetBool("Show level/window widget", true); if (showLevelWindowWidget) { d->m_StdMultiWidget->EnableStandardLevelWindow(); } else { d->m_StdMultiWidget->DisableStandardLevelWindow(); } // mouse modes toolbar bool newMode = prefs->GetBool("PACS like mouse interaction", false); d->m_MouseModeToolbar->setVisible( newMode ); d->m_StdMultiWidget->GetMouseModeSwitcher()->SetInteractionScheme( newMode ? mitk::MouseModeSwitcher::PACS : mitk::MouseModeSwitcher::MITK ); }
void MyClock::paintEvent(QPaintEvent *) { static const QPoint hourHand[8] = { QPoint (-5, 0), QPoint (-5, 30), QPoint (-10, 30), QPoint (0, 40), QPoint (10, 30), QPoint (5, 30), QPoint (5, 0), QPoint (- 5, 0) }; static const QPoint minuteHand[8] = { QPoint (-3, 0), QPoint (-3, 50), QPoint (-6, 50), QPoint (0, 60), QPoint (6, 50), QPoint (3, 50), QPoint (3, 0), QPoint (- 3, 0) }; static const QPoint secondHand[8] = { QPoint (-1, 0), QPoint (-1, 50), QPoint (-2, 60), QPoint (0, 70), QPoint (2, 60), QPoint (1, 50), QPoint (1, 0), QPoint (-1, 0) }; QColor hourColor(255, 50, 50); QColor minuteColor(50, 255, 50); QColor secondColor(50, 50, 255); int side = qMin(width(), height()); *time = QTime::currentTime(); //time->addSecs(3600); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); painter.scale(side / 200.0, side / 200.0); painter.setPen(Qt::SolidLine); painter.setBrush(hourColor); painter.save(); painter.rotate(30.0 * ((time->hour() + time->minute() / 60.0)) + 180.0); painter.drawConvexPolygon(hourHand, 8); painter.restore(); painter.setPen(hourColor); for (int i = 0; i < 12; ++i) { painter.drawLine(88, 0, 96, 0); painter.rotate(30.0); } painter.setPen(Qt::SolidLine); painter.setBrush(minuteColor); painter.save(); painter.rotate(6.0 * (time->minute() + time->second() / 60.0) + 180.0); painter.drawConvexPolygon(minuteHand, 8); painter.restore(); painter.setPen(minuteColor); for (int j = 0; j < 60; ++j) { if ((j % 5) != 0) painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } painter.setPen(Qt::SolidLine); painter.setBrush(secondColor); painter.save(); painter.rotate(6.0 * time->second() + 180.0); painter.drawConvexPolygon(secondHand, 8); painter.restore(); }