Mercurial > projects > qtd
changeset 378:7341c47790d4
binding of qwt
author | Eldar Insafutdinov |
---|---|
date | Sat, 10 Jul 2010 21:54:44 +0100 |
parents | c429854a40c0 |
children | a795eeb3b21f |
files | CMakeLists.txt build/qwt.txt examples/qwt/simpleplot/build.sh examples/qwt/simpleplot/simple.d generator/CMakeLists.txt generator/abstractmetalang.cpp generator/cppimplgenerator.cpp generator/dgenerator.cpp generator/typesystem_core.xml generator/typesystem_qwt.xml include/qtd_core.h include/qwt_masterinclude.h |
diffstat | 12 files changed, 412 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Fri Jul 09 20:24:24 2010 +0100 +++ b/CMakeLists.txt Sat Jul 10 21:54:44 2010 +0100 @@ -51,7 +51,7 @@ set(GENERATE_DI_FILES OFF) ## Very experimental option. Temporarily disabled. option(VERBOSE_DEBUG "Verbose debug" "OFF") -set(all_packages Core Gui OpenGL Xml Svg Network WebKit CACHE INTERNAL "") +set(all_packages Core Gui OpenGL Xml Svg Network WebKit Qwt CACHE INTERNAL "") ## Init D toolkit. set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) @@ -93,12 +93,30 @@ foreach(package_big ${all_packages}) string(TOLOWER ${package_big} package) string(TOUPPER ${package_big} package_upper) - option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON") + set(package_default_option "ON") + if(${package_big} STREQUAL "Qwt") + set(package_default_option "OFF") + endif() + option(BUILD_QT_${package_upper} "Build Qt${package_big}" ${package_default_option}) if(BUILD_QT_${package_upper}) set(packages ${packages} ${package_big}) endif() endforeach() +set(QWT_INCLUDE_PATH "/usr/include/qwt-qt4" CACHE STRING "Qwt include path") + +set(inc_paths "") + +if(CMAKE_HOST_WIN32) + set(sep ";") +else() + set(sep ":") +endif() + +if(BUILD_QT_QWT) + set(inc_paths ${inc_paths}${sep}${QWT_INCLUDE_PATH}) +endif() + add_subdirectory(generator) add_custom_target(main ALL) @@ -151,6 +169,9 @@ math(EXPR QTD_VERSION "(${QT_VERSION_MAJOR} << 16) + (${QT_VERSION_MINOR} << 8) + ${QT_VERSION_PATCH}") include_directories(${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) +if(${BUILD_QT_QWT}) + include_directories(${QWT_INCLUDE_PATH}) +endif() # System specifc settings. if(CMAKE_HOST_WIN32) @@ -342,30 +363,30 @@ set(all_req_found 1) if(BUILD_QT_${package_upper}) - foreach(req ${required}) - set(req_found) - foreach(pack ${packages_big}) - if(${pack} STREQUAL ${req}) - set(req_found 1) - endif() - endforeach(pack ${packages}) - if(NOT req_found) + foreach(req ${required}) set(req_found) - foreach(pack ${all_packages}) - if(${pack} STREQUAL ${req}) - set(req_found 1) - endif(${pack} STREQUAL ${req}) - endforeach(pack ${all_packages}) - if(req_found) - message(STATUS "Package '${package_big}' requires '${req}', but it is not active") - else() - message(STATUS "Package '${package_big}' requires '${req}', but it is not found") + foreach(pack ${packages_big}) + if(${pack} STREQUAL ${req}) + set(req_found 1) endif() - set(all_req_found) - endif() - endforeach(req ${required}) + endforeach(pack ${packages}) + if(NOT req_found) + set(req_found) + foreach(pack ${all_packages}) + if(${pack} STREQUAL ${req}) + set(req_found 1) + endif(${pack} STREQUAL ${req}) + endforeach(pack ${all_packages}) + if(req_found) + message(STATUS "Package '${package_big}' requires '${req}', but it is not active") + else() + message(STATUS "Package '${package_big}' requires '${req}', but it is not found") + endif() + set(all_req_found) + endif() + endforeach(req ${required}) else(BUILD_QT_${package_upper}) - set(all_req_found) + set(all_req_found) endif(BUILD_QT_${package_upper}) if("${all_req_found}" EQUAL 1)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build/qwt.txt Sat Jul 10 21:54:44 2010 +0100 @@ -0,0 +1,23 @@ +set(required Core Gui) + +set(classes + QwtPlot + QwtPlotDict + QwtPlotItem + QwtLegendItemManager + QwtText + QwtLegend + QwtScaleMap + QwtScaleWidget + QwtScaleTransformation + QwtTextLabel + QwtScaleDraw + QwtAbstractScaleDraw + QwtPlotCanvas + QwtPlotMarker + QwtPlotCurve + QwtData + QwtPolygonFData + QwtArrayData + QwtCPointerData + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/qwt/simpleplot/build.sh Sat Jul 10 21:54:44 2010 +0100 @@ -0,0 +1,3 @@ +#! /bin/bash + +dmd simple.d -L-lqtdqwt -L-lqtdgui -L-lqtdcore -L-lcpp_qwt -L-lcpp_core -L-lcpp_gui -L-lqwt-qt4 -L-lQtGui -L-lQtCore -ofsimple
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/qwt/simpleplot/simple.d Sat Jul 10 21:54:44 2010 +0100 @@ -0,0 +1,131 @@ +module simple; + +import std.math; + +import qt.gui.QApplication; +import qt.qwt.QwtPlot; +import qt.qwt.QwtPlotMarker; +import qt.qwt.QwtPlotCurve; +import qt.qwt.QwtLegend; +import qt.qwt.QwtData; +import qt.qwt.QwtText; + +//----------------------------------------------------------------- +// simple.d +// +// A simple example which shows how to use QwtPlot and QwtData +//----------------------------------------------------------------- + +real mysin(real arg) +{ + return sin(arg); +} + +real mycos(real arg) +{ + return cos(arg); +} + +alias real function(real) double_func; + +class SimpleData: QwtData +{ + // The x values depend on its index and the y values + // can be calculated from the corresponding x value. + // So we don't need to store the values. + // Such an implementation is slower because every point + // has to be recalculated for every replot, but it demonstrates how + // QwtData can be used. + +public: + this(const double_func y, size_t size) + { + d_size = size; + d_y = y; + } + + QwtData copy() const + { + return new SimpleData(d_y, d_size); + } + + size_t size() const + { + return d_size; + } + + double x(size_t i) const + { + return 0.1 * i; + } + + double y(size_t i) const + { + return d_y(x(i)); + } +private: + size_t d_size; + const double_func d_y; +}; + +class Plot : QwtPlot +{ +public: + this() + { + super(cast(QWidget)null); + setTitle("A Simple QwtPlot Demonstration"); + insertLegend(new QwtLegend(cast(QWidget)null), QwtPlot.RightLegend); + + // Set axis titles + setAxisTitle(xBottom, "x -."); + setAxisTitle(yLeft, "y -."); + + // Insert new curves + auto cSin = new QwtPlotCurve("y = sin(x)"); + cSin.setRenderHint(QwtPlotItem.RenderAntialiased); + cSin.setPen(new QPen(new QColor(Qt.red))); + cSin.attach(this); + + auto cCos = new QwtPlotCurve("y = cos(x)"); + cCos.setRenderHint(QwtPlotItem.RenderAntialiased); + cCos.setPen(new QPen(new QColor(Qt.blue))); + cCos.attach(this); + + // Create sin and cos data + const int nPoints = 100; + cSin.setData(new SimpleData(&mysin, nPoints)); + cCos.setData(new SimpleData(&mycos, nPoints)); + + // Insert markers + + // ...a horizontal line at y = 0... + auto mY = new QwtPlotMarker(); + mY.setLabel(new QwtText("y = 0")); + mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop); + mY.setLineStyle(QwtPlotMarker.HLine); + mY.setYValue(0.0); + mY.attach(this); + + // ...a vertical line at x = 2 * pi + auto mX = new QwtPlotMarker(); + mX.setLabel(new QwtText("x = 2 pi")); + mX.setLabelAlignment(Qt.AlignLeft | Qt.AlignBottom); + mX.setLabelOrientation(Qt.Vertical); + mX.setLineStyle(QwtPlotMarker.VLine); + mX.setLinePen(new QPen(new QBrush(Qt.black), 0, Qt.DashDotLine)); + mX.setXValue(2.0 * PI); + mX.attach(this); + } + +}; + +int main(string[] args) +{ + auto a = new QApplication(args); + + scope plot = new Plot; + plot.resize(600,400); + plot.show(); + return a.exec(); +}
--- a/generator/CMakeLists.txt Fri Jul 09 20:24:24 2010 +0100 +++ b/generator/CMakeLists.txt Sat Jul 10 21:54:44 2010 +0100 @@ -140,7 +140,7 @@ ) ## Includes path. -set(inc_paths +set(inc_paths_for_build ${CMAKE_CURRENT_SOURCE_DIR}/../common ${CMAKE_CURRENT_SOURCE_DIR}/parser ${CMAKE_CURRENT_SOURCE_DIR} @@ -158,8 +158,8 @@ include(${QT_USE_FILE} ${CMAKE_CURRENT_SOURCE_DIR}) -set(inc_paths - ${inc_paths} +set(inc_paths_for_build + ${inc_paths_for_build} ${QT_INCLUDES} ) set(lib_paths @@ -176,7 +176,7 @@ set (all_srcs ${srcs} ${moc_srcs} ${res_wrapped_files}) -include_directories(${inc_paths}) +include_directories(${inc_paths_for_build}) add_executable(generator ${all_srcs} ) target_link_libraries(generator ${libs}) @@ -201,17 +201,23 @@ file(REMOVE ${jambi_inc}) file(APPEND ${dgen_build_conf} "<typesystem>\n") foreach(package_normal ${packages}) - string(TOLOWER ${package_normal} package) - string(TOUPPER ${package_normal} package_upper) - file(APPEND ${dgen_build_conf} " <load-typesystem name=\"typesystem_${package}.xml\" generate=\"yes\" />\n") - file(APPEND ${jambi_inc} "#include <${QT_QT${package_upper}_INCLUDE_DIR}/Qt${package_normal}>\n") - endforeach(package_normal ${packages}) + string(TOLOWER ${package_normal} package) + string(TOUPPER ${package_normal} package_upper) + file(APPEND ${dgen_build_conf} " <load-typesystem name=\"typesystem_${package}.xml\" generate=\"yes\" />\n") + # only append include if we have QT_QT${MODULE}_INCLUDE_DIR defined, otherwise handle customly + if(NOT ${QT_QT${package_upper}_INCLUDE_DIR} STREQUAL "") + file(APPEND ${jambi_inc} "#include <${QT_QT${package_upper}_INCLUDE_DIR}/Qt${package_normal}>\n") + endif() + endforeach() file(APPEND ${dgen_build_conf} "</typesystem>\n") set(packages_in_build_txt ${packages} CACHE INTERNAL "") -endif( NOT "${packages_in_build_txt}" STREQUAL "${packages}" - OR NOT EXISTS ${dgen_build_conf} - OR NOT EXISTS ${jambi_inc}) - + # merge include file for Qwt + if(BUILD_QT_QWT) + file(READ "${CMAKE_SOURCE_DIR}/include/qwt_masterinclude.h" jambi_inc_qwt) + file(APPEND ${jambi_inc} ${jambi_inc_qwt}) + endif() +endif() + set(gen_sources) foreach(package_normal ${packages}) string(TOLOWER ${package_normal} package) @@ -219,25 +225,22 @@ set(d_inc_file_found d_inc_file_found-NOTFOUND) find_file(d_inc_file_found typesystem_${package}-java.java PATHS ${CMAKE_CURRENT_SOURCE_DIR}/) if(d_inc_file_found) - set(gen_sources ${gen_sources} ${d_inc_file_found}) - endif(d_inc_file_found) -endforeach(package_normal ${packages}) + set(gen_sources ${gen_sources} ${d_inc_file_found}) + endif() +endforeach() mark_as_advanced(d_inc_file_found) set(d_inc_file_found 1) -if(CMAKE_HOST_WIN32) - set(sep ";") -else(CMAKE_HOST_WIN32) - set(sep ":") -endif(CMAKE_HOST_WIN32) foreach(path ${QT_INCLUDES}) - set(inc_paths ${path}${sep}) -endforeach(path ${QT_INCLUDES}) + set(inc_paths_tmp ${path}${sep}) +endforeach() +set(inc_paths ${inc_paths}${sep}${inc_paths_tmp}) + if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) set(out_dir ${CMAKE_SOURCE_DIR}) -else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) +else() set(out_dir ${CMAKE_BINARY_DIR}/build) -endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) +endif() set(dgen_impl ${out_dir}/cpp/qt_core/ArrayOps_shell.cpp) add_custom_command(OUTPUT ${dgen_impl} COMMAND ${CMAKE_COMMAND} -E remove -f ${dgen_impl}
--- a/generator/abstractmetalang.cpp Fri Jul 09 20:24:24 2010 +0100 +++ b/generator/abstractmetalang.cpp Sat Jul 10 21:54:44 2010 +0100 @@ -2048,15 +2048,16 @@ return; m_instance = new ArgumentReplace(); - m_instance->data["version"] = "_version"; - m_instance->data["parent"] = "_parent"; - m_instance->data["delegate"] = "_delegate"; - m_instance->data["align"] = "_align"; - m_instance->data["in"] = "_in"; - m_instance->data["out"] = "_out"; - m_instance->data["scope"] = "_scope"; - m_instance->data["default"] = "_default"; - m_instance->data["body"] = "_body"; + m_instance->data["version"] = "version_"; + m_instance->data["parent"] = "parent_"; + m_instance->data["delegate"] = "delegate_"; + m_instance->data["align"] = "align_"; + m_instance->data["in"] = "in_"; + m_instance->data["out"] = "out_"; + m_instance->data["scope"] = "scope_"; + m_instance->data["default"] = "default_"; + m_instance->data["body"] = "body_"; + m_instance->data["ref"] = "ref_"; } QString ArgumentReplace::translate(QString arg)
--- a/generator/cppimplgenerator.cpp Fri Jul 09 20:24:24 2010 +0100 +++ b/generator/cppimplgenerator.cpp Sat Jul 10 21:54:44 2010 +0100 @@ -3164,6 +3164,8 @@ } else { // qtd s << fromObject(java_type->typeEntry(), // qtd (java_type->isReference() ? "&" : "") + qt_name) << endl; + if (java_type->isReference()) + s << "&"; s << qt_name << ";" << endl; } }
--- a/generator/dgenerator.cpp Fri Jul 09 20:24:24 2010 +0100 +++ b/generator/dgenerator.cpp Sat Jul 10 21:54:44 2010 +0100 @@ -71,7 +71,7 @@ << "signed short" << "Array" << "GLuint" << "GLenum" << "GLint" << "unsigned long" << "ulong" << "long" << "QByteRef" << "QStringList" << "QVector" << "QPair" - << "QSet" << "QStringRef" << "quintptr"; + << "QSet" << "QStringRef" << "quintptr" << "size_t"; } QString DGenerator::fileNameForClass(const AbstractMetaClass *d_class) const
--- a/generator/typesystem_core.xml Fri Jul 09 20:24:24 2010 +0100 +++ b/generator/typesystem_core.xml Sat Jul 10 21:54:44 2010 +0100 @@ -111,6 +111,8 @@ <primitive-type name="signed short" java-name="short" preferred-conversion="no" jni-name="jchar"/> <primitive-type name="unsigned short" java-name="ushort" preferred-conversion="no" jni-name="jchar"/> + <primitive-type name="size_t" java-name="size_t" jni-name="jsize_t"/> + <primitive-type name="char" java-name="char" jni-name="jbyte"/> <primitive-type name="signed char" java-name="byte" preferred-conversion="no" jni-name="jbyte"/> <primitive-type name="unsigned char" java-name="ubyte" preferred-conversion="no" jni-name="jbyte"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/generator/typesystem_qwt.xml Sat Jul 10 21:54:44 2010 +0100 @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet type="text/xsl" href="merge.xsl"?> + +<typesystem package="qt.qwt" default-superclass="QtdObject"> +<depend package="qt.core" /> +<depend package="qt.gui" /> + +<enum-type name="QwtAbstractScaleDraw::ScaleComponent" /> +<enum-type name="QwtPlot::Axis" /> +<enum-type name="QwtPlot::LegendPosition" /> +<enum-type name="QwtPlotItem::RttiValues" /> +<enum-type name="QwtPlotItem::ItemAttribute" /> +<enum-type name="QwtPlotItem::RenderHint" /> +<enum-type name="QwtLegend::LegendDisplayPolicy" /> +<enum-type name="QwtScaleTransformation::Type" /> +<enum-type name="QwtScaleDraw::Alignment" /> +<enum-type name="QwtText::TextFormat" /> +<enum-type name="QwtText::PaintAttribute" /> +<enum-type name="QwtText::LayoutAttribute" /> +<enum-type name="QwtPlotCanvas::PaintAttribute" /> +<enum-type name="QwtPlotCanvas::FocusIndicator" /> +<enum-type name="QwtPlotMarker::LineStyle"/> +<enum-type name="QwtPlotCurve::CurveType"/> +<enum-type name="QwtPlotCurve::CurveStyle"/> +<enum-type name="QwtPlotCurve::CurveAttribute"/> +<enum-type name="QwtPlotCurve::PaintAttribute"/> + +<object-type name="QwtPlot"/> +<interface-type name="QwtPlotDict"/> +<object-type name="QwtPlotItem"/> +<object-type name="QwtLegendItemManager"/> +<value-type name="QwtText"> + <modify-function signature="QwtText(QString, QwtText::TextFormat)"> + <modify-argument index="1"> + <replace-default-expression with=""""/> + </modify-argument> + </modify-function> +</value-type> + +<object-type name="QwtLegend"/> + +<value-type name="QwtScaleMap"/> + +<object-type name="QwtScaleWidget"/> + +<object-type name="QwtScaleTransformation"/> + +<object-type name="QwtTextLabel"/> + +<object-type name="QwtScaleDraw"> + <modify-function signature="operator=(QwtScaleDraw)" remove="all"/> +</object-type> + +<object-type name="QwtAbstractScaleDraw"> + <modify-function signature="operator=(QwtAbstractScaleDraw)" remove="all"/> +</object-type> + +<object-type name="QwtPlotCanvas"/> + +<object-type name="QwtPlotMarker"/> + +<object-type name="QwtPlotCurve"> +</object-type> + +<object-type name="QwtData"> + <modify-function signature="operator=(QwtData)" remove="all"/> +</object-type> + +<object-type name="QwtPolygonFData"> + <modify-function signature="operator=(QwtPolygonFData)" remove="all"/> +</object-type> + +<object-type name="QwtArrayData"> + <modify-function signature="operator=(QwtArrayData)" remove="all"/> +</object-type> + +<object-type name="QwtCPointerData"> + <modify-function signature="operator=(QwtCPointerData)" remove="all"/> +</object-type> + + +<!-- +QwtPlotPrintFilter +QwtScaleDiv +QwtPlotLayout +QwtTextEngine + +--> + +<!-- <object-type name=""/> --> + +</typesystem>
--- a/include/qtd_core.h Fri Jul 09 20:24:24 2010 +0100 +++ b/include/qtd_core.h Sat Jul 10 21:54:44 2010 +0100 @@ -84,6 +84,12 @@ #define QTD_WEBKIT_DLL_PUBLIC QTD_DLL_IMPORT #endif +#ifdef QTD_QWT + #define QTD_QWT_DLL_PUBLIC QTD_DLL_EXPORT +#else + #define QTD_QWT_DLL_PUBLIC QTD_DLL_IMPORT +#endif + //TODO: ditch struct QModelIndexAccessor { int row;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/qwt_masterinclude.h Sat Jul 10 21:54:44 2010 +0100 @@ -0,0 +1,70 @@ +#include <qwt_abstract_scale_draw.h> +#include <qwt_abstract_scale.h> +#include <qwt_abstract_slider.h> +#include <qwt_analog_clock.h> +#include <qwt_array.h> +#include <qwt_arrow_button.h> +#include <qwt_clipper.h> +#include <qwt_color_map.h> +#include <qwt_compass.h> +#include <qwt_compass_rose.h> +#include <qwt_counter.h> +#include <qwt_curve_fitter.h> +#include <qwt_data.h> +#include <qwt_dial.h> +#include <qwt_dial_needle.h> +#include <qwt_double_interval.h> +#include <qwt_double_range.h> +#include <qwt_double_rect.h> +#include <qwt_dyngrid_layout.h> +#include <qwt_event_pattern.h> +#include <qwt_global.h> +#include <qwt_interval_data.h> +#include <qwt_knob.h> +#include <qwt_layout_metrics.h> +#include <qwt_legend.h> +#include <qwt_legend_item.h> +#include <qwt_legend_itemmanager.h> +#include <qwt_magnifier.h> +#include <qwt_math.h> +#include <qwt_paint_buffer.h> +#include <qwt_painter.h> +#include <qwt_panner.h> +#include <qwt_picker.h> +#include <qwt_picker_machine.h> +#include <qwt_plot_canvas.h> +#include <qwt_plot_curve.h> +#include <qwt_plot_dict.h> +#include <qwt_plot_grid.h> +#include <qwt_plot.h> +#include <qwt_plot_item.h> +#include <qwt_plot_layout.h> +#include <qwt_plot_magnifier.h> +#include <qwt_plot_marker.h> +#include <qwt_plot_panner.h> +#include <qwt_plot_picker.h> +#include <qwt_plot_printfilter.h> +#include <qwt_plot_rasteritem.h> +#include <qwt_plot_rescaler.h> +#include <qwt_plot_scaleitem.h> +#include <qwt_plot_spectrogram.h> +#include <qwt_plot_svgitem.h> +#include <qwt_plot_zoomer.h> +#include <qwt_polygon.h> +#include <qwt_raster_data.h> +#include <qwt_round_scale_draw.h> +#include <qwt_scale_div.h> +#include <qwt_scale_draw.h> +#include <qwt_scale_engine.h> +#include <qwt_scale_map.h> +#include <qwt_scale_widget.h> +#include <qwt_slider.h> +#include <qwt_spline.h> +#include <qwt_symbol.h> +#include <qwt_text_engine.h> +#include <qwt_text.h> +#include <qwt_text_label.h> +#include <qwt_thermo.h> +#include <qwt_valuelist.h> +#include <qwt_wheel.h> +