#include <RelativePositions.h>
Public Slots | |
| virtual void | addBut_clicked () |
| virtual void | calculateAverage () |
| virtual void | removeBut_clicked () |
| virtual void | setStationList (const QList< NamedPoint > *stations) |
| virtual void | updateCurrentDistAz (QTableWidgetItem *item) |
Public Member Functions | |
| RelativePositions (QWidget *parent=0, Qt::WFlags fl=0) | |
| ~RelativePositions () | |
Protected Attributes | |
| const QList< NamedPoint > * | _stations |
| GeopsyGui::RelativePositions::RelativePositions | ( | QWidget * | parent = 0, |
| Qt::WFlags | fl = 0 |
||
| ) |
References addBut_clicked(), removeBut_clicked(), QGpCoreTools::tr(), TRACE, and updateCurrentDistAz().
: Dialog(parent, fl) { TRACE; setupUi(this); QStringList hLabels; hLabels << tr( "From" ) << tr( "To" ) << tr( "Distance" ) << tr( "Azimuth" ); mainTable->setHorizontalHeaderLabels (hLabels); mainTable->setSelectionBehavior(QAbstractItemView::SelectItems); mainTable->setSelectionMode(QAbstractItemView::SingleSelection); mainTable->setEditTriggers(QAbstractItemView::AllEditTriggers); RelativePositionsDelegate * delegate=new RelativePositionsDelegate(this); mainTable->setItemDelegate (delegate); // signals and slots connections connect(addBut, SIGNAL(clicked()), this, SLOT(addBut_clicked()) ); connect(removeBut, SIGNAL(clicked()), this, SLOT(removeBut_clicked()) ); connect(mainTable, SIGNAL(itemChanged (QTableWidgetItem * )), this, SLOT(updateCurrentDistAz(QTableWidgetItem * ))); }
| void GeopsyGui::RelativePositions::addBut_clicked | ( | ) | [virtual, slot] |
References _stations, GeopsyGui::RelativePositionsDelegate::stationAt(), and TRACE.
Referenced by RelativePositions().
{
TRACE;
mainTable->blockSignals(true);
int row=mainTable->rowCount();
mainTable->setRowCount(row + 1);
QTableWidgetItem * item;
item=new QTableWidgetItem;
mainTable->setItem(row,0, item);
item=new QTableWidgetItem;
mainTable->setItem(row,1, item);
item=new QTableWidgetItem;
mainTable->setItem(row,2, item);
item=new QTableWidgetItem;
mainTable->setItem(row,3, item);
mainTable->resizeRowToContents(row);
mainTable->blockSignals(false);
if(_stations->count()>0) {
RelativePositionsDelegate * delegate=static_cast<RelativePositionsDelegate *>(mainTable->itemDelegate());
mainTable->item(row,0)->setText(delegate->stationAt(0));
if(_stations->count()>1) {
mainTable->item(row,1)->setText(delegate->stationAt(1));
}
}
}
| void GeopsyGui::RelativePositions::calculateAverage | ( | ) | [virtual, slot] |
References TRACE.
Referenced by updateCurrentDistAz().
{
TRACE;
int nRow=mainTable->rowCount();
double d=0, az=0;
for(int iRow=0; iRow<nRow; iRow++) {
d+=mainTable->item(iRow, 2)->text().toDouble();
az+=mainTable->item(iRow, 3)->text().toDouble();
}
d/=(double)nRow;
az/=(double)nRow;
averageDistance->setText(QString::number(d));
averageAzimuth->setText(QString::number(az));
}
| void GeopsyGui::RelativePositions::removeBut_clicked | ( | ) | [virtual, slot] |
References TRACE.
Referenced by RelativePositions().
{
TRACE;
int row=mainTable->currentRow();
mainTable->removeRow(row);
mainTable->setCurrentItem(mainTable->item(row, 0) );
}
| void GeopsyGui::RelativePositions::setStationList | ( | const QList< NamedPoint > * | stations | ) | [virtual, slot] |
References _stations, GeopsyGui::RelativePositionsDelegate::addStation(), and TRACE.
| void GeopsyGui::RelativePositions::updateCurrentDistAz | ( | QTableWidgetItem * | item | ) | [virtual, slot] |
References _stations, QGpCoreTools::Point2D::azimuthTo(), calculateAverage(), QGpCoreTools::Point::distanceTo(), GeopsyGui::RelativePositionsDelegate::indexOf(), and TRACE.
Referenced by RelativePositions().
{
TRACE;
int row=mainTable->row(item);
mainTable->blockSignals(true);
RelativePositionsDelegate * delegate=static_cast<RelativePositionsDelegate *>(mainTable->itemDelegate());
int iFrom=delegate->indexOf(mainTable->item(row,0)->text());
int iTo=delegate->indexOf(mainTable->item(row,1)->text());
if(iFrom>=0 && iTo>=0) {
const Point& p1=_stations->at(iFrom);
const Point& p2=_stations->at(iTo);
mainTable->item(row,2)->setText(QString::number(p1.distanceTo(p2) ));
double angle=Angle::mathToGeographic(p1.azimuthTo(p2));
mainTable->item(row,3)->setText(QString::number(angle));
}
mainTable->blockSignals(false);
calculateAverage();
}
const QList<NamedPoint>* GeopsyGui::RelativePositions::_stations [protected] |
Referenced by addBut_clicked(), setStationList(), and updateCurrentDistAz().