Skip to content

Commit

Permalink
small modifications for a better build-support
Browse files Browse the repository at this point in the history
  • Loading branch information
feddischson committed Mar 14, 2014
1 parent c4c027c commit b5ec752
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 55 deletions.
22 changes: 21 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 4 additions & 28 deletions SkyplotWidget.pro
Original file line number Diff line number Diff line change
@@ -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

7 changes: 1 addition & 6 deletions example/example.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions include/SkyplotWidget.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -42,7 +42,7 @@ SkyplotWidgetPlugin::name ( void ) const
QString
SkyplotWidgetPlugin::includeFile ( void ) const
{
return QString( "" );
return QString( "SkyplotWidget.h" );
}

QString
Expand All @@ -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" );

}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 22 additions & 0 deletions plugin/plugin.pro
Original file line number Diff line number Diff line change
@@ -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

42 changes: 29 additions & 13 deletions src/SkyplotWidget.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -84,87 +92,97 @@ 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 ) ) );
}
}


for( int i=0; i < p_crosses; i ++ )
{
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 );


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") );
}
Expand All @@ -177,8 +195,6 @@ void SkyplotWidget::paintEvent(QPaintEvent *)



satelliteSize = size * p_satScale;


for( I_satellite i= satellites.begin(); i != satellites.end(); i++ )
{
Expand Down
36 changes: 36 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b5ec752

Please sign in to comment.