LibrePCB Developers Documentation
Loading...
Searching...
No Matches
Image Class Referencefinal

The Image class. More...

#include <image.h>

+ Collaboration diagram for Image:

Public Types

enum class  Event
 
typedef Slot< Image, EventOnEditedSlot
 

Public Member Functions

 Image ()=delete
 
 Image (const Image &other) noexcept
 
 Image (const Uuid &uuid, const Image &other) noexcept
 
 Image (const Uuid &uuid, const FileProofName &fileName, const Point &pos, const Angle &rotation, const PositiveLength &width, const PositiveLength &height, const std::optional< UnsignedLength > &borderWidth) noexcept
 
 Image (const SExpression &node)
 
 ~Image () noexcept
 
const UuidgetUuid () const noexcept
 
const FileProofNamegetFileName () const noexcept
 
QString getFileBasename () const noexcept
 
QString getFileExtension () const noexcept
 
const PointgetPosition () const noexcept
 
Point getCenter () const noexcept
 
const AnglegetRotation () const noexcept
 
const PositiveLengthgetWidth () const noexcept
 
const PositiveLengthgetHeight () const noexcept
 
const std::optional< UnsignedLength > & getBorderWidth () const noexcept
 
bool setFileName (const FileProofName &name) noexcept
 
bool setPosition (const Point &pos) noexcept
 
bool setRotation (const Angle &rotation) noexcept
 
bool setWidth (const PositiveLength &width) noexcept
 
bool setHeight (const PositiveLength &height) noexcept
 
bool setBorderWidth (const std::optional< UnsignedLength > &width) noexcept
 
void serialize (SExpression &root) const
 Serialize into librepcb::SExpression node.
 
bool operator== (const Image &rhs) const noexcept
 
bool operator!= (const Image &rhs) const noexcept
 
Imageoperator= (const Image &rhs) noexcept
 

Static Public Member Functions

static const QStringList & getSupportedExtensions () noexcept
 Get all supported file extensions.
 
static std::optional< QImage > tryLoad (const QByteArray &data, const QString &format, QString *errorMsg=nullptr) noexcept
 Try loading an image file.
 

Public Attributes

Signal< Image, EventonEdited
 

Private Attributes

Uuid mUuid
 
FileProofName mFileName
 
Point mPosition
 
Angle mRotation
 
PositiveLength mWidth
 
PositiveLength mHeight
 
std::optional< UnsignedLengthmBorderWidth
 

Detailed Description

The Image class.

Member Typedef Documentation

◆ OnEditedSlot

Member Enumeration Documentation

◆ Event

enum class Event
strong
Enumerator
UuidChanged 
FileNameChanged 
PositionChanged 
RotationChanged 
WidthChanged 
HeightChanged 
BorderWidthChanged 

Constructor & Destructor Documentation

◆ Image() [1/5]

Image ( )
delete

◆ Image() [2/5]

Image ( const Image other)
noexcept

◆ Image() [3/5]

Image ( const Uuid uuid,
const Image other 
)
noexcept

◆ Image() [4/5]

Image ( const Uuid uuid,
const FileProofName fileName,
const Point pos,
const Angle rotation,
const PositiveLength width,
const PositiveLength height,
const std::optional< UnsignedLength > &  borderWidth 
)
noexcept

◆ Image() [5/5]

Image ( const SExpression node)
explicit

◆ ~Image()

~Image ( )
noexcept

Member Function Documentation

◆ getUuid()

const Uuid & getUuid ( ) const
inlinenoexcept

◆ getFileName()

const FileProofName & getFileName ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getFileBasename()

QString getFileBasename ( ) const
noexcept

◆ getFileExtension()

QString getFileExtension ( ) const
noexcept
+ Here is the caller graph for this function:

◆ getPosition()

const Point & getPosition ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getCenter()

Point getCenter ( ) const
noexcept
+ Here is the call graph for this function:

◆ getRotation()

const Angle & getRotation ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getWidth()

const PositiveLength & getWidth ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getHeight()

const PositiveLength & getHeight ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getBorderWidth()

const std::optional< UnsignedLength > & getBorderWidth ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ setFileName()

bool setFileName ( const FileProofName name)
noexcept
+ Here is the caller graph for this function:

◆ setPosition()

bool setPosition ( const Point pos)
noexcept
+ Here is the caller graph for this function:

◆ setRotation()

bool setRotation ( const Angle rotation)
noexcept
+ Here is the caller graph for this function:

◆ setWidth()

bool setWidth ( const PositiveLength width)
noexcept
+ Here is the caller graph for this function:

◆ setHeight()

bool setHeight ( const PositiveLength height)
noexcept
+ Here is the caller graph for this function:

◆ setBorderWidth()

bool setBorderWidth ( const std::optional< UnsignedLength > &  width)
noexcept
+ Here is the caller graph for this function:

◆ serialize()

void serialize ( SExpression root) const

Serialize into librepcb::SExpression node.

Parameters
rootRoot node to serialize into.
+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const Image rhs) const
noexcept

◆ operator!=()

bool operator!= ( const Image rhs) const
inlinenoexcept

◆ operator=()

Image & operator= ( const Image rhs)
noexcept

◆ getSupportedExtensions()

const QStringList & getSupportedExtensions ( )
staticnoexcept

Get all supported file extensions.

Note
This is only a small subset of Qt's supported image formats. We don't want to support unusual, exotic or non-portable image formats to make sure LibrePCB can open them on any platform without needing possibly heavy dependencies.
All returned file extensions are lowercase and we expect images to be created only with lowercase file extensions too.
Returns
File extensions (e.g. "png", "jpg", "svg").
+ Here is the caller graph for this function:

◆ tryLoad()

std::optional< QImage > tryLoad ( const QByteArray &  data,
const QString &  format,
QString *  errorMsg = nullptr 
)
staticnoexcept

Try loading an image file.

Note
This also verifies that the format is officially supported. Formats not contained in getSupportedExtensions() will return std::nullopt even if Qt would be able to load it.
Parameters
dataThe file content.
formatThe file format (getFileExtension()). Note that we are case-sensitive, i.e. don't allow uppercase file extensions (there's no good reason to have uppercase file extensions).
errorMsgIf not nullptr, the (translated) error message will be written into this string (only on error).
Returns
The QImage on success, std::nullopt on failure.
+ Here is the caller graph for this function:

Member Data Documentation

◆ onEdited

Signal<Image, Event> onEdited

◆ mUuid

Uuid mUuid
private

◆ mFileName

FileProofName mFileName
private

◆ mPosition

Point mPosition
private

◆ mRotation

Angle mRotation
private

◆ mWidth

PositiveLength mWidth
private

◆ mHeight

PositiveLength mHeight
private

◆ mBorderWidth

std::optional<UnsignedLength> mBorderWidth
private

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