25
25
#include " qgsgrassplugin.h"
26
26
27
27
#include < cmath>
28
- #include < typeinfo>
29
28
30
29
#include < QDir>
31
30
#include < QDomDocument>
@@ -280,19 +279,19 @@ void QgsGrassMapcalc::mousePressEvent( QMouseEvent* e )
280
279
{
281
280
--it;
282
281
283
- if ( typeid ( **it ) == typeid ( QgsGrassMapcalcConnector ) )
282
+ if ( QgsGrassMapcalcConnector *con = dynamic_cast <QgsGrassMapcalcConnector *>( *it ) )
284
283
{
285
- mConnector = dynamic_cast <QgsGrassMapcalcConnector *>( *it ) ;
284
+ mConnector = con ;
286
285
mConnector ->setSelected ( true );
287
286
mConnector ->selectEnd ( p );
288
287
mStartMoveConnectorPoints [0 ] = mConnector ->point ( 0 );
289
288
mStartMoveConnectorPoints [1 ] = mConnector ->point ( 1 );
290
289
291
290
break ;
292
291
}
293
- else if ( typeid ( **it ) == typeid ( QgsGrassMapcalcObject ) )
292
+ else if ( QgsGrassMapcalcObject *obj = dynamic_cast <QgsGrassMapcalcObject *>( *it ) )
294
293
{
295
- mObject = dynamic_cast <QgsGrassMapcalcObject *>( *it ) ;
294
+ mObject = obj ;
296
295
mObject ->setSelected ( true );
297
296
298
297
int tool = Select;
@@ -991,17 +990,13 @@ void QgsGrassMapcalc::growCanvas( int left, int right, int top, int bottom )
991
990
{
992
991
--it;
993
992
994
- if ( typeid ( **it ) == typeid ( QgsGrassMapcalcObject ) )
993
+ if ( QgsGrassMapcalcObject *obj = dynamic_cast <QgsGrassMapcalcObject *>( *it ) )
995
994
{
996
- QgsGrassMapcalcObject *obj = dynamic_cast <QgsGrassMapcalcObject *>( *it );
997
-
998
995
QPoint p = obj->center ();
999
996
obj->setCenter ( p.x () + left, p.y () + top );
1000
997
}
1001
- else if ( typeid ( **it ) == typeid ( QgsGrassMapcalcConnector ) )
998
+ else if ( QgsGrassMapcalcConnector *con = dynamic_cast <QgsGrassMapcalcConnector *>( *it ) )
1002
999
{
1003
- QgsGrassMapcalcConnector *con = dynamic_cast <QgsGrassMapcalcConnector *>( *it );
1004
-
1005
1000
for ( int i = 0 ; i < 2 ; i++ )
1006
1001
{
1007
1002
QPoint p = con->point ( i );
@@ -1162,10 +1157,8 @@ void QgsGrassMapcalc::save()
1162
1157
{
1163
1158
--it;
1164
1159
1165
- if ( typeid ( **it ) == typeid ( QgsGrassMapcalcObject ) )
1160
+ if ( QgsGrassMapcalcObject *obj = dynamic_cast <QgsGrassMapcalcObject *>( *it ) )
1166
1161
{
1167
- QgsGrassMapcalcObject *obj = dynamic_cast <QgsGrassMapcalcObject *>( *it );
1168
-
1169
1162
QString type;
1170
1163
if ( obj->type () == QgsGrassMapcalcObject::Map )
1171
1164
{
@@ -1212,10 +1205,8 @@ void QgsGrassMapcalc::save()
1212
1205
}
1213
1206
stream << " />\n " ;
1214
1207
}
1215
- else if ( typeid ( **it ) == typeid ( QgsGrassMapcalcConnector ) )
1208
+ else if ( QgsGrassMapcalcConnector *con = dynamic_cast <QgsGrassMapcalcConnector *>( *it ) )
1216
1209
{
1217
- QgsGrassMapcalcConnector *con = dynamic_cast <QgsGrassMapcalcConnector *>( *it );
1218
-
1219
1210
stream << " <connector id=\" " + QString::number ( con->id () )
1220
1211
+ " \" >\n " ;
1221
1212
@@ -1914,7 +1905,9 @@ QString QgsGrassMapcalcObject::expression()
1914
1905
1915
1906
/* ************************ CONNECTOR **********************************/
1916
1907
QgsGrassMapcalcConnector::QgsGrassMapcalcConnector ( QGraphicsScene *canvas )
1917
- : QGraphicsLineItem(), QgsGrassMapcalcItem()
1908
+ : QGraphicsLineItem()
1909
+ , QgsGrassMapcalcItem()
1910
+ , mSelectedEnd( -1 )
1918
1911
{
1919
1912
QgsDebugMsg ( " entered." );
1920
1913
@@ -2042,11 +2035,8 @@ bool QgsGrassMapcalcConnector::tryConnectEnd( int end )
2042
2035
{
2043
2036
--it;
2044
2037
2045
- if ( typeid ( **it ) == typeid ( QgsGrassMapcalcObject ) )
2046
- {
2047
- object = dynamic_cast <QgsGrassMapcalcObject *>( *it );
2038
+ if (( object = dynamic_cast <QgsGrassMapcalcObject *>( *it ) ) )
2048
2039
break ;
2049
- }
2050
2040
}
2051
2041
2052
2042
// try to connect
@@ -2117,10 +2107,13 @@ QgsGrassMapcalcObject *QgsGrassMapcalcConnector::object( int end )
2117
2107
/* ************************ FUNCTION *****************************/
2118
2108
QgsGrassMapcalcFunction::QgsGrassMapcalcFunction ( int type, QString name,
2119
2109
int count, QString description, QString label, QString labels,
2120
- bool drawLabel ) :
2121
- mName( name ), mType( type ), mInputCount( count ),
2122
- mLabel( label ), mDescription( description ),
2123
- mDrawLabel( drawLabel )
2110
+ bool drawLabel )
2111
+ : mName( name )
2112
+ , mType( type )
2113
+ , mInputCount( count )
2114
+ , mLabel( label )
2115
+ , mDescription( description )
2116
+ , mDrawLabel( drawLabel )
2124
2117
{
2125
2118
if ( mLabel .isEmpty () )
2126
2119
mLabel = mName ;
@@ -2131,6 +2124,17 @@ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name,
2131
2124
}
2132
2125
}
2133
2126
2127
+ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction ()
2128
+ : mType( 0 )
2129
+ , mInputCount( 0 )
2130
+ , mDrawLabel( false )
2131
+ {
2132
+ }
2133
+
2134
+ QgsGrassMapcalcFunction::~QgsGrassMapcalcFunction ()
2135
+ {
2136
+ }
2137
+
2134
2138
/* ******************* CANVAS VIEW ******************************/
2135
2139
2136
2140
QgsGrassMapcalcView::QgsGrassMapcalcView ( QgsGrassMapcalc * mapcalc,
0 commit comments