Skip to content

RColor

Class in Core Module
Header: #include <src/core/RColor.h>
Inherits: QColor

Color.

Fixed RGBA or ByLayer or ByBlock.

Scriptable: This class is available in script environments.

Copyable: Objects are cleaned up automatically by the garbage collector of the script engine.

enum Mode { ByLayer, ByBlock, Fixed }
RColor()
Constructs an invalid color with the fixed RGB value (0, 0, 0).
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)
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
void setCompat(const QColor &col)
Initializes this color based on the given compatibility color.
QColor toCompat() const
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).
static RColor createFromCadIndex(const QString &code)
static RColor createFromCadIndex(int code)
Creates a color from the given CAD code (index 0…256).
static RColor createFromName(const QString &name)
static QList< RColor > getColorList(bool onlyFixed=false)
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 QStringList getNameList(bool onlyFixed=false)
static void reinit()
static void removeColor(const QString &cn)
static QColor CompatByBlock
static QColor CompatByLayer
Q_DECLARE_TR_FUNCTIONS(RColor)
static void init()
static void init(const QString &cn, const RColor &c)
Mode mode
static const double cadColors
static QMap< QPair< RColor, QPair< int, int > >, QIcon > iconMap
static bool isInitialized
static QList< QPair< QString, RColor > > list
QCADCORE_EXPORT QDataStream & operator<<(QDataStream &stream, const RColor &color)
Serializes the given RColor object.
QCADCORE_EXPORT QDataStream & operator>>(QDataStream &stream, RColor &color)
Deserializes the given RColor object.

enum Mode
Value Description
ByLayer
ByBlock
Fixed

RColor::RColor()

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

RColor::RColor(const QColor &color, RColor::Mode mode=RColor::Fixed)

Non-Scriptable: This function is not available in script environments.

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

explicit

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

RColor::RColor(Qt::GlobalColor color, RColor::Mode mode=RColor::Fixed)

Non-Scriptable: This function is not available in script environments.

RColor::RColor(RColor::Mode mode)

int RColor::getColorIndex() const

const

Returns: CAD index of this color used in MTEXT strings.

int RColor::getCustomColorCode() const

const

unsigned long long RColor::getHash() const

const

QString RColor::getName() const

const

Returns: Localized name of the color if known, otherwise “#RRGGBB”. For a localization neutral name use name() instead.

bool RColor::isByBlock() const

const

bool RColor::isByLayer() const

const

bool RColor::isFixed() const

const

bool RColor::isValid() const

const

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

const

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

const

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

const

void RColor::setCompat(const QColor &col)

Initializes this color based on the given compatibility color.

QColor RColor::toCompat() const

const

Returns: QColor compatibility equivalent of the current color.

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

static

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

static inline

static RColor RColor::createFromCadCustom(int code)

static

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

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

static inline

static RColor RColor::createFromCadIndex(int code)

static

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

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

static

static QList< RColor > RColor::getColorList(bool onlyFixed=false)

static

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

static

static RColor RColor::getHighlighted(const RColor &color, const QColor &bgColor, int minDist=75)

static

Returns: Highlighted color for the given color.

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

static

static QList< QPair< QString, RColor > > RColor::getList(bool onlyFixed=false)

static

Returns: List of known colors.

Parameters:

  • onlyFixed: Only fixed colors, not ByLayer, ByBlock, …

static QStringList RColor::getNameList(bool onlyFixed=false)

static

static void RColor::reinit()

static inline

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

static

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

static

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

static

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.

RColor::Q_DECLARE_TR_FUNCTIONS(RColor)

private

static void RColor::init()

static private

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

static private

Mode RColor::mode

private

static const double RColor::cadColors [][3]

static private

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.

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

static private

static bool RColor::isInitialized = false

static private

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

static private

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

Serializes the given RColor object.

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

Non-Scriptable: This function is not available in script environments.

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

Deserializes the given RColor object.

Non-Scriptable: This function is not available in script environments.