/** Find and remove the least value color from a group's menu, * updating all data structures. * @param grp is a group number * @return grp's deficit, after the update is complete */ int egcolor_menu::swapOut(int grp) { // find color of least value in grp's menu int c = firstColor(grp); if (c == 0) return 0; int cval = value(c,grp); for (int cc = firstColor(grp); cc != 0; cc = nextColor(grp,cc)) { int ccval = value(cc,grp); if (ccval < cval) { c = cc; cval = ccval; } } return shrinkMenu(grp, c); }
/** Determine the number of colors in a group's menu. * @param grp is a group number * @return the number of colors in grp's menu */ int egcolor_menu::menuSize(int grp) const { int cnt = 0; for (int c = firstColor(grp); c != 0; c = nextColor(grp,c)) { cnt++; } return cnt; }
/** Remove all colors from the menu of a group and update related * data structures. * @param grp is a group number */ void egcolor_menu::resetMenu(int grp) { vertex u = gp->input(gp->firstEdgeInGroup(grp)); int c = firstColor(grp); while (c != 0) { removeColor(c,grp); free(c, u); c = firstColor(grp); } for (edge e = gp->firstEdgeInGroup(grp); e != 0; e = gp->nextEdgeInGroup(grp,e)) { vertex v = gp->output(e); int dv = gp->degree(v); Graph &mg = *mgraf[v]; dmatch& dm = *dymatch[v]; edge ee = dm.matchEdge(gx[e]); if (ee != 0) { int c = mg.right(ee) - dv; dm.unmatch(ee); free(c, v); } for (edge ee = mg.firstAt(gx[e]); ee != 0; ee = mg.firstAt(gx[e])) mg.remove(ee); } }
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 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 ); }
bool egcolor_menu::inMenu(int grp, int c) const { for (int cc = firstColor(grp); cc != 0; cc = nextColor(grp,cc)) { if (cc == c) return true; } return false; }