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

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

#include <project.h>

+ Inheritance diagram for Project:
+ Collaboration diagram for Project:

Signals

void attributesChanged () override
 This signal is emited when the value of attributes has changed. More...
 
void schematicAdded (int newIndex)
 This signal is emitted after a schematic was added to the project. More...
 
void schematicRemoved (int oldIndex)
 This signal is emitted after a schematic was removed from the project. More...
 
void boardAdded (int newIndex)
 This signal is emitted after a board was added to the project. More...
 
void boardRemoved (int oldIndex)
 This signal is emitted after a board was removed from the project. More...
 
- Signals inherited from AttributeProvider
virtual void attributesChanged ()=0
 This signal is emited when the value of attributes has changed. More...
 

Public Member Functions

 Project ()=delete
 
 Project (const Project &other)=delete
 
 Project (const FilePath &filepath, bool readOnly, bool interactve)
 The constructor to open an existing project with all its content. More...
 
 ~Project () noexcept
 The destructor will close the whole project (without saving!) More...
 
const FilePathgetFilepath () const noexcept
 Get the filepath of the project file (*.lpp) More...
 
const FilePathgetPath () const noexcept
 Get the path to the project directory. More...
 
bool isReadOnly () const noexcept
 Check whether this project was opened in read-only mode or not. More...
 
bool isRestored () const noexcept
 Check whether this project restored from temporary files or not. More...
 
StrokeFontPoolgetStrokeFonts () const noexcept
 Get the StrokeFontPool which contains all stroke fonts of the project. More...
 
ProjectMetadatagetMetadata () const noexcept
 Get the ProjectMetadata object which contains all project metadata. More...
 
ProjectSettingsgetSettings () const noexcept
 Get the ProjectSettings object which contains all project settings. More...
 
ProjectLibrarygetLibrary () const noexcept
 Get the ProjectLibrary object which contains all library elements used in this project. More...
 
ErcMsgListgetErcMsgList () const noexcept
 Get the ERC messages list. More...
 
CircuitgetCircuit () const noexcept
 Get the Circuit object. More...
 
SchematicLayerProvidergetLayers () noexcept
 
const SchematicLayerProvidergetLayers () const noexcept
 
int getSchematicIndex (const Schematic &schematic) const noexcept
 Get the page index of a specific schematic. More...
 
const QList< Schematic * > & getSchematics () const noexcept
 Get all schematics. More...
 
SchematicgetSchematicByIndex (int index) const noexcept
 Get the schematic page at a specific index. More...
 
SchematicgetSchematicByUuid (const Uuid &uuid) const noexcept
 Get the schematic page with a specific UUID. More...
 
SchematicgetSchematicByName (const QString &name) const noexcept
 Get the schematic page with a specific name. More...
 
SchematiccreateSchematic (const ElementName &name)
 Create a new schematic (page) More...
 
void addSchematic (Schematic &schematic, int newIndex=-1)
 Add an existing schematic to this project. More...
 
void removeSchematic (Schematic &schematic, bool deleteSchematic=false)
 Remove a schematic from this project. More...
 
void exportSchematicsAsPdf (const FilePath &filepath)
 Export the schematic pages as a PDF. More...
 
void printSchematicPages (QPrinter &printer, QList< int > &pages)
 Print some schematics to a QPrinter (printer or file) More...
 
int getBoardIndex (const Board &board) const noexcept
 Get the index of a specific board. More...
 
const QList< Board * > & getBoards () const noexcept
 Get all boards. More...
 
BoardgetBoardByIndex (int index) const noexcept
 Get the board at a specific index. More...
 
BoardgetBoardByUuid (const Uuid &uuid) const noexcept
 Get the board with a specific UUID. More...
 
BoardgetBoardByName (const QString &name) const noexcept
 Get the board with a specific name. More...
 
BoardcreateBoard (const ElementName &name)
 Create a new board. More...
 
BoardcreateBoard (const Board &other, const ElementName &name)
 Create a new board as a copy of an existing board. More...
 
void addBoard (Board &board, int newIndex=-1)
 Add an existing board to this project. More...
 
void removeBoard (Board &board, bool deleteBoard=false)
 Remove a board from this project. More...
 
void save (bool toOriginal)
 Save the whole project to the harddisc. More...
 
QString getUserDefinedAttributeValue (const QString &key) const noexceptoverride
 Get the value of a user defined attribute (if available) More...
 
QString getBuiltInAttributeValue (const QString &key) const noexceptoverride
 Get the value of a built-in attribute (if available) More...
 
bool operator== (const Project &rhs) noexcept
 
bool operator!= (const Project &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 QVector< const
AttributeProvider * > 
getAttributeProviderParents () const noexcept
 Get all parent attribute providers (fallback if attribute not found) More...
 

Static Public Member Functions

static Projectcreate (const FilePath &filepath)
 
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

 Project (const FilePath &filepath, bool create, bool readOnly, bool interactve)
 The constructor to create or open a project with all its content. More...
 
bool save (bool toOriginal, QStringList &errors) noexcept
 Save the project to the harddisc (to temporary or original files) More...
 

Private Attributes

FilePath mPath
 the path to the project directory More...
 
FilePath mFilepath
 the filepath of the *.lpp project file More...
 
QScopedPointer< SmartVersionFilemVersionFile
 the ".librepcb-project" file More...
 
QScopedPointer< SmartTextFilemProjectFile
 the *.lpp project file More...
 
DirectoryLock mLock
 
bool mIsRestored
 
bool mIsReadOnly
 
QScopedPointer< SmartSExprFilemSchematicsFile
 core/schematics.lp More...
 
QScopedPointer< SmartSExprFilemBoardsFile
 core/boards.lp More...
 
QScopedPointer< StrokeFontPoolmStrokeFontPool
 all fonts from ./resources/fontobene/ More...
 
QScopedPointer< ProjectMetadatamProjectMetadata
 e.g. project name, author, ... More...
 
QScopedPointer< ProjectSettingsmProjectSettings
 all project specific settings More...
 
QScopedPointer< ProjectLibrarymProjectLibrary
 
QScopedPointer< ErcMsgListmErcMsgList
 
QScopedPointer< CircuitmCircuit
 
QList< Schematic * > mSchematics
 All schematics of this project. More...
 
QList< Schematic * > mRemovedSchematics
 All removed schematics of this project. More...
 
QScopedPointer
< SchematicLayerProvider
mSchematicLayerProvider
 All schematic layers of this project. More...
 
QList< Board * > mBoards
 All boards of this project. More...
 
QList< Board * > mRemovedBoards
 All removed boards of this project. More...
 
QScopedPointer< AttributeListmAttributes
 all attributes in a specific order More...
 

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 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 !!
Author
ubruhin
Date
2014-06-24

Constructor & Destructor Documentation

Project ( )
delete

+ Here is the caller graph for this function:

Project ( const Project other)
delete
Project ( const FilePath filepath,
bool  readOnly,
bool  interactve 
)
inline

The constructor to open an existing project with all its content.

Parameters
filepathThe filepath to the an existing *.lpp project file
readOnlyIt true, the project will be opened in read-only mode
interactiveIf true, message boxes may be shown.
Exceptions
ExceptionIf the project could not be opened successfully
~Project ( )
noexcept

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

+ Here is the call graph for this function:

Project ( const FilePath filepath,
bool  create,
bool  readOnly,
bool  interactve 
)
explicitprivate

The constructor to create or open a project with all its content.

Parameters
filepathThe filepath to the new or existing *.lpp project file
createTrue if the specified project does not exist already and must be created.
readOnlyIf true, the project will be opened in read-only mode
interactiveIf true, message boxes may be shown.
Exceptions
ExceptionIf the project could not be created/opened successfully
Todo:
Remove interactive message boxes, should be done at a higher layer!

+ Here is the call graph for this function:

Member Function Documentation

const FilePath& getFilepath ( ) const
inlinenoexcept

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

Returns
The absolute filepath

+ Here is the caller graph for this function:

const FilePath& getPath ( ) const
inlinenoexcept

Get the path to the project directory.

Returns
The filepath to the project directory
bool isReadOnly ( ) const
inlinenoexcept

Check whether this project was opened in read-only mode or not.

Returns
See mIsReadOnly

+ Here is the caller graph for this function:

bool isRestored ( ) const
inlinenoexcept

Check whether this project restored from temporary files or not.

Returns
See mIsRestored

+ Here is the caller graph for this function:

StrokeFontPool& getStrokeFonts ( ) const
inlinenoexcept

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

Returns
A reference to the librepcb::StrokeFontPool object
ProjectMetadata& getMetadata ( ) const
inlinenoexcept

Get the ProjectMetadata object which contains all project metadata.

Returns
A reference to the ProjectMetadata object

+ Here is the caller graph for this function:

ProjectSettings& getSettings ( ) const
inlinenoexcept

Get the ProjectSettings object which contains all project settings.

Returns
A reference to the ProjectSettings object

+ Here is the caller graph for this function:

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:

ErcMsgList& getErcMsgList ( ) const
inlinenoexcept

Get the ERC messages list.

Returns
A reference to the ErcMsgList object

+ Here is the caller graph for this function:

Circuit& getCircuit ( ) const
inlinenoexcept

Get the Circuit object.

Returns
A reference to the Circuit object

+ Here is the caller graph for this function:

SchematicLayerProvider& getLayers ( )
inlinenoexcept
const SchematicLayerProvider& getLayers ( ) const
inlinenoexcept
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:

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

Get all schematics.

Returns
A QList with all schematics

+ Here is the caller graph for this function:

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:

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:

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:

Schematic * createSchematic ( const ElementName name)

Create a new schematic (page)

Parameters
nameThe schematic page name
Returns
A pointer to the new schematic
Exceptions
ExceptionThis method throws an exception on error.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
Note
This method must be called only from inside an #UndoCommand! Undo Commands for this method: project::CmdSchematicAdd

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
Note
This method must be called only from inside an #UndoCommand! Undo Commands for this method: project::CmdSchematicRemove

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void exportSchematicsAsPdf ( const FilePath filepath)

Export the schematic pages as a PDF.

Parameters
filepathThe filepath where the PDF should be saved. If the file exists already, it will be overwritten.
Exceptions
ExceptionOn error
Todo:
add more parameters (paper size, orientation, pages to print, ...)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void printSchematicPages ( QPrinter &  printer,
QList< int > &  pages 
)

Print some schematics to a QPrinter (printer or file)

Parameters
printerThe QPrinter where to print the schematic pages
pagesA list with all schematic page indexes which should be printed
Exceptions
ExceptionOn error

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:

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

Get all boards.

Returns
A QList with all boards

+ Here is the caller graph for this function:

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
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:

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:

Board * createBoard ( const ElementName name)

Create a new board.

Parameters
nameThe board name
Returns
A pointer to the new board
Exceptions
ExceptionThis method throws an exception on error.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Board * createBoard ( const Board other,
const ElementName name 
)

Create a new board as a copy of an existing board.

Parameters
otherThe board to copy
nameThe board name
Returns
A pointer to the new board
Exceptions
ExceptionThis method throws an exception on error.

+ Here is the call graph for this function:

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
Note
This method must be called only from inside an #UndoCommand! Undo Commands for this method: project::CmdBoardAdd

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
Note
This method must be called only from inside an #UndoCommand! Undo Commands for this method: project::CmdBoardRemove

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void save ( bool  toOriginal)

Save the whole project to the harddisc.

Parameters
toOriginalIf false, the project is saved only to temporary files
Note
The whole save procedere is described in Saving Procedere / Automatic Periodically Saving.
Exceptions
Exceptionon error

+ Here is the caller graph for this function:

QString getUserDefinedAttributeValue ( const QString &  key) const
overridevirtualnoexcept

Get the value of a user defined 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.

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.

bool operator== ( const Project rhs)
inlinenoexcept
bool operator!= ( const Project rhs)
inlinenoexcept
static Project* create ( const FilePath filepath)
inlinestatic

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool isFilePathInsideProjectDirectory ( const FilePath fp)
staticnoexcept

+ Here is the call graph for this function:

bool isProjectFile ( const FilePath file)
staticnoexcept
bool isProjectDirectory ( const FilePath dir)
staticnoexcept

+ Here is the caller graph for this function:

Version getProjectFileFormatVersion ( const FilePath dir)
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 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:

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:

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:

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:

bool save ( bool  toOriginal,
QStringList &  errors 
)
privatenoexcept

Save the project to the harddisc (to temporary or original files)

Parameters
toOriginalTrue: save to original files; False: save to temporary files
errorsAll errors will be added to this string list (translated)
Returns
True on success (then the error list should be empty), false otherwise

+ Here is the call graph for this function:

Member Data Documentation

FilePath mPath
private

the path to the project directory

FilePath mFilepath
private

the filepath of the *.lpp project file

QScopedPointer<SmartVersionFile> mVersionFile
private

the ".librepcb-project" file

QScopedPointer<SmartTextFile> mProjectFile
private

the *.lpp project file

DirectoryLock mLock
private

Lock for the whole project directory (see Avoid opening a project multiple times (Directory Lock))

bool mIsRestored
private

the constructor will set this to true if the project was restored

bool mIsReadOnly
private

the constructor will set this to true if the project was opened in read only mode

QScopedPointer<SmartSExprFile> mSchematicsFile
private

core/schematics.lp

QScopedPointer<SmartSExprFile> mBoardsFile
private

core/boards.lp

QScopedPointer<StrokeFontPool> mStrokeFontPool
private

all fonts from ./resources/fontobene/

QScopedPointer<ProjectMetadata> mProjectMetadata
private

e.g. project name, author, ...

QScopedPointer<ProjectSettings> mProjectSettings
private

all project specific settings

QScopedPointer<ProjectLibrary> mProjectLibrary
private

the library which contains all elements needed in this project

QScopedPointer<ErcMsgList> mErcMsgList
private

A list which contains all electrical rule check (ERC) messages

QScopedPointer<Circuit> mCircuit
private

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

QList<Schematic*> mSchematics
private

All schematics of this project.

QList<Schematic*> mRemovedSchematics
private

All removed schematics of this project.

QScopedPointer<SchematicLayerProvider> mSchematicLayerProvider
private

All schematic layers of this project.

QList<Board*> mBoards
private

All boards of this project.

QList<Board*> mRemovedBoards
private

All removed boards of this project.

QScopedPointer<AttributeList> mAttributes
private

all attributes in a specific order


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