English | Deutsch

Last Update: May, 2008

The QCad Libraries

The QCad Libraries are a set of C++ libraries to be used with Qt for CAD related applications.

Programming With The QCad Libraries

Programming with the QCad libraries is as simple as demonstrated in this example code snippet which creates a graphic and loads a DXF file into it. The graphic is then shown in a Qt widget with scrollbars.

// Create graphic document:
RS_Graphic* graphic = new RS_Graphic();

// Import DXF file:
RS_Import import(*graphic);
import.fileImport("demo.dxf");

// Create graphic view (Qt widget):
QG_GraphicView* graphicView = 
    new QG_GraphicView(this);
graphicView->setContainer(graphic);

QCad Libraries Modules

QCad is based on these modules:

  • dxflib
  • qcadlib
  • qcadcmd
  • qcadactions
  • qcadguiqt
  • qcadprof
  • qcadscripting

These modules are used by the QCad application they can also be used by any other CAD related program to render and modify 2D CAD drawings. Note that the QCad application itself is also included as source code in the QCad Libraries packages.
The figure below shows how the modules interact with each other.


Module overview of the QCad Libraries.

A simple example: The user clicks into the graphic window to specify the start point of a line. The graphic view widget in the qcadguiqt module receives the mouse click event and forwards it to the qcadlib module. The qcadlib module knows that the currently active action is for drawing lines. The click event is forwarded to the appropriate action class in the qcadactions module.

dxflib

DXF parsing and writing. dxflib is also available as a single module. For more information about that, please click here.

Requirements: No special requirements.

qcadlib

2D CAD engine. Rendering, import, export, entity creation, entity modification, layer handling, block handling, undo/redo functionality, graphics information, abstract GUI, maths.

Requirements: Qt library, dxflib

qcadcmd

This module contains the handling of all commands used from the command line of an application. The module is separated to allow individual languages for the user interface and the commands.

Requirements: Qt library, dxflib, qcadlib

qcadactions

Interactive action classes for qcadlib. Handling of user events and inputs for creating, modifying and measuring entities. Interactive zooming, layer handling, block handling, snapping, selecting.

Requirements: Qt library, dxflib, qcadlib, qcadcmd

qcadguiqt

GUI implementation of common Qt widgets for use with a CAD or CAD related application. E.g. a graphic view widget, combo boxes for selecting entity attributes, dialogs, ..

Requirements: Qt library, dxflib, qcadlib, qcadcmd, qcadactions

qcadprof

Classes and functions that are only available for QCad Professional (e.g. polyline support).

Requirements: Qt library, dxflib, qcadlib, qcadcmd, qcadactions, qcadguiqt

qcadscripting

Scripting support for QCad. This module exposes some C++ functions and classes to the script interface.

Requirements: Qt library, QSA, dxflib, qcadlib, qcadcmd, qcadactions, qcadguiqt