void QgsColorBox::setColorFromPoint( QPoint point ) { int valX = valueRangeX() * ( point.x() - mMargin ) / ( width() - 2 * mMargin - 1 ); valX = qMin( qMax( valX, 0 ), valueRangeX() ); int valY = valueRangeY() - valueRangeY() * ( point.y() - mMargin ) / ( height() - 2 * mMargin - 1 ); valY = qMin( qMax( valY, 0 ), valueRangeY() ); QColor color = QColor( mCurrentColor ); alterColor( color, xComponent(), valX ); alterColor( color, yComponent(), valY ); if ( color == mCurrentColor ) { return; } if ( color.hue() >= 0 ) { mExplicitHue = color.hue(); } mCurrentColor = color; update(); emit colorChanged( color ); }
bool NFCClassModule::AddComponents(rapidxml::xml_node<>* pComponentRootNode, NF_SHARE_PTR<NFIClass> pClass) { for (rapidxml::xml_node<>* pComponentNode = pComponentRootNode->first_node(); pComponentNode; pComponentNode = pComponentNode->next_sibling()) { if (pComponentNode) { const char* strComponentName = pComponentNode->first_attribute("Name")->value(); const char* strLanguage = pComponentNode->first_attribute("Language")->value(); const char* strEnable = pComponentNode->first_attribute("Enable")->value(); bool bEnable = lexical_cast<bool>(strEnable); if (bEnable) { if (pClass->GetComponentManager()->GetElement(strComponentName)) { //error NFASSERT(0, strComponentName, __FILE__, __FUNCTION__); continue; } NF_SHARE_PTR<NFIComponent> xComponent(NF_NEW NFIComponent(NFGUID(), strComponentName)); pClass->GetComponentManager()->AddComponent(strComponentName, xComponent); } } } return true; }
void QgsColorBox::createBox() { int maxValueX = mBoxImage->width(); int maxValueY = mBoxImage->height(); //create a temporary color object QColor currentColor = QColor( mCurrentColor ); int colorComponentValue; for ( int y = 0; y < maxValueY; ++y ) { QRgb* scanLine = ( QRgb* )mBoxImage->scanLine( y ); colorComponentValue = int( valueRangeY() - valueRangeY() * ( double( y ) / maxValueY ) ); alterColor( currentColor, yComponent(), colorComponentValue ); for ( int x = 0; x < maxValueX; ++x ) { colorComponentValue = int( valueRangeX() * ( double( x ) / maxValueX ) ); alterColor( currentColor, xComponent(), colorComponentValue ); scanLine[x] = currentColor.rgb(); } } mDirty = false; }
int QgsColorBox::xComponentValue() const { return componentValue( xComponent() ); }
int QgsColorBox::valueRangeX() const { return componentRange( xComponent() ); }