QCAD
Open Source 2D CAD
RColor Class Reference

Color. More...

#include <RColor.h>

Inheritance diagram for RColor:

Public Types

enum  Mode { ByLayer, ByBlock, Fixed }
 

Public Member Functions

int getColorIndex () const
 
int getCustomColorCode () const
 
unsigned long long getHash () const
 
QString getName () const
 
bool isByBlock () const
 
bool isByLayer () const
 
bool isFixed () const
 
bool isValid () const
 
bool operator!= (const RColor &color) const
 
bool operator< (const RColor &color) const
 
bool operator== (const RColor &color) const
 
 RColor ()
 Constructs an invalid color with the fixed RGB value (0, 0, 0). More...
 
 RColor (const QColor &color, RColor::Mode mode=RColor::Fixed)
 
 RColor (const QString &name, RColor::Mode mode=RColor::Fixed)
 
 RColor (int r, int g, int b, int a=255, RColor::Mode mode=RColor::Fixed)
 
 RColor (Qt::GlobalColor color, RColor::Mode mode=RColor::Fixed)
 
 RColor (RColor::Mode mode)
 
void setCompat (const QColor &col)
 Initializes this color based on the given compatibility color. More...
 
QColor toCompat () const
 

Static Public Member Functions

static void addColor (const QString &cn, const RColor &c)
 
static RColor createFromCadCustom (const QString &code)
 
static RColor createFromCadCustom (int code)
 Creates a color from the given CAD code (RGB encoded int). More...
 
static RColor createFromCadIndex (const QString &code)
 
static RColor createFromCadIndex (int code)
 Creates a color from the given CAD code (index 0...256). More...
 
static RColor createFromName (const QString &name)
 
static RColor getFaded (const RColor &color, const QColor &bgColor, double factor=1)
 
static RColor getHighlighted (const RColor &color, const QColor &bgColor, int minDist=75)
 
static QIcon getIcon (const RColor &color, const QSize &size=RDEFAULT_QSIZE_ICON)
 
static QList< QPair< QString, RColor > > getList (bool onlyFixed=false)
 
static void reinit ()
 
static void removeColor (const QString &cn)
 

Static Public Attributes

static QColor CompatByBlock = QColor(2,2,2)
 
static QColor CompatByLayer = QColor(1,1,1)
 Copyright (c) 2011-2018 by Andrew Mustun. More...
 

Private Member Functions

 Q_DECLARE_TR_FUNCTIONS (RColor)
 

Static Private Member Functions

static void init ()
 
static void init (const QString &cn, const RColor &c)
 

Private Attributes

Mode mode
 

Static Private Attributes

static const double cadColors [][3]
 Copyright (c) 2011-2018 by Andrew Mustun. More...
 
static QMap< QPair< RColor, QPair< int, int > >, QIcon > iconMap
 
static bool isInitialized = false
 
static QList< QPair< QString, RColor > > list
 

Friends

QCADCORE_EXPORT QDataStream & operator<< (QDataStream &stream, const RColor &color)
 Serializes the given RColor object. More...
 
QCADCORE_EXPORT QDataStream & operator>> (QDataStream &stream, RColor &color)
 Deserializes the given RColor object. More...
 

Detailed Description

Color.

Fixed RGBA or ByLayer or ByBlock.

Scriptable:\nThis class is available in script environments.\n
Copyable:\nObjects are cleaned up automatically by the garbage collector of the script engine.\n

Member Enumeration Documentation

◆ Mode

Enumerator
ByLayer 
ByBlock 
Fixed 

Constructor & Destructor Documentation

◆ RColor() [1/6]

RColor::RColor ( )

Constructs an invalid color with the fixed RGB value (0, 0, 0).

◆ RColor() [2/6]

RColor::RColor ( int  r,
int  g,
int  b,
int  a = 255,
RColor::Mode  mode = RColor::Fixed 
)

◆ RColor() [3/6]

RColor::RColor ( RColor::Mode  mode)

◆ RColor() [4/6]

RColor::RColor ( const QString &  name,
RColor::Mode  mode = RColor::Fixed 
)
explicit

◆ RColor() [5/6]

RColor::RColor ( Qt::GlobalColor  color,
RColor::Mode  mode = RColor::Fixed 
)
Non-Scriptable:\nThis function is not available in script environments.\n

◆ RColor() [6/6]

RColor::RColor ( const QColor &  color,
RColor::Mode  mode = RColor::Fixed 
)
Non-Scriptable:\nThis function is not available in script environments.\n

Member Function Documentation

◆ addColor()

void RColor::addColor ( const QString &  cn,
const RColor c 
)
static

◆ createFromCadCustom() [1/2]

static RColor RColor::createFromCadCustom ( const QString &  code)
inlinestatic

◆ createFromCadCustom() [2/2]

RColor RColor::createFromCadCustom ( int  code)
static

Creates a color from the given CAD code (RGB encoded int).

◆ createFromCadIndex() [1/2]

static RColor RColor::createFromCadIndex ( const QString &  code)
inlinestatic

◆ createFromCadIndex() [2/2]

RColor RColor::createFromCadIndex ( int  code)
static

Creates a color from the given CAD code (index 0...256).

◆ createFromName()

RColor RColor::createFromName ( const QString &  name)
static

◆ getColorIndex()

int RColor::getColorIndex ( ) const
Returns
CAD index of this color used in MTEXT strings.

◆ getCustomColorCode()

int RColor::getCustomColorCode ( ) const

◆ getFaded()

RColor RColor::getFaded ( const RColor color,
const QColor &  bgColor,
double  factor = 1 
)
static

◆ getHash()

unsigned long long RColor::getHash ( ) const

◆ getHighlighted()

RColor RColor::getHighlighted ( const RColor color,
const QColor &  bgColor,
int  minDist = 75 
)
static
Returns
Highlighted color for the given color.

◆ getIcon()

QIcon RColor::getIcon ( const RColor color,
const QSize &  size = RDEFAULT_QSIZE_ICON 
)
static

◆ getList()

QList< QPair< QString, RColor > > RColor::getList ( bool  onlyFixed = false)
static
Returns
List of known colors.
Parameters
onlyFixedOnly fixed colors, not ByLayer, ByBlock, ...

◆ getName()

QString RColor::getName ( ) const
Returns
Localized name of the color if known, otherwise "#RRGGBB". For a localization neutral name use name() instead.

◆ init() [1/2]

void RColor::init ( )
staticprivate

◆ init() [2/2]

void RColor::init ( const QString &  cn,
const RColor c 
)
staticprivate

◆ isByBlock()

bool RColor::isByBlock ( ) const

◆ isByLayer()

bool RColor::isByLayer ( ) const

◆ isFixed()

bool RColor::isFixed ( ) const

◆ isValid()

bool RColor::isValid ( ) const

◆ operator!=()

bool RColor::operator!= ( const RColor color) const

◆ operator<()

bool RColor::operator< ( const RColor color) const

◆ operator==()

bool RColor::operator== ( const RColor color) const

◆ Q_DECLARE_TR_FUNCTIONS()

RColor::Q_DECLARE_TR_FUNCTIONS ( RColor  )
private

◆ reinit()

static void RColor::reinit ( )
inlinestatic

◆ removeColor()

void RColor::removeColor ( const QString &  cn)
static

◆ setCompat()

void RColor::setCompat ( const QColor &  col)

Initializes this color based on the given compatibility color.

◆ toCompat()

QColor RColor::toCompat ( ) const
Returns
QColor compatibility equivalent of the current color.

Friends And Related Function Documentation

◆ operator<<

QCADCORE_EXPORT QDataStream& operator<< ( QDataStream &  stream,
const RColor color 
)
friend

Serializes the given RColor object.

Used for RSettings, keep in sync with operator>>.

Non-Scriptable:\nThis function is not available in script environments.\n

◆ operator>>

QCADCORE_EXPORT QDataStream& operator>> ( QDataStream &  stream,
RColor color 
)
friend

Deserializes the given RColor object.

Non-Scriptable:\nThis function is not available in script environments.\n

Member Data Documentation

◆ cadColors

const double RColor::cadColors
staticprivate

Copyright (c) 2011-2018 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

◆ CompatByBlock

QColor RColor::CompatByBlock = QColor(2,2,2)
static

◆ CompatByLayer

QColor RColor::CompatByLayer = QColor(1,1,1)
static

Copyright (c) 2011-2018 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

◆ iconMap

QMap< QPair< RColor, QPair< int, int > >, QIcon > RColor::iconMap
staticprivate

◆ isInitialized

bool RColor::isInitialized = false
staticprivate

◆ list

QList< QPair< QString, RColor > > RColor::list
staticprivate

◆ mode

Mode RColor::mode
private

The documentation for this class was generated from the following files: