This repository is a git submodule providing C++ classes for larger projects, including (all in namespace cairowindow):
-
Window
: A new native window, assuming you are on X11. Full support for tripple buffering to allow seamless, non-stop updating. -
Layer
: Abstraction of a layer. Represents a drawing surface, can be smaller than and have an offset relative to the Window. -
LayerRegion
: A rectangular portion of a layer that has adraw
function associated with it (base class to all drawable objects). -
MultiRegion
: Convenience base class for drawable objects that exist of more than one layer region. -
EventLoop
: Returned by Window::run(). Causes the window to be opened and everything that was added to it to be drawn. Destructing the returnedEventLoop
blocks until the window was closed. You want to destroy theEventLoop
before destroying any of the above objects, because destroying those will make them disappear (no longer being drawn). -
Vector
: An x and y coordinate. -
Matrix
: A row-major 2x2 matrix. -
Color
: A color object. -
StrokeExtents
: A rectangle object, used to keep track of what area needs to be redrawn for a givenLayerRegion
upon expose. -
IntersectRectangle
: Another rectangle object, most suitable to find intersections between rectangles.
And the following "mathematical" objects that can be used to construct plottable counter parts from:
Arc
: A center point, begin and end angle, and a radius.Circle
: A center and a radius.Connector
: A LinePiece and two arrow head types (among which 'no_arrow').Direction
: A direction (unit) vector.Line
: Defined by a Point and a Direction (yes, the line has a direction "awareness").LinePiece
: Defined by two Point's (from and to).Point
: Defined by an x and y coordinate (double).Rectangle
: Describes a rectangle with an (optional) offset relative to the main Window.Text
: A Point and a std::string.
In namespace cairowindow::plot
we currently have:
Plot
: An object representing a plot chart with title, axes, data points etc.Range
: Describes the minimum and maximum values of the axes of a plot.
The following classes in namespace cairowindow::plot
are derived from the classes with the same
name in namespace cairowindow
but add a shared_ptr
to a draw::
object with the same name, that
contain plot specific data. Objects of these types therefore correspond with an object drawn in the
plot and destructing the object will erase it from the plot.
Point
: Created withPlot::create_point
from acairowindow::Point
and adraw::PointStyle
.Circle
: Created withPlot::create_circle
from acairowindow::Point center
,double radius
anddraw::CircleStyle
(ordraw::LineStyle
).Text
: Created withPlot::create_text
from acairowindow::Point position
,std::string
anddraw::TextStyle<>
.LinePiece
: Created withPlot::create_line
from twocairowindow::Point
objects anddraw::LineStyle
(plus aLineExtend
enum that allows to extend the line in zero, one or both directions).Line
: Created withPlot::create_line
from acairowindow::Point
, cairowindow::Directionand
draw::LineStyle`.Connector
: Created withPlot::create_connector
from twocairowindow::Point
objects, zero or moreConnector::ArrowHeadShape
,draw::LineStyle
and a fillColor
(for the arrow heads, if appropriate).Arc
: Created withPlot::create_arc
from acairowindow::Point center
,double start_angle
,double end_angle
,double radius
anddraw::ArcStyle
.
The objects in namespace cairowindow::draw
shouldn't be used by the user.
It currently contains:
Arc
: A piece of a circle.Circle
: A circle (or ellipse).Connector
: A line piece with optional arrow heads (open, closed, diamond or circle).Line
: A line.Rectangle
: A rectangle.Text
: Some text or label.PlotArea
: The axes and ticks of a plot.
The root project should be using cmake cwm4 and cwds.
To clone a project example-project that uses cairowindow simply run:
git clone --recursive <URL-to-project>/example-project.git
cd example-project
AUTOGEN_CMAKE_ONLY=1 ./autogen.sh
The --recursive
is optional because ./autogen.sh
will fix
it when you forgot it.
In order to use cmake
configure as usual, for example to do a debug build with 16 cores:
mkdir build_debug
cmake -S . -B build_debug -DCMAKE_MESSAGE_LOG_LEVEL=DEBUG -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DEnableDebugGlobal:BOOL=OFF
cmake --build build_debug --config Debug --parallel 16
Or to make a release build:
mkdir build_release
cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release
cmake --build build_release --config Release --parallel 16
To add this submodule to a project, that project should already be set up to use cwm4.
Simply execute the following in a directory of that project
where you want to have the cairowindow
subdirectory (the
root of the project is recommended as that is the only thing
I've tested so far):
git submodule add https://github.com/CarloWood/cairowindow.git
This should clone cairowindow into the subdirectory cairowindow
, or
if you already cloned it there, it should add it.
Check out the submodules cwds, cwm4 and ai-utils in the root of the project:
git submodule add https://github.com/CarloWood/cwds.git
git submodule add https://github.com/CarloWood/cwm4.git
git submodule add https://github.com/CarloWood/ai-utils.git utils
The easiest way to use libcwd is by using gitache.
For that to happen create in the root of the project (that uses utils)
a directory cmake/gitache-configs
and put in it the file libcwd_r.cmake
with the content:
gitache_config(
GIT_REPOSITORY
"https://github.com/CarloWood/libcwd.git"
GIT_TAG
"master"
CMAKE_ARGS
"-DEnableLibcwdAlloc:BOOL=OFF -DEnableLibcwdLocation:BOOL=ON"
)
Add the variable GITACHE_ROOT
to your environment,
for example add to your ~/.bashrc
the line:
export GITACHE_ROOT="/opt/gitache"
Add the following lines to the CMakeLists.txt
in the
root of the project (directly under the project
line):
# Begin of gitache configuration.
set(GITACHE_PACKAGES libcwd_r)
include(cwm4/cmake/StableGitache)
# End of gitache configuration.
include(cwm4/cmake/AICxxProject)
include(AICxxSubmodules)
add_subdirectory
is not necessary for cwds
, cwm4
, utils
or cairowindow
.
See for example the root MakeLists.txt of machine-learning.
Finally, linking is done by adding ${AICXX_OBJECTS_LIST}
to
the appropriate target_link_libraries
.
For example,
include(AICxxProject)
add_executable(register_test register_test.cxx)
target_link_libraries(register_test PRIVATE ${AICXX_OBJECTS_LIST})
See this MakeLists.txt of machine-learning for a complete example.
Finally, run
./autogen.sh
to let cwm4 do its magic, and commit all the changes.
Checkout machine-learning for an example of a project that uses this submodule.