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

The Project class represents a whole (opened) project with all its content. More...

#include <project.h>

Inherits QObject.

+ Collaboration diagram for Project:

Signals

void attributesChanged ()
 
void normOrderChanged ()
 The norm order has been changed.
 
void ercMessageApprovalsChanged (const QSet< SExpression > &approvals)
 Called by setErcMessageApprovals()
 
void schematicAdded (int newIndex)
 This signal is emitted after a schematic was added to the project.
 
void schematicRemoved (int oldIndex)
 This signal is emitted after a schematic was removed from the project.
 
void boardAdded (int newIndex)
 This signal is emitted after a board was added to the project.
 
void boardRemoved (int oldIndex)
 This signal is emitted after a board was removed from the project.
 
void primaryBoardChanged (const QPointer< Board > &board)
 A different board has become the primary board.
 

Public Member Functions

 Project ()=delete
 
 Project (const Project &other)=delete
 
 Project (std::unique_ptr< TransactionalDirectory > directory, const QString &filename)
 Create a new, default initialized project.
 
 ~Project () noexcept
 The destructor will close the whole project (without saving!)
 
const QString & getFileName () const noexcept
 Get the filename of the project file (*.lpp)
 
FilePath getFilepath () const noexcept
 Get the filepath of the project file (*.lpp)
 
FilePath getPath () const noexcept
 Get the path to the project directory.
 
const TransactionalDirectorygetDirectory () const noexcept
 
TransactionalDirectorygetDirectory () noexcept
 
FilePath getCurrentOutputDir () const noexcept
 Get the output jobs base directory for the current version number.
 
StrokeFontPoolgetStrokeFonts () const noexcept
 Get the StrokeFontPool which contains all stroke fonts of the project.
 
const UuidgetUuid () const noexcept
 Get the UUID of the project.
 
const ElementNamegetName () const noexcept
 Get the name of the project.
 
const QString & getAuthor () const noexcept
 Get the author of the project.
 
const FileProofNamegetVersion () const noexcept
 Get the version of the project.
 
const QDateTime & getCreated () const noexcept
 Get the date and time when the project was created.
 
const QDateTime & getDateTime () const noexcept
 Get the date and time when the project was opened or saved.
 
const AttributeListgetAttributes () const noexcept
 Get the list of attributes.
 
const QStringList & getLocaleOrder () const noexcept
 Get the configured locale order.
 
const QStringList & getNormOrder () const noexcept
 Get the configured norm order.
 
const QStringList & getCustomBomAttributes () const noexcept
 Get the configured custom BOM attributes.
 
bool getDefaultLockComponentAssembly () const noexcept
 Whether assembly options of new components are locked for the board editor or not.
 
const OutputJobListgetOutputJobs () const noexcept
 Get all output jobs.
 
OutputJobListgetOutputJobs () noexcept
 
ProjectLibrarygetLibrary () const noexcept
 Get the ProjectLibrary object which contains all library elements used in this project.
 
CircuitgetCircuit () const noexcept
 Get the Circuit object.
 
const QSet< SExpression > & getErcMessageApprovals () const noexcept
 Get all ERC message approvals.
 
const QPointer< Board > & getPrimaryBoard () noexcept
 Get the primary board (the first one)
 
void setUuid (const Uuid &newUuid) noexcept
 Set the project's UUID.
 
void setName (const ElementName &newName) noexcept
 Set the name of the project.
 
void setAuthor (const QString &newAuthor) noexcept
 Set the author of the project.
 
void setVersion (const FileProofName &newVersion) noexcept
 Set the version of the project.
 
void setCreated (const QDateTime &newCreated) noexcept
 Set the creation date/time.
 
void updateDateTime () noexcept
 Update the last modified date/time.
 
void setAttributes (const AttributeList &newAttributes) noexcept
 Set all project attributes.
 
void setLocaleOrder (const QStringList &newLocales) noexcept
 Set the locale order.
 
void setNormOrder (const QStringList &newNorms) noexcept
 Set the norm order.
 
void setCustomBomAttributes (const QStringList &newKeys) noexcept
 Set the custom BOM attributes.
 
void setDefaultLockComponentAssembly (bool newLock) noexcept
 Set the default value for librepcb::ComponentInstance::mLockAssembly.
 
bool setErcMessageApprovals (const QSet< SExpression > &approvals) noexcept
 Set all ERC message approvals.
 
int getSchematicIndex (const Schematic &schematic) const noexcept
 Get the page index of a specific schematic.
 
const QList< Schematic * > & getSchematics () const noexcept
 Get all schematics.
 
SchematicgetSchematicByIndex (int index) const noexcept
 Get the schematic page at a specific index.
 
SchematicgetSchematicByUuid (const Uuid &uuid) const noexcept
 Get the schematic page with a specific UUID.
 
SchematicgetSchematicByName (const QString &name) const noexcept
 Get the schematic page with a specific name.
 
void addSchematic (Schematic &schematic, int newIndex=-1)
 Add an existing schematic to this project.
 
void removeSchematic (Schematic &schematic, bool deleteSchematic=false)
 Remove a schematic from this project.
 
int getBoardIndex (const Board &board) const noexcept
 Get the index of a specific board.
 
const QList< Board * > & getBoards () const noexcept
 Get all boards.
 
BoardgetBoardByIndex (int index) const noexcept
 Get the board at a specific index.
 
BoardgetBoardByUuid (const Uuid &uuid) const noexcept
 Get the board with a specific UUID.
 
BoardgetBoardByName (const QString &name) const noexcept
 Get the board with a specific name.
 
void addBoard (Board &board, int newIndex=-1)
 Add an existing board to this project.
 
void removeBoard (Board &board, bool deleteBoard=false)
 Remove a board from this project.
 
void save ()
 Save the project to the transactional file system.
 
bool operator== (const Project &rhs) noexcept
 
bool operator!= (const Project &rhs) noexcept
 

Static Public Member Functions

static std::unique_ptr< Projectcreate (std::unique_ptr< TransactionalDirectory > directory, const QString &filename)
 
static bool isFilePathInsideProjectDirectory (const FilePath &fp) noexcept
 
static bool isProjectFile (const FilePath &file) noexcept
 
static bool isProjectDirectory (const FilePath &dir) noexcept
 
static Version getProjectFileFormatVersion (const FilePath &dir)
 

Private Member Functions

void updatePrimaryBoard ()
 

Private Attributes

std::unique_ptr< TransactionalDirectorymDirectory
 Project root directory.
 
QString mFilename
 Name of the *.lpp project file.
 
QScopedPointer< StrokeFontPoolmStrokeFontPool
 All fonts from ./resources/fontobene/.
 
Uuid mUuid
 The project's UUID.
 
ElementName mName
 The project name.
 
QString mAuthor
 Author (optional).
 
FileProofName mVersion
 Version number.
 
QDateTime mCreated
 Date/time of project creation.
 
QDateTime mDateTime
 Date/time of opening or saving the project.
 
AttributeList mAttributes
 User-defined attributes in the specified order.
 
QStringList mLocaleOrder
 Configured locales (e.g. "de_CH") in a particular order.
 
QStringList mNormOrder
 Configured norms in a particular order.
 
QStringList mCustomBomAttributes
 Custom attributes to be included in BOM export.
 
bool mDefaultLockComponentAssembly
 Default value for librepcb::ComponentInstance::mLockAssembly.
 
OutputJobList mOutputJobs
 Output jobs.
 
QScopedPointer< ProjectLibrarymProjectLibrary
 Ehe library which contains all elements needed in this project.
 
QScopedPointer< CircuitmCircuit
 
QList< Schematic * > mSchematics
 All schematics of this project.
 
QList< Schematic * > mRemovedSchematics
 All removed schematics of this project.
 
QList< Board * > mBoards
 All boards of this project.
 
QList< Board * > mRemovedBoards
 All removed boards of this project.
 
QSet< SExpressionmErcMessageApprovals
 All approved ERC messages.
 
QPointer< BoardmPrimaryBoard
 

Detailed Description

The Project class represents a whole (opened) project with all its content.

This class represents a whole project with all the content of its directory:

  • circuit, schematics and boards
  • the project's library
  • project settings
  • and much more...

The constructor of the librepcb::Project class needs the filepath to a project file. Then the project will be opened. A new project can be created with the static method create(). The destructor will close the project (without saving). Use the method save() to write the whole project to the harddisc.

Note
!! A detailed description about projects is available here: Project Specification !!

Constructor & Destructor Documentation

◆ Project() [1/3]

Project ( )
delete
+ Here is the caller graph for this function:

◆ Project() [2/3]

Project ( const Project other)
delete

◆ Project() [3/3]

Project ( std::unique_ptr< TransactionalDirectory directory,
const QString &  filename 
)

Create a new, default initialized project.

Parameters
directoryThe project directory to use.
filenameThe filename of the *.lpp project file.
Exceptions
ExceptionIf the project could not be opened successfully

◆ ~Project()

~Project ( )
noexcept

The destructor will close the whole project (without saving!)

+ Here is the call graph for this function:

Member Function Documentation

◆ getFileName()

const QString & getFileName ( ) const
inlinenoexcept

Get the filename of the project file (*.lpp)

Returns
Filename with suffix but without path
+ Here is the caller graph for this function:

◆ getFilepath()

FilePath getFilepath ( ) const
inlinenoexcept

Get the filepath of the project file (*.lpp)

Returns
The absolute filepath
+ Here is the caller graph for this function:

◆ getPath()

FilePath getPath ( ) const
inlinenoexcept

Get the path to the project directory.

Returns
The filepath to the project directory
+ Here is the caller graph for this function:

◆ getDirectory() [1/2]

const TransactionalDirectory & getDirectory ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getDirectory() [2/2]

TransactionalDirectory & getDirectory ( )
inlinenoexcept

◆ getCurrentOutputDir()

FilePath getCurrentOutputDir ( ) const
inlinenoexcept

Get the output jobs base directory for the current version number.

Returns
Output path (./output/{{VERSION}}/)

◆ getStrokeFonts()

StrokeFontPool & getStrokeFonts ( ) const
inlinenoexcept

Get the StrokeFontPool which contains all stroke fonts of the project.

Returns
A reference to the librepcb::StrokeFontPool object

◆ getUuid()

const Uuid & getUuid ( ) const
inlinenoexcept

Get the UUID of the project.

Returns
The project UUID
+ Here is the caller graph for this function:

◆ getName()

const ElementName & getName ( ) const
inlinenoexcept

Get the name of the project.

Returns
The name of the project
+ Here is the caller graph for this function:

◆ getAuthor()

const QString & getAuthor ( ) const
inlinenoexcept

Get the author of the project.

Returns
The author of the project
+ Here is the caller graph for this function:

◆ getVersion()

const FileProofName & getVersion ( ) const
inlinenoexcept

Get the version of the project.

Returns
The version of the project
+ Here is the caller graph for this function:

◆ getCreated()

const QDateTime & getCreated ( ) const
inlinenoexcept

Get the date and time when the project was created.

Returns
The local date and time of creation
+ Here is the caller graph for this function:

◆ getDateTime()

const QDateTime & getDateTime ( ) const
inlinenoexcept

Get the date and time when the project was opened or saved.

Returns
The local date and time

◆ getAttributes()

const AttributeList & getAttributes ( ) const
inlinenoexcept

Get the list of attributes.

Returns
All attributes in a specific order

◆ getLocaleOrder()

const QStringList & getLocaleOrder ( ) const
inlinenoexcept

Get the configured locale order.

Returns
Locales in a specific order
+ Here is the caller graph for this function:

◆ getNormOrder()

const QStringList & getNormOrder ( ) const
inlinenoexcept

Get the configured norm order.

Returns
Norms in a specific order
+ Here is the caller graph for this function:

◆ getCustomBomAttributes()

const QStringList & getCustomBomAttributes ( ) const
inlinenoexcept

Get the configured custom BOM attributes.

Returns
Attribute keys in a specific order

◆ getDefaultLockComponentAssembly()

bool getDefaultLockComponentAssembly ( ) const
inlinenoexcept

Whether assembly options of new components are locked for the board editor or not.

Returns
Default state for librepcb::ComponentInstance::mLockAssembly

◆ getOutputJobs() [1/2]

const OutputJobList & getOutputJobs ( ) const
inlinenoexcept

Get all output jobs.

Returns
Output jobs
+ Here is the caller graph for this function:

◆ getOutputJobs() [2/2]

OutputJobList & getOutputJobs ( )
inlinenoexcept

◆ getLibrary()

ProjectLibrary & getLibrary ( ) const
inlinenoexcept

Get the ProjectLibrary object which contains all library elements used in this project.

Returns
A reference to the ProjectLibrary object
+ Here is the caller graph for this function:

◆ getCircuit()

Circuit & getCircuit ( ) const
inlinenoexcept

Get the Circuit object.

Returns
A reference to the Circuit object
+ Here is the caller graph for this function:

◆ getErcMessageApprovals()

const QSet< SExpression > & getErcMessageApprovals ( ) const
inlinenoexcept

Get all ERC message approvals.

Returns
Approval nodes
+ Here is the caller graph for this function:

◆ getPrimaryBoard()

const QPointer< Board > & getPrimaryBoard ( )
inlinenoexcept

Get the primary board (the first one)

Returns
Primary board (nullptr if there are no boards)
+ Here is the caller graph for this function:

◆ setUuid()

void setUuid ( const Uuid newUuid)
noexcept

Set the project's UUID.

Warning
Only call this right after instantiating a new Project object, not some time later! Not intended to be accessible by the UI.
Parameters
newUuidThe new UUID.
+ Here is the caller graph for this function:

◆ setName()

void setName ( const ElementName newName)
noexcept

Set the name of the project.

Parameters
newNameThe new name
+ Here is the caller graph for this function:

◆ setAuthor()

void setAuthor ( const QString &  newAuthor)
noexcept

Set the author of the project.

Parameters
newAuthorThe new author
+ Here is the caller graph for this function:

◆ setVersion()

void setVersion ( const FileProofName newVersion)
noexcept

Set the version of the project.

Parameters
newVersionThe new version
+ Here is the caller graph for this function:

◆ setCreated()

void setCreated ( const QDateTime &  newCreated)
noexcept

Set the creation date/time.

Parameters
newCreatedThe new date/time of creation.
+ Here is the caller graph for this function:

◆ updateDateTime()

void updateDateTime ( )
noexcept

Update the last modified date/time.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttributes()

void setAttributes ( const AttributeList newAttributes)
noexcept

Set all project attributes.

Parameters
newAttributesThe new list of attributes.
+ Here is the caller graph for this function:

◆ setLocaleOrder()

void setLocaleOrder ( const QStringList &  newLocales)
noexcept

Set the locale order.

Parameters
newLocalesThe new locale order.
+ Here is the caller graph for this function:

◆ setNormOrder()

void setNormOrder ( const QStringList &  newNorms)
noexcept

Set the norm order.

Parameters
newNormsThe new norm order.
+ Here is the caller graph for this function:

◆ setCustomBomAttributes()

void setCustomBomAttributes ( const QStringList &  newKeys)
noexcept

Set the custom BOM attributes.

Parameters
newKeysThe new attribute keys.
+ Here is the caller graph for this function:

◆ setDefaultLockComponentAssembly()

void setDefaultLockComponentAssembly ( bool  newLock)
noexcept

Set the default value for librepcb::ComponentInstance::mLockAssembly.

Parameters
newLockThe new lock default value.
+ Here is the caller graph for this function:

◆ setErcMessageApprovals()

bool setErcMessageApprovals ( const QSet< SExpression > &  approvals)
noexcept

Set all ERC message approvals.

Parameters
approvalsApproval nodes
Return values
falseIf approvals have not been modified (no change)
trueIf approvals have been moified
+ Here is the caller graph for this function:

◆ getSchematicIndex()

int getSchematicIndex ( const Schematic schematic) const
noexcept

Get the page index of a specific schematic.

Returns
the schematic index (-1 if the schematic does not exist)
+ Here is the caller graph for this function:

◆ getSchematics()

const QList< Schematic * > & getSchematics ( ) const
inlinenoexcept

Get all schematics.

Returns
A QList with all schematics
+ Here is the caller graph for this function:

◆ getSchematicByIndex()

Schematic * getSchematicByIndex ( int  index) const
inlinenoexcept

Get the schematic page at a specific index.

Parameters
indexThe page index (zero is the first)
Returns
A pointer to the specified schematic, or nullptr if index is invalid
+ Here is the caller graph for this function:

◆ getSchematicByUuid()

Schematic * getSchematicByUuid ( const Uuid uuid) const
noexcept

Get the schematic page with a specific UUID.

Parameters
uuidThe schematic UUID
Returns
A pointer to the specified schematic, or nullptr if uuid is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSchematicByName()

Schematic * getSchematicByName ( const QString &  name) const
noexcept

Get the schematic page with a specific name.

Parameters
nameThe schematic name
Returns
A pointer to the specified schematic, or nullptr if name is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSchematic()

void addSchematic ( Schematic schematic,
int  newIndex = -1 
)

Add an existing schematic to this project.

Parameters
schematicThe schematic to add
newIndexThe desired index in the list (after inserting it)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeSchematic()

void removeSchematic ( Schematic schematic,
bool  deleteSchematic = false 
)

Remove a schematic from this project.

Parameters
schematicThe schematic to remove
deleteSchematicIf true, the schematic object will be deleted (Set this to true only when called from ctor or dtor!!)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBoardIndex()

int getBoardIndex ( const Board board) const
noexcept

Get the index of a specific board.

Returns
the board index (-1 if the board does not exist)
+ Here is the caller graph for this function:

◆ getBoards()

const QList< Board * > & getBoards ( ) const
inlinenoexcept

Get all boards.

Returns
A QList with all boards
+ Here is the caller graph for this function:

◆ getBoardByIndex()

Board * getBoardByIndex ( int  index) const
inlinenoexcept

Get the board at a specific index.

Parameters
indexThe board index (zero is the first)
Returns
A pointer to the specified board, or nullptr if index is invalid
+ Here is the caller graph for this function:

◆ getBoardByUuid()

Board * getBoardByUuid ( const Uuid uuid) const
noexcept

Get the board with a specific UUID.

Parameters
uuidThe board UUID
Returns
A pointer to the specified board, or nullptr if uuid is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBoardByName()

Board * getBoardByName ( const QString &  name) const
noexcept

Get the board with a specific name.

Parameters
nameThe board name
Returns
A pointer to the specified board, or nullptr if name is invalid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addBoard()

void addBoard ( Board board,
int  newIndex = -1 
)

Add an existing board to this project.

Parameters
boardThe board to add
newIndexThe desired index in the list (after inserting it)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeBoard()

void removeBoard ( Board board,
bool  deleteBoard = false 
)

Remove a board from this project.

Parameters
boardThe board to remove
deleteBoardIf true, the board object will be deleted (Set this to true only when called from ctor or dtor!!)
Exceptions
ExceptionOn error
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

void save ( )

Save the project to the transactional file system.

Exceptions
ExceptionIf an error occurred.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==()

bool operator== ( const Project rhs)
inlinenoexcept

◆ operator!=()

bool operator!= ( const Project rhs)
inlinenoexcept

◆ create()

std::unique_ptr< Project > create ( std::unique_ptr< TransactionalDirectory directory,
const QString &  filename 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFilePathInsideProjectDirectory()

bool isFilePathInsideProjectDirectory ( const FilePath fp)
staticnoexcept
+ Here is the call graph for this function:

◆ isProjectFile()

bool isProjectFile ( const FilePath file)
staticnoexcept

◆ isProjectDirectory()

bool isProjectDirectory ( const FilePath dir)
staticnoexcept
+ Here is the caller graph for this function:

◆ getProjectFileFormatVersion()

Version getProjectFileFormatVersion ( const FilePath dir)
static
+ Here is the call graph for this function:

◆ attributesChanged

void attributesChanged ( )
signal
+ Here is the caller graph for this function:

◆ normOrderChanged

void normOrderChanged ( )
signal

The norm order has been changed.

◆ ercMessageApprovalsChanged

void ercMessageApprovalsChanged ( const QSet< SExpression > &  approvals)
signal

Called by setErcMessageApprovals()

Parameters
approvalsThe new approvals

◆ schematicAdded

void schematicAdded ( int  newIndex)
signal

This signal is emitted after a schematic was added to the project.

Parameters
newIndexThe index of the added schematic
+ Here is the caller graph for this function:

◆ schematicRemoved

void schematicRemoved ( int  oldIndex)
signal

This signal is emitted after a schematic was removed from the project.

Parameters
oldIndexThe index of the removed schematic
+ Here is the caller graph for this function:

◆ boardAdded

void boardAdded ( int  newIndex)
signal

This signal is emitted after a board was added to the project.

Parameters
newIndexThe index of the added board
+ Here is the caller graph for this function:

◆ boardRemoved

void boardRemoved ( int  oldIndex)
signal

This signal is emitted after a board was removed from the project.

Parameters
oldIndexThe index of the removed board
+ Here is the caller graph for this function:

◆ primaryBoardChanged

void primaryBoardChanged ( const QPointer< Board > &  board)
signal

A different board has become the primary board.

Parameters
boardNew primary board (may be nullptr)
+ Here is the caller graph for this function:

◆ updatePrimaryBoard()

void updatePrimaryBoard ( )
private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ mDirectory

std::unique_ptr<TransactionalDirectory> mDirectory
private

Project root directory.

◆ mFilename

QString mFilename
private

Name of the *.lpp project file.

◆ mStrokeFontPool

QScopedPointer<StrokeFontPool> mStrokeFontPool
private

All fonts from ./resources/fontobene/.

◆ mUuid

Uuid mUuid
private

The project's UUID.

◆ mName

ElementName mName
private

The project name.

◆ mAuthor

QString mAuthor
private

Author (optional).

◆ mVersion

FileProofName mVersion
private

Version number.

◆ mCreated

QDateTime mCreated
private

Date/time of project creation.

◆ mDateTime

QDateTime mDateTime
private

Date/time of opening or saving the project.

◆ mAttributes

AttributeList mAttributes
private

User-defined attributes in the specified order.

◆ mLocaleOrder

QStringList mLocaleOrder
private

Configured locales (e.g. "de_CH") in a particular order.

◆ mNormOrder

QStringList mNormOrder
private

Configured norms in a particular order.

◆ mCustomBomAttributes

QStringList mCustomBomAttributes
private

Custom attributes to be included in BOM export.

◆ mDefaultLockComponentAssembly

bool mDefaultLockComponentAssembly
private

◆ mOutputJobs

OutputJobList mOutputJobs
private

Output jobs.

◆ mProjectLibrary

QScopedPointer<ProjectLibrary> mProjectLibrary
private

Ehe library which contains all elements needed in this project.

◆ mCircuit

QScopedPointer<Circuit> mCircuit
private

The whole circuit of this project (contains all netclasses, netsignals, component instances, ...)

◆ mSchematics

QList<Schematic*> mSchematics
private

All schematics of this project.

◆ mRemovedSchematics

QList<Schematic*> mRemovedSchematics
private

All removed schematics of this project.

◆ mBoards

QList<Board*> mBoards
private

All boards of this project.

◆ mRemovedBoards

QList<Board*> mRemovedBoards
private

All removed boards of this project.

◆ mErcMessageApprovals

QSet<SExpression> mErcMessageApprovals
private

All approved ERC messages.

◆ mPrimaryBoard

QPointer<Board> mPrimaryBoard
private

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