Пример #1
0
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 );
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
int QgsColorBox::xComponentValue() const
{
  return componentValue( xComponent() );
}
Пример #5
0
int QgsColorBox::valueRangeX() const
{
  return componentRange( xComponent() );
}