LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Schematic Class Referencefinal

The Schematic class represents one schematic page of a project and is always part of a circuit. More...

#include <schematic.h>

+ Inheritance diagram for Schematic:
+ Collaboration diagram for Schematic:

Public Types

enum  ItemZValue
 Z Values of all items in a schematic scene (to define the stacking order) More...
 

Signals

void attributesChanged () override
 This signal is emited when the value of attributes has changed. More...
 
- Signals inherited from AttributeProvider
virtual void attributesChanged ()=0
 This signal is emited when the value of attributes has changed. More...
 

Public Member Functions

 Schematic ()=delete
 
 Schematic (const Schematic &other)=delete
 
 Schematic (Project &project, const FilePath &filepath, bool restore, bool readOnly)
 
 ~Schematic () noexcept
 
ProjectgetProject () const noexcept
 
const FilePathgetFilePath () const noexcept
 
const GridPropertiesgetGridProperties () const noexcept
 
GraphicsScenegetGraphicsScene () const noexcept
 
bool isEmpty () const noexcept
 
QList< SI_Base * > getItemsAtScenePos (const Point &pos) const noexcept
 
QList< SI_NetPoint * > getNetPointsAtScenePos (const Point &pos) const noexcept
 
QList< SI_NetLine * > getNetLinesAtScenePos (const Point &pos) const noexcept
 
QList< SI_NetLabel * > getNetLabelsAtScenePos (const Point &pos) const noexcept
 
QList< SI_SymbolPin * > getPinsAtScenePos (const Point &pos) const noexcept
 
void setGridProperties (const GridProperties &grid) noexcept
 
const UuidgetUuid () const noexcept
 
const ElementNamegetName () const noexcept
 
const QIcon & getIcon () const noexcept
 
QList< SI_Symbol * > getSymbols () const noexcept
 
SI_SymbolgetSymbolByUuid (const Uuid &uuid) const noexcept
 
void addSymbol (SI_Symbol &symbol)
 
void removeSymbol (SI_Symbol &symbol)
 
SI_NetSegmentgetNetSegmentByUuid (const Uuid &uuid) const noexcept
 
void addNetSegment (SI_NetSegment &netsegment)
 
void removeNetSegment (SI_NetSegment &netsegment)
 
void addToProject ()
 
void removeFromProject ()
 
bool save (bool toOriginal, QStringList &errors) noexcept
 
void showInView (GraphicsView &view) noexcept
 
void saveViewSceneRect (const QRectF &rect) noexcept
 
const QRectF & restoreViewSceneRect () const noexcept
 
void setSelectionRect (const Point &p1, const Point &p2, bool updateItems) noexcept
 
void clearSelection () const noexcept
 
void updateAllNetLabelAnchors () noexcept
 
void renderToQPainter (QPainter &painter) const noexcept
 
std::unique_ptr
< SchematicSelectionQuery
createSelectionQuery () const noexcept
 
QString getBuiltInAttributeValue (const QString &key) const noexceptoverride
 Get the value of a built-in attribute (if available) More...
 
QVector< const
AttributeProvider * > 
getAttributeProviderParents () const noexceptoverride
 Get all parent attribute providers (fallback if attribute not found) More...
 
Schematicoperator= (const Schematic &rhs)=delete
 
bool operator== (const Schematic &rhs) noexcept
 
bool operator!= (const Schematic &rhs) noexcept
 
- Public Member Functions inherited from AttributeProvider
 AttributeProvider () noexcept
 
 AttributeProvider (const AttributeProvider &other)=delete
 
AttributeProvideroperator= (const AttributeProvider &rhs)=delete
 
virtual ~AttributeProvider () noexcept
 
QString getAttributeValue (const QString &key) const noexcept
 Get the value of an attribute which can be used in texts (like "{{NAME}}") More...
 
virtual QString getUserDefinedAttributeValue (const QString &key) const noexcept
 Get the value of a user defined attribute (if available) More...
 
- Public Member Functions inherited from SerializableObject
 SerializableObject () noexcept
 
virtual ~SerializableObject () noexcept
 
SExpression serializeToDomElement (const QString &name) const
 Serialize the object to a new S-Expression node. More...
 

Static Public Member Functions

static Schematiccreate (Project &project, const FilePath &filepath, const ElementName &name)
 
- Static Public Member Functions inherited from SerializableObject
template<typename T >
static void serializeObjectContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainerUuidSorted (SExpression &root, const T &container, const QString &itemName)
 

Private Member Functions

 Schematic (Project &project, const FilePath &filepath, bool restore, bool readOnly, bool create, const QString &newName)
 
void updateIcon () noexcept
 
void serialize (SExpression &root) const override
 Serialize the object into an existing S-Expression node. More...
 

Private Attributes

ProjectmProject
 A reference to the Project object (from the ctor) More...
 
FilePath mFilePath
 the filepath of the schematic *.lp file (from the ctor) More...
 
QScopedPointer< SmartSExprFilemFile
 
bool mIsAddedToProject
 
QScopedPointer< GraphicsScenemGraphicsScene
 
QScopedPointer< GridPropertiesmGridProperties
 
QRectF mViewRect
 
Uuid mUuid
 
ElementName mName
 
QIcon mIcon
 
QList< SI_Symbol * > mSymbols
 
QList< SI_NetSegment * > mNetSegments
 

Detailed Description

The Schematic class represents one schematic page of a project and is always part of a circuit.

A schematic can contain following items (see #project#SI_Base and #project#SGI_Base):

  • netsegment: #project#SI_NetSegment
    • netpoint: #project#SI_NetPoint + #project#SGI_NetPoint
    • netline: #project#SI_NetLine + #project#SGI_NetLine
    • netlabel: #project#SI_NetLabel + #project#SGI_NetLabel
  • symbol: #project#SI_Symbol + #project#SGI_Symbol
    • symbol pin: #project#SI_SymbolPin + #project#SGI_SymbolPin
  • polygon: TODO
  • circle: TODO
  • text: TODO

Member Enumeration Documentation

enum ItemZValue

Z Values of all items in a schematic scene (to define the stacking order)

These values are used for QGraphicsItem::setZValue() to define the stacking order of all items in a schematic QGraphicsScene. We use integer values, even if the z-value of QGraphicsItem is a qreal attribute...

Low number = background, high number = foreground

Enumerator
ZValue_Default 

this is the default value (behind all other items)

ZValue_Symbols 

Z value for #project#SI_Symbol items.

ZValue_NetLabels 

Z value for #project#SI_NetLabel items.

ZValue_NetLines 

Z value for #project#SI_NetLine items.

ZValue_HiddenNetPoints 

Z value for hidden #project#SI_NetPoint items.

ZValue_VisibleNetPoints 

Z value for visible #project#SI_NetPoint items

Constructor & Destructor Documentation

Schematic ( )
delete

+ Here is the caller graph for this function:

Schematic ( const Schematic other)
delete
Schematic ( Project project,
const FilePath filepath,
bool  restore,
bool  readOnly 
)
inline
~Schematic ( )
noexcept
Schematic ( Project project,
const FilePath filepath,
bool  restore,
bool  readOnly,
bool  create,
const QString &  newName 
)
private

+ Here is the call graph for this function:

Member Function Documentation

Project& getProject ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const FilePath& getFilePath ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const GridProperties& getGridProperties ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

GraphicsScene& getGraphicsScene ( ) const
inlinenoexcept
bool isEmpty ( ) const
noexcept

+ Here is the caller graph for this function:

QList< SI_Base * > getItemsAtScenePos ( const Point pos) const
noexcept

+ Here is the call graph for this function:

QList< SI_NetPoint * > getNetPointsAtScenePos ( const Point pos) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QList< SI_NetLine * > getNetLinesAtScenePos ( const Point pos) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QList< SI_NetLabel * > getNetLabelsAtScenePos ( const Point pos) const
noexcept

+ Here is the call graph for this function:

QList< SI_SymbolPin * > getPinsAtScenePos ( const Point pos) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void setGridProperties ( const GridProperties grid)
noexcept

+ Here is the caller graph for this function:

const Uuid& getUuid ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const ElementName& getName ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const QIcon& getIcon ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

QList<SI_Symbol*> getSymbols ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

SI_Symbol * getSymbolByUuid ( const Uuid uuid) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void addSymbol ( SI_Symbol symbol)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void removeSymbol ( SI_Symbol symbol)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SI_NetSegment * getNetSegmentByUuid ( const Uuid uuid) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void addNetSegment ( SI_NetSegment netsegment)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void removeNetSegment ( SI_NetSegment netsegment)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void addToProject ( )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void removeFromProject ( )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool save ( bool  toOriginal,
QStringList &  errors 
)
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void showInView ( GraphicsView view)
noexcept

+ Here is the caller graph for this function:

void saveViewSceneRect ( const QRectF &  rect)
inlinenoexcept

+ Here is the caller graph for this function:

const QRectF& restoreViewSceneRect ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

void setSelectionRect ( const Point p1,
const Point p2,
bool  updateItems 
)
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clearSelection ( ) const
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void updateAllNetLabelAnchors ( )
noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void renderToQPainter ( QPainter &  painter) const
noexcept

+ Here is the caller graph for this function:

std::unique_ptr< SchematicSelectionQuery > createSelectionQuery ( ) const
noexcept

+ Here is the caller graph for this function:

QString getBuiltInAttributeValue ( const QString &  key) const
overridevirtualnoexcept

Get the value of a built-in attribute (if available)

Parameters
keyThe attribute name (e.g. "NAME" for "{{NAME}}")
Returns
The value of the attribute (empty string if not found)

Reimplemented from AttributeProvider.

QVector< const AttributeProvider * > getAttributeProviderParents ( ) const
overridevirtualnoexcept

Get all parent attribute providers (fallback if attribute not found)

Returns
All parent attribute provider objects (empty and nullptr are allowed)

Reimplemented from AttributeProvider.

Schematic& operator= ( const Schematic rhs)
delete
bool operator== ( const Schematic rhs)
inlinenoexcept
bool operator!= ( const Schematic rhs)
inlinenoexcept
Schematic * create ( Project project,
const FilePath filepath,
const ElementName name 
)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void attributesChanged ( )
overridesignal

This signal is emited when the value of attributes has changed.

All derived classes must emit this signal when some attributes have changed their values (only attributes which can be fetched with getAttributeValue(), inclusive all attributes from all "parent" classes).

+ Here is the caller graph for this function:

void updateIcon ( )
privatenoexcept

+ Here is the caller graph for this function:

void serialize ( SExpression root) const
overrideprivatevirtual

Serialize the object into an existing S-Expression node.

This method inserts/appends all attributes and childs of the object to an existing S-Expression node. The content which already exists in the given S-Expression node will not be removed.

Note
The generated S-Expression node has always the format of the application's major version (it's not possible to generate DOMs of older versions).
Parameters
rootThe target DOM root node
Exceptions
ExceptionThis method throws an exception if an error occurs.

Implements SerializableObject.

+ Here is the call graph for this function:

Member Data Documentation

Project& mProject
private

A reference to the Project object (from the ctor)

FilePath mFilePath
private

the filepath of the schematic *.lp file (from the ctor)

QScopedPointer<SmartSExprFile> mFile
private
bool mIsAddedToProject
private
QScopedPointer<GraphicsScene> mGraphicsScene
private
QScopedPointer<GridProperties> mGridProperties
private
QRectF mViewRect
private
Uuid mUuid
private
ElementName mName
private
QIcon mIcon
private
QList<SI_Symbol*> mSymbols
private
QList<SI_NetSegment*> mNetSegments
private

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