fix windows build, warnings, typos and roadgraph plugin indentation

git-svn-id: http://svn.osgeo.org/qgis/trunk@15071 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2011-01-24 16:33:27 +00:00
parent d29ac2476b
commit 656ca4ad6a
40 changed files with 1006 additions and 1000 deletions

View File

@ -1555,7 +1555,7 @@ You can take care of both with the PyQwt source from:
Double-click the tarball to unpack it. The following assumes PyQwt v5.2.0 (comes with Qwt 5.2.1).
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is staically linked
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is statically linked
into PyQwt, and Qgis can't use it. So, we need to split the build.
First edit qwtconfig.pri in the qwt-5.2 subdir and change some settings so

View File

@ -265,7 +265,7 @@ http://pyqwt.sourceforge.net/
```
Double-click the tarball to unpack it. The following assumes PyQwt v5.2.0 (comes with Qwt 5.2.1).
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is staically linked
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is statically linked
into PyQwt, and Qgis can't use it. So, we need to split the build.
First edit qwtconfig.pri in the qwt-5.2 subdir and change some settings so

View File

@ -56,7 +56,7 @@ static pysqlite_StatementKind detect_statement_type(char* statement)
dst = buf;
*dst = 0;
while (isalpha(*src) && dst - buf < sizeof(buf) - 2) {
*dst++ = tolower(*src++);
*dst++ = (char) tolower(*src++);
}
*dst = 0;

View File

@ -2,7 +2,7 @@
RE=$(echo $(cut -d: -f1 scripts/spelling.dat | sed -e 's/^/\\</; s/$/\\>|/;') | sed -e 's/| /|/g; s/|$//;')
EX="\.(svn-base|tmp|xpm|ts)|context_help|spelling\.dat"
EX="\.(svn-base|tmp|xpm|ts)|context_help|spelling\.dat|Exception_to_GPL_for_Qt.txt|sqlite3.c"
egrep --color=always "$RE" -ir . | egrep -iv "$EX"
egrep --color=always "$RE" -i resources/context_help/*-en_US

View File

@ -1596,7 +1596,7 @@ string ASBeautifier::beautify(const string &originalLine)
/*
* Create a temporary snapshot of the current block's header-list in the
* uppermost inner stack in tempStacks, and clear the headerStack up to
* the begining of the block.
* the beginning of the block.
* Thus, the next future statement will think it comes one indent past
* the block's '{' unless it specifically checks for a companion-header
* (such as a previous 'if' for an 'else' header) within the tempStacks,
@ -1758,7 +1758,7 @@ string ASBeautifier::beautify(const string &originalLine)
if (lineCommentNoBeautify || blockCommentNoBeautify || isInQuoteContinuation)
tabCount = spaceTabCount = 0;
// finally, insert indentations into begining of line
// finally, insert indentations into beginning of line
prevFinalLineSpaceTabCount = spaceTabCount;
prevFinalLineTabCount = tabCount;
@ -1897,7 +1897,7 @@ const string *ASBeautifier::findHeader(const string &line, int i, const vector<c
if (line.compare(i, header->length(), header->c_str()) == 0)
{
// check that this is a header and not a part of a longer word
// (e.g. not at its begining, not at its middle...)
// (e.g. not at its beginning, not at its middle...)
int lineLength = line.length();
int headerEnd = i + header->length();

View File

@ -475,7 +475,7 @@ bool ASEnhancer::findKeyword(const string &line, int i, const char *keyword) con
if (line.compare(i, strlen(keyword), keyword) == 0)
{
// check that this is a header and not a part of a longer word
// (e.g. not at its begining, not at its middle...)
// (e.g. not at its beginning, not at its middle...)
int lineLength = line.length();
int wordEnd = i + strlen(keyword);

View File

@ -180,7 +180,7 @@ void ASFormatter::staticInit()
*
* init() should be called every time a ASFormatter object is to start
* formatting a NEW source file.
* init() recieves a pointer to a DYNAMICALLY CREATED ASSourceIterator object
* init() receives a pointer to a DYNAMICALLY CREATED ASSourceIterator object
* that will be used to iterate through the source code. This object will be
* deleted during the ASFormatter's destruction, and thus should not be
* deleted elsewhere.
@ -307,7 +307,7 @@ string ASFormatter::nextLine()
}
else // stuff to do when reading a new character...
{
// make sure that a virgin '{' at the begining ofthe file will be treated as a block...
// make sure that a virgin '{' at the beginning ofthe file will be treated as a block...
if (isInVirginLine && currentChar == '{' && lineBeginsWith('{'))
previousCommandChar = '{';
isPreviousCharPostComment = isCharImmediatelyPostComment;
@ -322,7 +322,7 @@ string ASFormatter::nextLine()
{
appendCurrentChar();
// explicitely break a line when a line comment's end is found.
// explicitly break a line when a line comment's end is found.
if (charNum + 1 == (int) currentLine.length())
{
isInLineBreak = true;
@ -404,7 +404,7 @@ string ASFormatter::nextLine()
formattedLineCommentNum = formattedLine.length();
appendSequence(AS_OPEN_LINE_COMMENT);
goForward(1);
// explicitely break a line when a line comment's end is found.
// explicitly break a line when a line comment's end is found.
if (charNum + 1 == (int) currentLine.length())
{
isInLineBreak = true;
@ -448,7 +448,7 @@ string ASFormatter::nextLine()
previousCommandChar = previousNonWSChar = previousChar = '{';
// check if in preprocessor
// ** isInPreprocessor will be automatically reset at the begining
// ** isInPreprocessor will be automatically reset at the beginning
// of a new line in getnextChar()
if (isCStyle && currentChar == '#')
{
@ -1263,7 +1263,7 @@ bool ASFormatter::isBeforeLineEndComment(int startPos) const
* get the next character, increasing the current placement in the process.
* the new character is inserted into the variable currentChar.
*
* @return whether succeded to recieve the new character.
* @return whether succeded to receive the new character.
*/
bool ASFormatter::getNextChar()
{

View File

@ -90,7 +90,7 @@ class CORE_EXPORT QgsPalLayerSettings
Hali, //horizontal alignment for data defined label position (Left, Center, Right)
Vali, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
LabelDistance,
Rotation //data defined rotation (only usefull in connection with data defined position)
Rotation //data defined rotation (only useful in connection with data defined position)
};
QString fieldName;

View File

@ -377,7 +377,7 @@ extern "C"
char *Name; /* field name */
unsigned char Type; /* field type */
int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
unsigned char Length; /* field total lenght [in bytes] */
unsigned char Length; /* field total length [in bytes] */
unsigned char Decimals; /* decimal positions */
gaiaValuePtr Value; /* the current multitype value for this attribute */
struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */

View File

@ -4448,7 +4448,7 @@ SQLITE_API int sqlite3_release_memory(int);
** <li> Memory accounting is disabled using a combination of the
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
** <li> An alternative page cache implementation is specifed using
** <li> An alternative page cache implementation is specified using
** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
** <li> The page cache allocates from its own memory pool supplied
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than

View File

@ -424,7 +424,7 @@ struct sqlite3_api_routines {
/*
** The following macros redefine the API routines so that they are
** redirected throught the global sqlite3_api structure.
** redirected through the global sqlite3_api structure.
**
** This header file is also used by the loadext.c source file
** (part of the main SQLite library - not an extension) so that

View File

@ -4556,7 +4556,7 @@ SQLITE_API int sqlite3_release_memory(int);
** <li> Memory accounting is disabled using a combination of the
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
** <li> An alternative page cache implementation is specifed using
** <li> An alternative page cache implementation is specified using
** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
** <li> The page cache allocates from its own memory pool supplied
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
@ -6717,7 +6717,7 @@ struct sqlite3_api_routines {
/*
** The following macros redefine the API routines so that they are
** redirected throught the global sqlite3_api structure.
** redirected through the global sqlite3_api structure.
**
** This header file is also used by the loadext.c source file
** (part of the main SQLite library - not an extension) so that
@ -7533,7 +7533,7 @@ extern "C"
char *Name; /* field name */
unsigned char Type; /* field type */
int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
unsigned char Length; /* field total lenght [in bytes] */
unsigned char Length; /* field total length [in bytes] */
unsigned char Decimals; /* decimal positions */
gaiaValuePtr Value; /* the current multitype value for this attribute */
struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */

View File

@ -99,7 +99,7 @@ INCLUDE_DIRECTORIES(
../analysis/interpolation
../plugins/diagram_overlay
.
)
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(BEFORE ../core/spatialite/headers/spatialite)

View File

@ -629,6 +629,8 @@ QList<QDomElement> QgsProjectParser::legendGroupElements() const
{
groupList.push_back( groupNodeList.at( i ).toElement() );
}
return groupList;
}
QMap< QString, QDomElement > QgsProjectParser::projectLayerElementsById() const

View File

@ -88,7 +88,7 @@ QgsMapLayer* QgsRemoteOWSBuilder::createMapLayer( const QDomElement& elem, const
if ( serviceName == "WFS" )
{
//support for old format where type is explicitely given and not part of url
//support for old format where type is explicitly given and not part of url
QString tname = onlineResourceElement.attribute( "type" );
if ( !tname.isEmpty() )
{

View File

@ -28,6 +28,7 @@ SET (VRP_RCCS roadgraph.qrc)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${GEOS_INCLUDE_DIR}
../../core
../../gui
..

View File

@ -31,23 +31,23 @@ RgExportDlg::RgExportDlg( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
// create base widgets;
setWindowTitle( tr("Export feature") );
setWindowTitle( tr( "Export feature" ) );
QVBoxLayout *v = new QVBoxLayout( this );
QHBoxLayout *h = new QHBoxLayout();
QLabel *l = new QLabel( tr("Select destination layer:"), this);
h->addWidget(l);
QLabel *l = new QLabel( tr( "Select destination layer:" ), this );
h->addWidget( l );
mcbLayers = new QComboBox( this );
h->addWidget(mcbLayers);
v->addLayout(h);
h->addWidget( mcbLayers );
v->addLayout( h );
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
connect(bb, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted()) );
connect(bb, SIGNAL(rejected()), this, SLOT(on_buttonBox_rejected()) );
v->addWidget(bb);
QDialogButtonBox *bb = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
connect( bb, SIGNAL( accepted() ), this, SLOT( on_buttonBox_accepted() ) );
connect( bb, SIGNAL( rejected() ), this, SLOT( on_buttonBox_rejected() ) );
v->addWidget( bb );
//fill list of layers
mcbLayers->insertItem( 0, tr("new temporary layer"), QVariant("-1") );
mcbLayers->insertItem( 0, tr( "new temporary layer" ), QVariant( "-1" ) );
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
@ -73,21 +73,22 @@ QgsVectorLayer* RgExportDlg::mapLayer() const
QgsVectorLayer* myLayer = NULL;
QString layerId = mcbLayers->itemData( mcbLayers->currentIndex() ).toString();
if ( layerId == QString("-1") )
if ( layerId == QString( "-1" ) )
{
// create a temporary layer
myLayer = new QgsVectorLayer( "LineString", "shortest path", "memory" );
QgsVectorDataProvider *prov = myLayer->dataProvider();
if ( prov == NULL)
if ( prov == NULL )
return NULL;
QList<QgsField> attrList;
attrList.append( QgsField("one", QVariant::Int) );
attrList.append( QgsField( "one", QVariant::Int ) );
prov->addAttributes( attrList );
QgsMapLayerRegistry::instance()->addMapLayer( myLayer );
}else
}
else
{
// retrun selected layer
myLayer = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );

View File

@ -35,20 +35,20 @@ class QgsVectorLayer;
class RgExportDlg : public QDialog
{
Q_OBJECT
public:
public:
RgExportDlg( QWidget* parent = 0, Qt::WFlags fl = 0 );
~RgExportDlg();
public:
public:
QgsVectorLayer* mapLayer() const;
private:
private:
static const int context_id = 0;
private slots:
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
private:
private:
QComboBox *mcbLayers;
};
#endif

View File

@ -32,7 +32,7 @@
*/
class RgGraphBuilder
{
public:
public:
//! Destructor
virtual ~RgGraphBuilder()
{};

View File

@ -31,7 +31,7 @@ class RgGraphBuilder;
*/
class RgGraphDirector
{
public:
public:
//! Destructor
virtual ~RgGraphDirector() { };

View File

@ -82,7 +82,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
vl->select( la );
QgsFeature feature;
while ( vl->nextFeature(feature) )
while ( vl->nextFeature( feature ) )
{
QgsAttributeMap attr = feature.attributeMap();
RgLineVectorLayerSettings::DirectionType directionType = mSettings.mDefaultDirection;
@ -110,7 +110,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
}
// What speed have feature?
double speed = 0.0;
for (it = attr.constBegin(); it != attr.constEnd(); ++it)
for ( it = attr.constBegin(); it != attr.constEnd(); ++it )
{
if ( it.key() != speedFieldId )
{
@ -118,7 +118,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
}
speed = it.value().toDouble();
}
if (speed <= 0.0)
if ( speed <= 0.0 )
{
speed = mSettings.mDefaultSpeed;
}
@ -126,7 +126,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
// begin features segments and add arc to the Graph;
QgsPoint pt1, pt2;
bool isFirstPoint=true;
bool isFirstPoint = true;
QgsPolyline pl = feature.geometry()->asPolyline();
QgsPolyline::iterator pointIt;
for ( pointIt = pl.begin(); pointIt != pl.end(); ++pointIt )
@ -137,16 +137,16 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
if ( directionType == RgLineVectorLayerSettings::FirstPointToLastPoint ||
directionType == RgLineVectorLayerSettings::Both )
{
builder->addArc(pt1, pt2, speed*su.multipler() );
builder->addArc( pt1, pt2, speed*su.multipler() );
}
if (directionType == RgLineVectorLayerSettings::LastPointToFirstPoint ||
if ( directionType == RgLineVectorLayerSettings::LastPointToFirstPoint ||
directionType == RgLineVectorLayerSettings::Both )
{
builder->addArc( pt2, pt1, speed*su.multipler() );
}
}
pt1 = pt2;
isFirstPoint=false;
isFirstPoint = false;
} // for (it = pl.begin(); it != pl.end(); ++it)
} // while( vl->nextFeature(feature) )

View File

@ -32,7 +32,7 @@ class RgGraphBuilder;
*/
class RgLineVectorLayerDirector : public RgGraphDirector
{
public:
public:
RgLineVectorLayerDirector();
//! Destructor
virtual ~RgLineVectorLayerDirector();
@ -44,7 +44,7 @@ public:
RgSettings* settings();
QString name() const;
private:
private:
/**
* settings of this director
*/

View File

@ -44,11 +44,11 @@ bool RgLineVectorLayerSettings::test()
// implement me
// check default speed
if (mDefaultSpeed <= 0.0)
if ( mDefaultSpeed <= 0.0 )
{
return false;
}
if (mLayer == "")
if ( mLayer == "" )
{
return false;
}
@ -69,17 +69,17 @@ void RgLineVectorLayerSettings::read( const QgsProject *project )
mSpeed = project->readEntry( "roadgraphplugin", "/speedField" );
mDefaultSpeed = project->readDoubleEntry( "roadgraphplugin", "/defaultSpeed" );
mLayer = project->readEntry( "roadgraphplugin", "/layer" );
mSpeedUnitName= project->readEntry( "roadgraphplugin","/speedUnitName" );
mSpeedUnitName = project->readEntry( "roadgraphplugin", "/speedUnitName" );
if (dd == 1)
if ( dd == 1 )
{
mDefaultDirection = FirstPointToLastPoint;
}
else if (dd == 2)
else if ( dd == 2 )
{
mDefaultDirection = LastPointToFirstPoint;
}
else if (dd == 3)
else if ( dd == 3 )
{
mDefaultDirection = Both;
}
@ -109,7 +109,7 @@ QWidget* RgLineVectorLayerSettings::getGui( QWidget *parent )
void RgLineVectorLayerSettings::setFromGui( QWidget *myGui )
{
RgLineVectorLayerSettingsWidget* w = dynamic_cast<RgLineVectorLayerSettingsWidget*>( myGui );
if (w == NULL)
if ( w == NULL )
return;
mFirstPointToLastPointDirectionVal = w->mleFirstPointToLastPointDirection->text();

View File

@ -19,7 +19,7 @@
// Qgis includes
// standart includes
// standard includes
// forward declaration Qgis-classes
class QWidget;
@ -34,14 +34,14 @@ class QWidget;
class RgLineVectorLayerSettings: public RgSettings
{
public:
public:
/**
* \enum DirectionType
* \brief DirectionType enumeration discribe
*/
enum DirectionType { FirstPointToLastPoint=1, LastPointToFirstPoint=2, Both=3 };
enum DirectionType { FirstPointToLastPoint = 1, LastPointToFirstPoint = 2, Both = 3 };
public:
public:
/**
* default constructor.
*/
@ -51,7 +51,7 @@ public:
* destructor
*/
~RgLineVectorLayerSettings();
public:
public:
/*
* MANDATORY SETTINGS PROPERTY DECLARATIONS
*/
@ -60,7 +60,7 @@ public:
bool test();
QWidget *getGui( QWidget* Parent );
void setFromGui( QWidget* );
public:
public:
/**
* contained Layer name

View File

@ -37,78 +37,78 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
: QWidget( parent )
{
// create base widgets;
QTabWidget *tab = new QTabWidget(this);
QVBoxLayout *v= new QVBoxLayout(this);
v->addWidget(tab);
QTabWidget *tab = new QTabWidget( this );
QVBoxLayout *v = new QVBoxLayout( this );
v->addWidget( tab );
// transportation layer
QFrame *frame = new QFrame(this);
tab->addTab( frame, tr("Transportation layer") );
v = new QVBoxLayout(frame);
QLabel *l = new QLabel(tr("Layer"), frame);
mcbLayers = new QComboBox(frame);
QHBoxLayout *h = new QHBoxLayout(this);
QFrame *frame = new QFrame( this );
tab->addTab( frame, tr( "Transportation layer" ) );
v = new QVBoxLayout( frame );
QLabel *l = new QLabel( tr( "Layer" ), frame );
mcbLayers = new QComboBox( frame );
QHBoxLayout *h = new QHBoxLayout( this );
h->addWidget(l);
h->addWidget(mcbLayers);
v->addLayout(h);
h->addWidget( l );
h->addWidget( mcbLayers );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr("Direction field"), frame );
mcbDirection = new QComboBox(frame);
h->addWidget(l);
h->addWidget(mcbDirection);
v->addLayout(h);
l = new QLabel( tr( "Direction field" ), frame );
mcbDirection = new QComboBox( frame );
h->addWidget( l );
h->addWidget( mcbDirection );
v->addLayout( h );
h = new QHBoxLayout();
h->addWidget( new QLabel( tr("Direct direction"), frame) );
h->addWidget( new QLabel( tr( "Direct direction" ), frame ) );
mleFirstPointToLastPointDirection = new QLineEdit( s->mFirstPointToLastPointDirectionVal, frame );
h->addWidget( mleFirstPointToLastPointDirection );
v->addLayout(h);
v->addLayout( h );
h = new QHBoxLayout();
h->addWidget( new QLabel( tr("Reverse direction"), frame) );
h->addWidget( new QLabel( tr( "Reverse direction" ), frame ) );
mleLastPointToFirstPointDirection = new QLineEdit( s->mLastPointToFirstPointDirectionVal, frame );
h->addWidget( mleLastPointToFirstPointDirection );
v->addLayout(h);
v->addLayout( h );
h = new QHBoxLayout();
h->addWidget( new QLabel( tr("Both direction"), frame) );
h->addWidget( new QLabel( tr( "Both direction" ), frame ) );
mleBothDirection = new QLineEdit( s->mBothDirectionVal, frame );
h->addWidget( mleBothDirection );
v->addLayout(h);
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr("Speed field"), frame );
mcbSpeed = new QComboBox(frame);
h->addWidget(l);
h->addWidget(mcbSpeed);
v->addLayout(h);
l = new QLabel( tr( "Speed field" ), frame );
mcbSpeed = new QComboBox( frame );
h->addWidget( l );
h->addWidget( mcbSpeed );
v->addLayout( h );
frame = new QFrame(tab);
tab->addTab( frame, tr("Default settings") );
v = new QVBoxLayout(frame);
frame = new QFrame( tab );
tab->addTab( frame, tr( "Default settings" ) );
v = new QVBoxLayout( frame );
h = new QHBoxLayout();
l = new QLabel( tr("Direction"), frame );
mcbDirectionDefault = new QComboBox(frame);
mcbDirectionDefault->insertItem( 0, tr("Both direction") );
mcbDirectionDefault->insertItem( 1, tr("Direct direction") );
mcbDirectionDefault->insertItem( 2, tr("Reverse direction") );
connect( mcbLayers, SIGNAL(currentIndexChanged(int)), this, SLOT(on_mcbLayers_selectItem()) );
l = new QLabel( tr( "Direction" ), frame );
mcbDirectionDefault = new QComboBox( frame );
mcbDirectionDefault->insertItem( 0, tr( "Both direction" ) );
mcbDirectionDefault->insertItem( 1, tr( "Direct direction" ) );
mcbDirectionDefault->insertItem( 2, tr( "Reverse direction" ) );
connect( mcbLayers, SIGNAL( currentIndexChanged( int ) ), this, SLOT( on_mcbLayers_selectItem() ) );
h->addWidget(l);
h->addWidget(mcbDirectionDefault);
v->addLayout(h);
h->addWidget( l );
h->addWidget( mcbDirectionDefault );
v->addLayout( h );
h = new QHBoxLayout(frame);
l = new QLabel( tr("Cost"), frame );
h->addWidget(l);
l = new QLabel( tr("lines length"), frame );
h->addWidget(l);
v->addLayout(h);
h = new QHBoxLayout( frame );
l = new QLabel( tr( "Cost" ), frame );
h->addWidget( l );
l = new QLabel( tr( "lines length" ), frame );
h->addWidget( l );
v->addLayout( h );
h = new QHBoxLayout(frame);
l = new QLabel( tr("Speed"), frame );
h = new QHBoxLayout( frame );
l = new QLabel( tr( "Speed" ), frame );
msbSpeedDefault = new QSpinBox( frame );
msbSpeedDefault->setMinimum( 1 );
msbSpeedDefault->setMaximum( 10000000 );
@ -116,21 +116,21 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
h->addWidget( msbSpeedDefault );
v->addLayout( h );
frame = new QFrame(tab);
tab->addTab( frame, tr("Units") );
frame = new QFrame( tab );
tab->addTab( frame, tr( "Units" ) );
v = new QVBoxLayout( frame );
h = new QHBoxLayout();
l = new QLabel( tr("Unit of speed") );
mcbUnitOfSpeed = new QComboBox(this);
h->addWidget(l);
l = new QLabel( tr( "Unit of speed" ) );
mcbUnitOfSpeed = new QComboBox( this );
h->addWidget( l );
h->addWidget( mcbUnitOfSpeed );
v->addLayout( h );
mcbUnitOfSpeed->insertItem( 0, tr("km/h") );
mcbUnitOfSpeed->insertItem( 0, tr("m/s") );
mcbUnitOfSpeed->insertItem( 0, tr( "km/h" ) );
mcbUnitOfSpeed->insertItem( 0, tr( "m/s" ) );
if ( s->mSpeedUnitName == "km/h" )
mcbUnitOfSpeed->setCurrentIndex( 1 );
else if (s->mSpeedUnitName == "m/s" )
else if ( s->mSpeedUnitName == "m/s" )
mcbUnitOfSpeed->setCurrentIndex( 0 );
// fill list of layers
@ -151,30 +151,30 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
msbSpeedDefault->setValue( static_cast<int>( s->mDefaultSpeed ) );
int idx = mcbLayers->findText( s->mLayer );
if (idx != -1)
if ( idx != -1 )
{
mcbLayers->setCurrentIndex( idx );
}
idx = mcbDirection->findText( s->mDirection );
if (idx != -1)
if ( idx != -1 )
mcbDirection->setCurrentIndex( idx );
idx = mcbSpeed->findText( s->mSpeed );
if (idx != -1)
if ( idx != -1 )
mcbSpeed->setCurrentIndex( idx );
switch( s->mDefaultDirection )
switch ( s->mDefaultDirection )
{
case RgLineVectorLayerSettings::Both:
mcbDirectionDefault->setCurrentIndex(0);
mcbDirectionDefault->setCurrentIndex( 0 );
break;
case RgLineVectorLayerSettings::FirstPointToLastPoint:
mcbDirectionDefault->setCurrentIndex(1);
mcbDirectionDefault->setCurrentIndex( 1 );
break;
case RgLineVectorLayerSettings::LastPointToFirstPoint:
mcbDirectionDefault->setCurrentIndex(2);
mcbDirectionDefault->setCurrentIndex( 2 );
break;
}
} // RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget()
@ -203,8 +203,8 @@ void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
mcbDirection->clear();
mcbSpeed->clear();
mcbDirection->insertItem( 0, tr("Always use default") );
mcbSpeed->insertItem( 0, tr("Always use default") );
mcbDirection->insertItem( 0, tr( "Always use default" ) );
mcbSpeed->insertItem( 0, tr( "Always use default" ) );
QgsVectorLayer* vl = selectedLayer();
if ( !vl )
@ -216,17 +216,17 @@ void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
const QgsFieldMap& fields = provider->fields();
QgsFieldMap::const_iterator it;
for (it = fields.constBegin(); it != fields.constEnd(); ++it)
for ( it = fields.constBegin(); it != fields.constEnd(); ++it )
{
QgsField currentField = it.value();
QVariant currentType = currentField.type();
if ( currentType == QVariant::Int || currentType == QVariant::String )
{
mcbDirection->insertItem(1, currentField.name());
mcbDirection->insertItem( 1, currentField.name() );
}
if ( currentType == QVariant::Int || currentType == QVariant::Double )
{
mcbSpeed->insertItem(1, currentField.name());
mcbSpeed->insertItem( 1, currentField.name() );
}
}

View File

@ -39,16 +39,16 @@ class QgsVectorLayer;
class RgLineVectorLayerSettingsWidget : public QWidget
{
Q_OBJECT
public:
public:
RgLineVectorLayerSettingsWidget( RgLineVectorLayerSettings *s, QWidget* parent = 0 );
private slots:
private slots:
void on_mcbLayers_selectItem();
private:
private:
QgsVectorLayer * selectedLayer();
public:
public:
/**
* list of passible layers
*/

View File

@ -45,7 +45,7 @@
#include <QVBoxLayout>
#include <QDebug>
// standart includes
// standard includes
static const char * const sIdent = "$Id: roadgraphplugin.cpp 9327 2009-04-20 10:09:44Z YEKST $";
static const QString sName = QObject::tr( "Road graph plugin" );
@ -92,13 +92,13 @@ void RoadGraphPlugin::initGui()
// Create the action for tool
mQSettingsAction = new QAction( QIcon( ":/roadgraph/road.png" ), tr( "Road graph settings" ), this );
mQShowDirectionAction = new QAction( QIcon( ":/roadgraph/showdirect.png" ), tr("Show roads direction"), this );
mQShowDirectionAction = new QAction( QIcon( ":/roadgraph/showdirect.png" ), tr( "Show roads direction" ), this );
mInfoAction = new QAction( QIcon( ":/roadgraph/about.png" ), tr( "About" ), this );
// Set the what's this text
mQSettingsAction->setWhatsThis( tr("Road graph plugin settings") );
mQShowDirectionAction->setWhatsThis( tr("Roads direction viewer") );
mInfoAction->setWhatsThis( tr("About Road graph plugin") );
mQSettingsAction->setWhatsThis( tr( "Road graph plugin settings" ) );
mQShowDirectionAction->setWhatsThis( tr( "Roads direction viewer" ) );
mInfoAction->setWhatsThis( tr( "About Road graph plugin" ) );
mQShowDirectionAction->setCheckable( true );
@ -116,7 +116,7 @@ void RoadGraphPlugin::initGui()
mQGisIface->addPluginToMenu( tr( "Road graph" ), mQShowDirectionAction );
mQGisIface->addPluginToMenu( tr( "Road graph" ), mInfoAction );
connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete(QPainter*) ), this, SLOT( render(QPainter*) ) );
connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) );
connect( mQGisIface, SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
connect( mQGisIface , SIGNAL( newProjectCreated() ), this, SLOT( newProject() ) );
// load settings
@ -127,13 +127,13 @@ void RoadGraphPlugin::initGui()
void RoadGraphPlugin::unload()
{
// remove the GUI
mQGisIface->removePluginMenu( tr("Road graph"), mQSettingsAction );
mQGisIface->removePluginMenu( tr("Road graph"), mQShowDirectionAction );
mQGisIface->removePluginMenu( tr( "Road graph" ), mQSettingsAction );
mQGisIface->removePluginMenu( tr( "Road graph" ), mQShowDirectionAction );
mQGisIface->removeToolBarIcon( mQShowDirectionAction );
// disconnect
disconnect( mQGisIface->mapCanvas(), SIGNAL( renderComplete(QPainter*) ), this, SLOT( render(QPainter*) ) );
disconnect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) );
disconnect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
disconnect( mQGisIface->mainWindow(), SIGNAL( newProject() ), this, SLOT( newProject() ) );
@ -166,7 +166,7 @@ void RoadGraphPlugin::newProject()
void RoadGraphPlugin::property()
{
RgSettingsDlg dlg(mDirector, mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
RgSettingsDlg dlg( mDirector, mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
dlg.setTimeUnitName( mTimeUnitName );
dlg.setDistanceUnitName( mDistanceUnitName );
@ -251,7 +251,7 @@ const RgGraphDirector* RoadGraphPlugin::director() const
{
return mDirector;
}
void RoadGraphPlugin::render(QPainter *painter)
void RoadGraphPlugin::render( QPainter *painter )
{
if ( mDirector == NULL )
return;
@ -275,22 +275,22 @@ void RoadGraphPlugin::render(QPainter *painter)
x2 = p2.x(),
y2 = p2.y();
double length = sqrt( pow( x2-x1, 2.0) + pow( y2-y1, 2.0 ) );
double Cos = (x2-x1)/length;
double Sin = (y2-y1)/length;
double centerX = (x1+x2)/2;
double centerY = (y1+y2)/2;
double length = sqrt( pow( x2 - x1, 2.0 ) + pow( y2 - y1, 2.0 ) );
double Cos = ( x2 - x1 ) / length;
double Sin = ( y2 - y1 ) / length;
double centerX = ( x1 + x2 ) / 2;
double centerY = ( y1 + y2 ) / 2;
double r = mArrowSize;
QPointF pt1(centerX - Sin*r, centerY + Cos*r);
QPointF pt2(centerX + Sin*r, centerY - Cos*r);
QPointF pt1( centerX - Sin*r, centerY + Cos*r );
QPointF pt2( centerX + Sin*r, centerY - Cos*r );
QVector<QPointF> tmp;
tmp.resize(3);
tmp[0] = QPointF( centerX + Cos*r*2, centerY + Sin*r*2 );
tmp.resize( 3 );
tmp[0] = QPointF( centerX + Cos * r * 2, centerY + Sin * r * 2 );
tmp[1] = pt1;
tmp[2] = pt2;
painter->drawPolygon(tmp);
painter->drawPolygon( tmp );
}
}

View File

@ -41,7 +41,7 @@ class RgShortestPathWidget;
class RoadGraphPlugin: public QObject, public QgisPlugin
{
Q_OBJECT
public:
public:
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
@ -70,8 +70,8 @@ public:
*/
QString distanceUnitName();
public slots:
void render(QPainter *painter);
public slots:
void render( QPainter *painter );
//! init the gui
virtual void initGui();
@ -92,19 +92,19 @@ public slots:
//! show about window
void about();
private slots:
private slots:
/**
* set show roads direction
*/
void onShowDirection();
private:
private:
/**
* set all gui elements to default status
*/
void setGuiElementsToDefault( );
private:
private:
////////////////////////////////////////////////////////////////////
//
@ -153,7 +153,7 @@ private:
* distance unit for results presentation
*/
QString mDistanceUnitName;
private:
private:
static const int mArrowSize = 5;
};

View File

@ -30,7 +30,7 @@ class QgsProject;
*/
class RgSettings
{
public:
public:
//! Destructor
virtual ~RgSettings() { };

View File

@ -27,21 +27,21 @@
//standard includes
RgSettingsDlg::RgSettingsDlg( RgGraphDirector *director, QWidget* parent, Qt::WFlags fl )
: mDirector(director), QDialog( parent, fl )
: mDirector( director ), QDialog( parent, fl )
{
// create base widgets;
setWindowTitle( tr("Road graph plugins settings") );
setWindowTitle( tr( "Road graph plugins settings" ) );
QVBoxLayout *v = new QVBoxLayout( this );
QHBoxLayout *h = new QHBoxLayout();
QLabel *l = new QLabel( tr("Plugins time unit:"), this );
QLabel *l = new QLabel( tr( "Plugins time unit:" ), this );
h->addWidget( l );
mcbPluginsTimeUnit = new QComboBox( this );
h->addWidget( mcbPluginsTimeUnit );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr("Plugins distance unit:"), this );
l = new QLabel( tr( "Plugins distance unit:" ), this );
h->addWidget( l );
mcbPluginsDistanceUnit = new QComboBox( this );
h->addWidget( mcbPluginsDistanceUnit );
@ -55,18 +55,18 @@ RgSettingsDlg::RgSettingsDlg( RgGraphDirector *director, QWidget* parent, Qt::WF
h->addWidget(mcbGraphDirector);
v->addLayout(h);
*/
mSettingsWidget = director->settings()->getGui(this);
mSettingsWidget = director->settings()->getGui( this );
v->addWidget( mSettingsWidget );
QDialogButtonBox *bb = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
connect( bb, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted()) );
connect( bb, SIGNAL(rejected()), this, SLOT(on_buttonBox_rejected()) );
connect( bb, SIGNAL( accepted() ), this, SLOT( on_buttonBox_accepted() ) );
connect( bb, SIGNAL( rejected() ), this, SLOT( on_buttonBox_rejected() ) );
v->addWidget( bb );
mcbPluginsTimeUnit->addItem( tr("second"), QVariant( "s" ) );
mcbPluginsTimeUnit->addItem( tr("hour"), QVariant( "h" ) );
mcbPluginsDistanceUnit->addItem( tr("meter"), QVariant( "m" ) );
mcbPluginsDistanceUnit->addItem( tr("kilometer"), QVariant( "km" ) );
mcbPluginsTimeUnit->addItem( tr( "second" ), QVariant( "s" ) );
mcbPluginsTimeUnit->addItem( tr( "hour" ), QVariant( "h" ) );
mcbPluginsDistanceUnit->addItem( tr( "meter" ), QVariant( "m" ) );
mcbPluginsDistanceUnit->addItem( tr( "kilometer" ), QVariant( "km" ) );
} // RgSettingsDlg::RgSettingsDlg()
@ -95,10 +95,10 @@ QString RgSettingsDlg::timeUnitName()
return mcbPluginsTimeUnit->itemData( mcbPluginsTimeUnit->currentIndex() ).toString();
}
void RgSettingsDlg::setTimeUnitName( const QString& name)
void RgSettingsDlg::setTimeUnitName( const QString& name )
{
int i = mcbPluginsTimeUnit->findData( QVariant( name ) );
if (i != -1)
if ( i != -1 )
{
mcbPluginsTimeUnit->setCurrentIndex( i );
}
@ -109,10 +109,10 @@ QString RgSettingsDlg::distanceUnitName()
return mcbPluginsDistanceUnit->itemData( mcbPluginsDistanceUnit->currentIndex() ).toString();
}
void RgSettingsDlg::setDistanceUnitName( const QString& name)
void RgSettingsDlg::setDistanceUnitName( const QString& name )
{
int i = mcbPluginsDistanceUnit->findData( QVariant( name ) );
if (i != -1)
if ( i != -1 )
{
mcbPluginsDistanceUnit->setCurrentIndex( i );
}

View File

@ -47,15 +47,15 @@ class RgSettingsDlg : public QDialog
void setDistanceUnitName( const QString& );
private:
private:
static const int context_id = 0;
private slots:
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
private:
private:
// futurame by used
QComboBox *mcbGraphDirector;

View File

@ -50,95 +50,95 @@
RgShortestPathWidget::RgShortestPathWidget( QWidget* theParent, RoadGraphPlugin *thePlugin ) : QDockWidget( theParent ), mPlugin( thePlugin )
{
setWindowTitle( tr("Shortest path") );
setWindowTitle( tr( "Shortest path" ) );
setObjectName( "ShortestPathDock" );
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
QWidget *myWidget = new QWidget(this);
QWidget *myWidget = new QWidget( this );
setWidget( myWidget );
QVBoxLayout *v = new QVBoxLayout( myWidget );
QHBoxLayout *h = NULL;
QLabel *l = NULL;
l = new QLabel(tr("Start:"), myWidget );
l = new QLabel( tr( "Start:" ), myWidget );
v->addWidget( l );
h = new QHBoxLayout();
mFrontPointLineEdit = new QLineEdit( myWidget );
mFrontPointLineEdit->setReadOnly( true );
QToolButton *selectFrontPoint = new QToolButton( myWidget );
selectFrontPoint->setCheckable( true );
selectFrontPoint->setIcon( QPixmap(":/roadgraph/coordinate_capture.png") );
selectFrontPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) );
h->addWidget( mFrontPointLineEdit );
h->addWidget( selectFrontPoint );
v->addLayout(h);
v->addLayout( h );
l = new QLabel(tr("Stop:"), myWidget );
l = new QLabel( tr( "Stop:" ), myWidget );
v->addWidget( l );
h = new QHBoxLayout();
mBackPointLineEdit = new QLineEdit( myWidget );
mBackPointLineEdit->setReadOnly( true );
QToolButton *selectBackPoint = new QToolButton( myWidget );
selectBackPoint->setCheckable( true );
selectBackPoint->setIcon( QPixmap(":/roadgraph/coordinate_capture.png") );
selectBackPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) );
h->addWidget( mBackPointLineEdit );
h->addWidget( selectBackPoint );
v->addLayout( h );
h = new QHBoxLayout( this );
l = new QLabel(tr("Criterion:"), myWidget );
l = new QLabel( tr( "Criterion:" ), myWidget );
mCriterionName = new QComboBox( myWidget );
mCriterionName->insertItem(0, tr("Length"));
mCriterionName->insertItem(1, tr("Time") );
mCriterionName->insertItem( 0, tr( "Length" ) );
mCriterionName->insertItem( 1, tr( "Time" ) );
h->addWidget( l );
h->addWidget( mCriterionName );
v->addLayout( h );
h = new QHBoxLayout( myWidget );
l = new QLabel( tr("Length:"), myWidget );
l = new QLabel( tr( "Length:" ), myWidget );
mPathCostLineEdit = new QLineEdit( myWidget );
mPathCostLineEdit->setReadOnly ( true );
mPathCostLineEdit->setReadOnly( true );
h->addWidget( l );
h->addWidget( mPathCostLineEdit );
v->addLayout( h );
h = new QHBoxLayout( myWidget );
l = new QLabel( tr("Time:"), myWidget );
l = new QLabel( tr( "Time:" ), myWidget );
mPathTimeLineEdit = new QLineEdit( myWidget );
mPathTimeLineEdit->setReadOnly ( true );
mPathTimeLineEdit->setReadOnly( true );
h->addWidget( l );
h->addWidget( mPathTimeLineEdit );
v->addLayout( h );
h = new QHBoxLayout( myWidget );
mCalculate = new QPushButton( tr("Calculate"), myWidget );
mCalculate = new QPushButton( tr( "Calculate" ), myWidget );
h->addWidget( mCalculate );
QPushButton *pbExport = new QPushButton( tr("Export"), myWidget );
QPushButton *pbExport = new QPushButton( tr( "Export" ), myWidget );
h->addWidget( pbExport );
connect( pbExport, SIGNAL( clicked(bool) ), this, SLOT(exportPath()) );
connect( pbExport, SIGNAL( clicked( bool ) ), this, SLOT( exportPath() ) );
mClear = new QPushButton( tr("Clear"), myWidget );
mClear = new QPushButton( tr( "Clear" ), myWidget );
h->addWidget( mClear );
v->addLayout( h );
v->addStretch();
mFrontPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() );
mFrontPointMapTool->setButton ( selectFrontPoint );
mFrontPointMapTool->setButton( selectFrontPoint );
mBackPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() );
mBackPointMapTool->setButton ( selectBackPoint );
mBackPointMapTool->setButton( selectBackPoint );
connect( selectFrontPoint, SIGNAL( clicked(bool) ), this, SLOT( onSelectFrontPoint() ) );
connect( selectFrontPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectFrontPoint() ) );
connect( mFrontPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ),
this, SLOT( setFrontPoint( const QgsPoint& ) ) );
connect( selectBackPoint, SIGNAL( clicked(bool) ), this, SLOT( onSelectBackPoint() ) );
connect( selectBackPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectBackPoint() ) );
connect( mBackPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ),
this, SLOT( setBackPoint( const QgsPoint& ) ) );
connect( mCalculate, SIGNAL(clicked(bool) ), this, SLOT( findingPath() ) );
connect( mClear, SIGNAL(clicked(bool)), this, SLOT(clear()) );
connect( mCalculate, SIGNAL( clicked( bool ) ), this, SLOT( findingPath() ) );
connect( mClear, SIGNAL( clicked( bool ) ), this, SLOT( clear() ) );
mrbFrontPoint = new QgsRubberBand( mPlugin->iface()->mapCanvas(), true );
mrbFrontPoint->setColor( Qt::green );
@ -151,7 +151,7 @@ RgShortestPathWidget::RgShortestPathWidget( QWidget* theParent, RoadGraphPlugin
mrbPath = new QgsRubberBand( mPlugin->iface()->mapCanvas(), false );
mrbPath->setWidth( 2 );
connect(mPlugin->iface()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( mapCanvasExtentsChanged() ) );
connect( mPlugin->iface()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( mapCanvasExtentsChanged() ) );
} //RgShortestPathWidget::RgShortestPathWidget()
RgShortestPathWidget::~RgShortestPathWidget()
@ -181,17 +181,17 @@ void RgShortestPathWidget::onSelectFrontPoint()
void RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
{
mPlugin->iface()->mapCanvas()->unsetMapTool( mFrontPointMapTool );
mFrontPointLineEdit->setText( QString("(")+QString().setNum(pt.x()) + QString(",") +
QString().setNum(pt.y()) + QString(")") );
mFrontPointLineEdit->setText( QString( "(" ) + QString().setNum( pt.x() ) + QString( "," ) +
QString().setNum( pt.y() ) + QString( ")" ) );
mFrontPoint = pt;
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel()*2;
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
mrbFrontPoint->reset(true);
mrbFrontPoint->addPoint( QgsPoint( pt.x()-mupp, pt.y()-mupp), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x()+mupp, pt.y()-mupp), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x()+mupp, pt.y()+mupp), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x()-mupp, pt.y()+mupp), true );
mrbFrontPoint->reset( true );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() + mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() + mupp ), true );
mrbFrontPoint->show();
} //RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
@ -205,41 +205,41 @@ void RgShortestPathWidget::setBackPoint( const QgsPoint& pt )
mPlugin->iface()->mapCanvas()->unsetMapTool( mBackPointMapTool );
mBackPoint = pt;
mBackPointLineEdit->setText( QString("(")+QString().setNum(pt.x()) + QString(",") +
QString().setNum(pt.y()) + QString(")") );
mBackPointLineEdit->setText( QString( "(" ) + QString().setNum( pt.x() ) + QString( "," ) +
QString().setNum( pt.y() ) + QString( ")" ) );
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel()*2;
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
mrbBackPoint->reset(true);
mrbBackPoint->addPoint( QgsPoint( pt.x()-mupp, pt.y()-mupp), false );
mrbBackPoint->addPoint( QgsPoint( pt.x()+mupp, pt.y()-mupp), false );
mrbBackPoint->addPoint( QgsPoint( pt.x()+mupp, pt.y()+mupp), false );
mrbBackPoint->addPoint( QgsPoint( pt.x()-mupp, pt.y()+mupp), true );
mrbBackPoint->reset( true );
mrbBackPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() - mupp ), false );
mrbBackPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() - mupp ), false );
mrbBackPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() + mupp ), false );
mrbBackPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() + mupp ), true );
mrbBackPoint->show();
}
bool RgShortestPathWidget::getPath(AdjacencyMatrix& matrix, QgsPoint& p1, QgsPoint& p2)
bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPoint& p2 )
{
if ( mFrontPointLineEdit->text().isNull() || mBackPointLineEdit->text().isNull() )
return false;
RgSimpleGraphBuilder builder;
builder.setDestinationCrs ( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs() );
mPlugin->director()->makeGraph(&builder);
builder.setDestinationCrs( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs() );
mPlugin->director()->makeGraph( &builder );
bool ok;
p1 = builder.tiePoint(mFrontPoint, ok);
p1 = builder.tiePoint( mFrontPoint, ok );
if ( !ok )
return false;
p2 = builder.tiePoint(mBackPoint, ok);
p2 = builder.tiePoint( mBackPoint, ok );
if ( !ok )
return false;
AdjacencyMatrix m = builder.adjacencyMatrix();
DijkstraFinder::OptimizationCriterion criterion = DijkstraFinder::byCost;
if (mCriterionName->currentIndex() == 1)
if ( mCriterionName->currentIndex() == 1 )
criterion = DijkstraFinder::byTime;
DijkstraFinder f(m, criterion);
DijkstraFinder f( m, criterion );
matrix = f.find( p1, p2 );
@ -250,7 +250,7 @@ void RgShortestPathWidget::findingPath()
{
QgsPoint p1, p2;
AdjacencyMatrix path;
if ( !getPath(path, p1, p2) )
if ( !getPath( path, p1, p2 ) )
return;
mrbPath->reset( false );
@ -275,28 +275,28 @@ void RgShortestPathWidget::findingPath()
Unit timeUnit = Unit::byName( mPlugin->timeUnitName() );
Unit distanceUnit = Unit::byName( mPlugin->distanceUnitName() );
mPathCostLineEdit->setText( QString().setNum( cost/distanceUnit.multipler() ) + distanceUnit.name() );
mPathTimeLineEdit->setText( QString().setNum( time/timeUnit.multipler() ) + timeUnit.name() );
mPathCostLineEdit->setText( QString().setNum( cost / distanceUnit.multipler() ) + distanceUnit.name() );
mPathTimeLineEdit->setText( QString().setNum( time / timeUnit.multipler() ) + timeUnit.name() );
mrbPath->setColor( Qt::red );
}
void RgShortestPathWidget::clear()
{
mFrontPointLineEdit->setText(QString());
mrbFrontPoint->reset(true);
mBackPointLineEdit->setText(QString());
mrbBackPoint->reset(true);
mFrontPointLineEdit->setText( QString() );
mrbFrontPoint->reset( true );
mBackPointLineEdit->setText( QString() );
mrbBackPoint->reset( true );
mrbPath->reset();
}
void RgShortestPathWidget::exportPath()
{
RgExportDlg dlg(this);
RgExportDlg dlg( this );
if ( !dlg.exec() )
return;
QgsPoint p1,p2;
QgsPoint p1, p2;
AdjacencyMatrix path;
if ( !getPath( path, p1, p2 ) )
return;

View File

@ -20,7 +20,7 @@
// Qgis includes
#include <qgspoint.h>
// standart includes
// standard includes
// forward declaration
@ -44,18 +44,18 @@ class RoadGraphPlugin;
class RgShortestPathWidget : public QDockWidget
{
Q_OBJECT
public:
public:
/**
* Standart construct
* Standard constructor
*/
RgShortestPathWidget( QWidget * , RoadGraphPlugin *);
RgShortestPathWidget( QWidget * , RoadGraphPlugin * );
/**
* destructor
*/
~RgShortestPathWidget();
private slots:
private slots:
/**
* export path
*/
@ -99,8 +99,8 @@ private slots:
/**
* retrun path as a graph
*/
bool getPath(AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2);
private:
bool getPath( AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2 );
private:
/**
* This line edit show front points coordinates
*/

View File

@ -49,17 +49,17 @@ void RgSimpleGraphBuilder::setDestinationCrs( const QgsCoordinateReferenceSystem
void RgSimpleGraphBuilder::addVertex( const QgsPoint& pt )
{
mMatrix[ mCoordinateTransform->transform(pt) ];
mMatrix[ mCoordinateTransform->transform( pt )];
}
void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed )
{
QgsPoint p1 = mCoordinateTransform->transform(pt1);
QgsPoint p2 = mCoordinateTransform->transform(pt2);
QgsPoint p1 = mCoordinateTransform->transform( pt1 );
QgsPoint p2 = mCoordinateTransform->transform( pt2 );
double distance = mDistanceArea->measureLine( p1, p2 );
double time = distance/speed;
mMatrix[ p1 ][ p2 ] = ArcAttributes(distance, time, 0);
double time = distance / speed;
mMatrix[ p1 ][ p2 ] = ArcAttributes( distance, time, 0 );
}
QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
@ -76,8 +76,8 @@ QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
for ( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
{
QgsPoint c;
double d = distance(it1->first, it2->first, pt, c);
if (d < min)
double d = distance( it1->first, it2->first, pt, c );
if ( d < min )
{
minP1 = it1->first;
minP2 = it2->first;
@ -93,18 +93,18 @@ QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
double t = mMatrix[ minP1 ][ minP2 ].mTime;
double newArcLength = mDistanceArea->measureLine( minP1, center );
mMatrix[ minP1 ][ center ] = ArcAttributes( newArcLength, t*newArcLength/c, 0);
mMatrix[ minP1 ][ center ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
newArcLength = mDistanceArea->measureLine( center, minP2 );
mMatrix[ center ][ minP2 ] = ArcAttributes( newArcLength, t*newArcLength/c, 0 );
mMatrix[ center ][ minP2 ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
if ( mMatrix[ minP2 ].find( minP1 ) != mMatrix[ minP2 ].end() )
{
c = mMatrix[ minP2 ][ minP1 ].mCost;
t = mMatrix[ minP2 ][ minP1 ].mTime;
newArcLength = mDistanceArea->measureLine( center, minP1 );
mMatrix[ center ][ minP1 ] = ArcAttributes( newArcLength, t*newArcLength/c, 0);
mMatrix[ center ][ minP1 ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
newArcLength = mDistanceArea->measureLine( minP2, center );
mMatrix[ minP2 ][ center ] = ArcAttributes( newArcLength, t*newArcLength/c, 0);
mMatrix[ minP2 ][ center ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
}
mMatrix[minP1].erase( minP2 );

View File

@ -34,7 +34,7 @@ class QgsCoordinateTransform;
class RgSimpleGraphBuilder : public RgGraphBuilder
{
public:
public:
/**
* default constructor
*/
@ -53,7 +53,7 @@ public:
* return Adjacecncy matrix;
*/
AdjacencyMatrix adjacencyMatrix();
private:
private:
AdjacencyMatrix mMatrix;
QgsDistanceArea* mDistanceArea;

View File

@ -23,8 +23,8 @@ Unit::Unit()
mMultipler = 1.0;
}
Unit::Unit(const QString& name, double multipler) :
mName(name), mMultipler(multipler)
Unit::Unit( const QString& name, double multipler ) :
mName( name ), mMultipler( multipler )
{
}
@ -37,7 +37,7 @@ double Unit::multipler() const
{
return mMultipler;
}
Unit Unit::byName( const QString& name)
Unit Unit::byName( const QString& name )
{
if ( name == "h" )
return Unit( name, 60*60 );
@ -51,12 +51,12 @@ Unit Unit::byName( const QString& name)
}
SpeedUnit::SpeedUnit() :
mTimeUnit("",1), mDistanceUnit("",1)
mTimeUnit( "", 1 ), mDistanceUnit( "", 1 )
{
}
SpeedUnit::SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit) :
SpeedUnit::SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit ) :
mTimeUnit( timeUnit ), mDistanceUnit( distanceUnit )
{
}
@ -65,21 +65,21 @@ QString SpeedUnit::name() const
{
if ( mDistanceUnit.name().isNull() || mTimeUnit.name().isNull() )
return QString();
return mDistanceUnit.name() + QString("/") + mTimeUnit.name();
return mDistanceUnit.name() + QString( "/" ) + mTimeUnit.name();
}
SpeedUnit SpeedUnit::byName( const QString& name )
{
if ( name=="km/h" )
return SpeedUnit( Unit::byName("km"), Unit::byName("h") );
else if ( name=="m/s" )
return SpeedUnit( Unit::byName("m"), Unit::byName("s") );
if ( name == "km/h" )
return SpeedUnit( Unit::byName( "km" ), Unit::byName( "h" ) );
else if ( name == "m/s" )
return SpeedUnit( Unit::byName( "m" ), Unit::byName( "s" ) );
return SpeedUnit();
}
double SpeedUnit::multipler() const
{
return mDistanceUnit.multipler()/mTimeUnit.multipler();
return mDistanceUnit.multipler() / mTimeUnit.multipler();
}
Unit SpeedUnit::timeUnit() const

View File

@ -32,7 +32,7 @@
*/
class Unit
{
public:
public:
/**
* default constructor
*/
@ -57,7 +57,7 @@ public:
* return unit by name
*/
static Unit byName( const QString& name );
private:
private:
/**
* units name
@ -72,7 +72,7 @@ private:
class SpeedUnit
{
public:
public:
SpeedUnit();
SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit );
@ -83,7 +83,7 @@ public:
Unit distanceUnit() const;
static SpeedUnit byName( const QString& name );
protected:
protected:
Unit mTimeUnit;
Unit mDistanceUnit;
};

View File

@ -22,7 +22,7 @@
// Qgis includes
#include <qgspoint.h>
// standart includes
// standard includes
#include <set>
#include <cmath>
@ -36,32 +36,32 @@ double distance( const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p, QgsP
{
// first line
double A1,B1,C1;
double A1, B1, C1;
A1 = p1.y() - p2.y();
B1 = p2.x() - p1.x();
C1 = p1.x()*(-A1) + p1.y()*(-B1);
C1 = p1.x() * ( -A1 ) + p1.y() * ( -B1 );
// second line. First and second line is perpendicular.
double A2,B2,C2;
double A2, B2, C2;
A2 = B1;
B2 = -A1;
C2 = -p.x()*A2 - p.y()*B2;
C2 = -p.x() * A2 - p.y() * B2;
// union point
double x,y,det;
det = A1*B2 - B1*A2;
x = (C2*B1 - B2*C1)/det;
y = (-A1*C2 + C1*A2)/det;
double x, y, det;
det = A1 * B2 - B1 * A2;
x = ( C2 * B1 - B2 * C1 ) / det;
y = ( -A1 * C2 + C1 * A2 ) / det;
center = QgsPoint(x,y);
center = QgsPoint( x, y );
det = sqrt(A1*A1+B1*B1);
det = sqrt( A1 * A1 + B1 * B1 );
A1 /= det;
B1 /= det;
C1 /= det;
if ( std::min( p1.x(), p2.x() ) <= x && std::max( p1.x(), p2.x() ) >= x &&
std::min( p1.y(), p2.y() ) <= y && std::max( p1.y(), p2.y() ) >= y )
return std::abs( A1*p.x()+B1*p.y()+C1 );
return std::abs( A1*p.x() + B1*p.y() + C1 );
return infinity();
}// RoadGraphPlugin::distance()
@ -85,7 +85,7 @@ ArcAttributes::ArcAttributes( double cost, double time, int featureId ) :
DijkstraFinder::DijkstraFinder( const AdjacencyMatrix& m, DijkstraFinder::OptimizationCriterion c ):
mAdjacencyMatrix (m), mCriterion(c)
mAdjacencyMatrix( m ), mCriterion( c )
{
}
@ -95,7 +95,7 @@ std::map< QgsPoint , DijkstraFinder::DijkstraIterator, QgsPointCompare> Dijkstra
std::set< DijkstraIterator, CompareDijkstraIterator > not_begin( ci );
std::set< DijkstraIterator, CompareDijkstraIterator >::iterator it;
std::map< QgsPoint, DijkstraIterator, QgsPointCompare> res;
if (mAdjacencyMatrix.find( p ) == mAdjacencyMatrix.end() )
if ( mAdjacencyMatrix.find( p ) == mAdjacencyMatrix.end() )
{
return res;
}
@ -122,13 +122,13 @@ std::map< QgsPoint , DijkstraFinder::DijkstraIterator, QgsPointCompare> Dijkstra
continue;
}
end = mAdjacencyMatrix.find( i.mBackPoint )->second.end();
for (arcIt = mAdjacencyMatrix.find( i.mBackPoint )->second.begin(); arcIt != end; ++arcIt)
for ( arcIt = mAdjacencyMatrix.find( i.mBackPoint )->second.begin(); arcIt != end; ++arcIt )
{
DijkstraIterator di = i;
di.mCost += arcIt->second.mCost;
di.mTime += arcIt->second.mTime;
if ( ci(di, res[ arcIt->first ] ) )
if ( ci( di, res[ arcIt->first ] ) )
{
di.mFrontPoint = di.mBackPoint;
di.mBackPoint = arcIt->first;

View File

@ -18,7 +18,7 @@
// Qgis includes
#include "qgspoint.h"
// standart includes
// standard includes
#include <map>
#include <set>
@ -35,7 +35,7 @@
double infinity();
/**
* return distance from lenght <x1,y1><x2,y2> to point <x,y> or infinity() value
* return distance from length <x1,y1><x2,y2> to point <x,y> or infinity() value
* in union point
*/
double distance( const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p, QgsPoint& center );
@ -47,7 +47,7 @@ double distance( const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p, QgsP
*/
class QgsPointCompare
{
public:
public:
bool operator()( const QgsPoint& a, const QgsPoint& b ) const;
};
@ -57,10 +57,10 @@ public:
*/
class ArcAttributes
{
public:
public:
ArcAttributes();
ArcAttributes( double cost, double time, int mFeatureId );
public:
public:
double mCost;
double mTime;
int mFeatureId;
@ -76,10 +76,11 @@ typedef std::map< QgsPoint, AdjacencyMatrixString, QgsPointCompare > AdjacencyM
*/
class DijkstraFinder
{
public:
enum OptimizationCriterion { byTime=1, byCost=2 };
private:
class DijkstraIterator {
public:
enum OptimizationCriterion { byTime = 1, byCost = 2 };
private:
class DijkstraIterator
{
public:
DijkstraIterator()
{
@ -91,7 +92,8 @@ private:
QgsPoint mBackPoint;
QgsPoint mFrontPoint;
};
class CompareDijkstraIterator {
class CompareDijkstraIterator
{
public:
CompareDijkstraIterator( OptimizationCriterion criterion = byCost ) :
mCriterion( criterion )
@ -111,7 +113,7 @@ private:
private:
OptimizationCriterion mCriterion;
};
public:
public:
/**
* constructor.
* m is adjacency matrix of graph, criterion is a citerion of shortest path
@ -129,7 +131,7 @@ public:
*/
AdjacencyMatrix find( const QgsPoint& frontPoint, const QgsPoint& endPoint );
private:
private:
const AdjacencyMatrix& mAdjacencyMatrix;
OptimizationCriterion mCriterion;
};

View File

@ -1140,7 +1140,7 @@ QgsSqlAnywhereProvider::addFeatures( QgsFeatureList & flist )
if ( ok )
{
// expand extents to accomodate new geometries
// expand extents to accommodate new geometries
mSrsExtent.unionRect( rect );
if ( !mLayerExtent.isEmpty() )
{
@ -1565,7 +1565,7 @@ QgsSqlAnywhereProvider::changeGeometryValues( QgsGeometryMap & gmap )
if ( ok )
{
// expand SRS and layer extents to accomodate new geometries
// expand SRS and layer extents to accommodate new geometries
mSrsExtent.unionRect( rect );
if ( !mLayerExtent.isEmpty() )
{