diff --git a/README.txt b/README.txt index 01c4187..b49d4d6 100644 --- a/README.txt +++ b/README.txt @@ -18,7 +18,27 @@ - Description: + ----------------------------------------------------------------------------------- + INSTALLATION: + ----------------------------------------------------------------------------------- + + run + qmake + make + make install + to build and install the widget. + + To make the widget available for the designer, please copy + lib/libskyplotwidgetdesigner.so into your qt-designer's library directory. + Linux users may check the environment-variable QT_PLUGIN_PATH. + + + + + + ----------------------------------------------------------------------------------- + Usage: + ----------------------------------------------------------------------------------- Each satellite can be painted with a circle, a ring around the circle and a label. The satellites are addressed with an id. diff --git a/SkyplotWidget.pro b/SkyplotWidget.pro index c34d9cd..9cd0f93 100644 --- a/SkyplotWidget.pro +++ b/SkyplotWidget.pro @@ -1,29 +1,5 @@ -TARGET = skyplotwidget -TEMPLATE = lib -CONFIG += qt warn_on debug designer plugin static -MOC_DIR = tmp -OBJECTS_DIR = tmp -INCLUDEPATH = include -DEPENDPATH = include src -DESTDIR = lib -QT += - - -unix:VERSION = 1.0.0 - - -#win32:TEMPLATE = vclib -win32:CONFIG += dll -win32:dll:DEFINES += QT_DLL -win32:QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_STL - - -# Input -HEADERS += include/SkyplotWidget.h \ - include/SkyplotWidgetPlugin.h - -SOURCES += src/SkyplotWidget.cpp \ - src/SkyplotWidgetPlugin.cpp - - +TEMPLATE = subdirs +SUBDIRS += src/src.pro \ + plugin/plugin.pro \ + example/example.pro diff --git a/example/example.pro b/example/example.pro index b5f373b..29af5de 100644 --- a/example/example.pro +++ b/example/example.pro @@ -3,16 +3,11 @@ TEMPLATE = app CONFIG += qt warn_on debug MOC_DIR = tmp OBJECTS_DIR = tmp -INCLUDEPATH = . ../include/ DEPENDPATH = . DESTDIR = . QT += - - - +INCLUDEPATH = . ../include/ HEADERS += Window.h - SOURCES += main.cpp Window.cpp - LIBS += -L../lib -lskyplotwidget diff --git a/include/SkyplotWidget.h b/include/SkyplotWidget.h index c9a6090..f3cd264 100644 --- a/include/SkyplotWidget.h +++ b/include/SkyplotWidget.h @@ -1,5 +1,5 @@ // SkyplotWidget -// Copyright (C) 2011 Christian Haettich feddischson[at]gmx.com +// Copyright (C) 2011-2014 Christian Haettich feddischson[at]gmx.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,10 @@ #define MY_PI 3.141593 -class SkyplotWidget : public QWidget +#include "SkyplotWidget_global.h" + + +class SKYPLOTWIDGET_EXPORT SkyplotWidget : public QWidget { Q_OBJECT diff --git a/src/SkyplotWidgetPlugin.cpp b/plugin/SkyplotWidgetPlugin.cpp similarity index 88% rename from src/SkyplotWidgetPlugin.cpp rename to plugin/SkyplotWidgetPlugin.cpp index e13dd62..36ab502 100644 --- a/src/SkyplotWidgetPlugin.cpp +++ b/plugin/SkyplotWidgetPlugin.cpp @@ -1,5 +1,5 @@ // SkyplotWidget -// Copyright (C) 2011 Christian Haettich feddischson[at]gmx.com +// Copyright (C) 2011-2014 Christian Haettich feddischson[at]gmx.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -42,7 +42,7 @@ SkyplotWidgetPlugin::name ( void ) const QString SkyplotWidgetPlugin::includeFile ( void ) const { - return QString( "" ); + return QString( "SkyplotWidget.h" ); } QString @@ -61,14 +61,14 @@ SkyplotWidgetPlugin::icon ( void ) const QString SkyplotWidgetPlugin::toolTip ( void ) const { - return QString( "" ); + return QString( "Skyplot Widget" ); } QString SkyplotWidgetPlugin::whatsThis ( void ) const { - return QString( "" ); + return QString( "Skyplot Widget to visualize satellite position data" ); } diff --git a/include/SkyplotWidgetPlugin.h b/plugin/SkyplotWidgetPlugin.h similarity index 95% rename from include/SkyplotWidgetPlugin.h rename to plugin/SkyplotWidgetPlugin.h index b7c2fc2..bc3525d 100644 --- a/include/SkyplotWidgetPlugin.h +++ b/plugin/SkyplotWidgetPlugin.h @@ -1,5 +1,5 @@ // SkyplotWidget -// Copyright (C) 2011 Christian Haettich feddischson[at]gmx.com +// Copyright (C) 2011-2014 Christian Haettich feddischson[at]gmx.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public diff --git a/plugin/plugin.pro b/plugin/plugin.pro new file mode 100644 index 0000000..0a44f2f --- /dev/null +++ b/plugin/plugin.pro @@ -0,0 +1,22 @@ +TARGET = skyplotwidgetdesigner +TEMPLATE = lib +CONFIG += qt warn_on debug designer plugin +MOC_DIR = tmp +OBJECTS_DIR = tmp +DEPENDPATH = ../include ../src +DESTDIR = ../lib + +INCLUDEPATH += ../include +VERSION = 1.0.1 + + +#win32:TEMPLATE = vclib +win32:CONFIG += dll +win32:dll:DEFINES += QT_DLL +win32:QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_STL + + + +HEADERS += SkyplotWidgetPlugin.h ../include/SkyplotWidget.h +SOURCES += SkyplotWidgetPlugin.cpp ../src/SkyplotWidget.cpp + diff --git a/src/SkyplotWidget.cpp b/src/SkyplotWidget.cpp index 3f408fe..d6a4c47 100644 --- a/src/SkyplotWidget.cpp +++ b/src/SkyplotWidget.cpp @@ -1,5 +1,5 @@ // SkyplotWidget -// Copyright (C) 2011 Christian Haettich feddischson[at]gmx.com +// Copyright (C) 2011-2014 Christian Haettich feddischson[at]gmx.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -30,6 +30,9 @@ SkyplotWidget::SkyplotWidget(QWidget *parent) { p_antialiased = true; noBlinkingSats = 0; + + + // default values for the properties p_marginScale = 0.78; p_gridColor = QColor( 150, 150, 150, 255 ); p_gridWidth = 3; @@ -66,13 +69,18 @@ void SkyplotWidget::paintEvent(QPaintEvent *) { QSize widgetSize( this->size() ); QPainter painter(this); + QPalette p = palette(); float topMargin ; float leftMargin; float size; float satelliteSize; float fontSize; + float bottomMargin; + + float availableWidth = widgetSize.width (); + float availableHeight = widgetSize.height(); - if( widgetSize.height() > widgetSize.width() ) + if( availableHeight > availableWidth ) { size = widgetSize.width() * p_marginScale; topMargin = ( widgetSize.width() - widgetSize.width() * p_marginScale + widgetSize.height() - widgetSize.width() ) / 2; @@ -84,23 +92,25 @@ void SkyplotWidget::paintEvent(QPaintEvent *) leftMargin = ( widgetSize.height() - widgetSize.height() * p_marginScale + widgetSize.width() - widgetSize.height()) / 2; topMargin = ( widgetSize.height() - widgetSize.height() * p_marginScale ) / 2; } + satelliteSize = size * p_satScale; painter.setRenderHint(QPainter::Antialiasing, p_antialiased); painter.translate( leftMargin, topMargin ); fontSize = size * p_fontScale; - - - painter.setPen( QPen( p_gridColor, p_gridWidth ) ); painter.setFont( QFont( "Arial", (int)fontSize ) ); for( int i=0; i < p_ellipses; i++ ) { float radius = size / 2 - i * ( size / (2 * p_ellipses ) ); + painter.setPen( QPen( p_gridColor, p_gridWidth ) ); painter.drawEllipse( QPoint( size/2, size/2 ), (int)radius, (int)radius ); if( p_withGridLabels ) + { + painter.setPen( QPen( p.text( ).color( ), p_gridWidth ) ); painter.drawText( QPoint( size/2 + p_textMargin, size/2 - ( radius + p_textMargin ) ), QString("%1").arg( i * (90 / p_ellipses ) ) ); + } } @@ -108,7 +118,7 @@ void SkyplotWidget::paintEvent(QPaintEvent *) { QLineF line1; QLineF line2; - float angel = i * 90 / p_crosses; + float angle = i * 90 / p_crosses; line1.setP1( QPoint( size/2, size/2 ) ); line1.setLength( size/2 ); @@ -116,55 +126,63 @@ void SkyplotWidget::paintEvent(QPaintEvent *) QRectF textRect( 0, 0, 4 * fontSize, fontSize + 2 ); - line1.setAngle( angel + 90 ); + line1.setAngle( angle + 90 ); + painter.setPen( QPen( p_gridColor, p_gridWidth ) ); painter.drawLine( line1 ); if( p_withGridLabels ) { + painter.setPen( QPen( p.text( ).color( ), p_gridWidth ) ); line2 = QLineF( line1 ); line2.setLength( size/2 + 2 * fontSize ); textRect.moveCenter( line2.p2() ); if( i > 0 ) - painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - angel ) ); + painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - angle ) ); else painter.drawText( textRect, Qt::AlignCenter, QString( "N") ); } line1 = line1.normalVector(); + painter.setPen( QPen( p_gridColor, p_gridWidth ) ); painter.drawLine( line1 ); if( p_withGridLabels ) { + painter.setPen( QPen( p.text( ).color( ), p_gridWidth ) ); line2 = QLineF( line1 ); line2.setLength( size/2 + 2 * fontSize ); textRect.moveCenter( line2.p2() ); if( i > 0 ) - painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - 90 - angel ) ); + painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - 90 - angle ) ); else painter.drawText( textRect, Qt::AlignCenter, QString( "W") ); } line1 = line1.normalVector(); + painter.setPen( QPen( p_gridColor, p_gridWidth ) ); painter.drawLine( line1 ); if( p_withGridLabels ) { + painter.setPen( QPen( p.text( ).color( ), p_gridWidth ) ); line2 = QLineF( line1 ); line2.setLength( size/2 + 2 * fontSize ); textRect.moveCenter( line2.p2() ); if( i > 0 ) - painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - 180 - angel ) ); + painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - 180 - angle ) ); else painter.drawText( textRect, Qt::AlignCenter, QString( "S") ); } line1 = line1.normalVector(); + painter.setPen( QPen( p_gridColor, p_gridWidth ) ); painter.drawLine( line1 ); if( p_withGridLabels ) { + painter.setPen( QPen( p.text( ).color( ), p_gridWidth ) ); line2 = QLineF( line1 ); line2.setLength( size/2 + 2 * fontSize ); textRect.moveCenter( line2.p2() ); if( i > 0 ) - painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - 270 - angel ) ); + painter.drawText( textRect, Qt::AlignCenter, QString( "%1").arg( 360 - 270 - angle ) ); else painter.drawText( textRect, Qt::AlignCenter, QString( "E") ); } @@ -177,8 +195,6 @@ void SkyplotWidget::paintEvent(QPaintEvent *) - satelliteSize = size * p_satScale; - for( I_satellite i= satellites.begin(); i != satellites.end(); i++ ) { diff --git a/src/src.pro b/src/src.pro new file mode 100644 index 0000000..3841ce7 --- /dev/null +++ b/src/src.pro @@ -0,0 +1,36 @@ +TARGET = skyplotwidget +TEMPLATE = lib +CONFIG += qt warn_on debug +MOC_DIR = tmp +OBJECTS_DIR = tmp +INCLUDEPATH = ../include +DEPENDPATH = ../include ../src +DESTDIR = ../lib +HEADERS += ../include/SkyplotWidget.h +SOURCES += ../src/SkyplotWidget.cpp +VERSION = 1.0.1 + + +isEmpty(PREFIX) { + PREFIX=/usr/local +} + +unix { + INSTALLBASE = /usr/local/ +} + +win32 { + INSTALLBASE = C:/skyplotwidget-$$VERSION +} +headers.path = $$INSTALLBASE/include/ +target.path = $$INSTALLBASE/lib +headers.files = $$HEADERS + + + +#win32:TEMPLATE = vclib +win32:CONFIG += dll +win32:dll:DEFINES += QT_DLL +win32:QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_STL + +INSTALLS += target headers