Newer
Older
return mHeadSize; // muss noch aus density map gelesen werden!!!
}
else //(pos == NULL) && (pers == -1)
{
void Petrack::setProFileName(const QString &fileName)
{
// don't change project Name to an autosave
if(mAutosave.isAutosave(fileName) || fileName == mProFileName)
{
return;
}
// Change project => delete old autosave
mAutosave.deleteAutosave();
// NOTE: Use only the global variant in future?
// global one in helper.h because it is needed to use getFileList and shouldn't depend on Petrack
proFileName = fileName;
mProFileName = fileName;
updateWindowTitle();
}
Schrödter, Tobias
committed
* @brief Return the user's selection of pedestrians/trajectories
Schrödter, Tobias
committed
* Only people selected via "show only people" (single person) or "show only
* people list"(multiple persons) are going to be selected.
Schrödter, Tobias
committed
* @return All user selected pedestrian (empty for all pedestrians)
QSet<size_t> Petrack::getPedestrianUserSelection()
if(mControlWidget->trackShowOnly->checkState() == Qt::Checked)
{
// subtraction needed as in UI ID start at 1 and internally at 0
Schrödter, Tobias
committed
onlyVisible.insert(mControlWidget->trackShowOnlyNr->value() - 1);
return onlyVisible;
}
if(mControlWidget->trackShowOnlyList->checkState() == Qt::Checked)
{
auto enteredIDs = util::splitStringToInt(mControlWidget->trackShowOnlyNrList->text());
if(enteredIDs.has_value())
for(auto id : enteredIDs.value())
// subtraction needed as in UI ID start at 1 and internally at 0
selectedIDs.insert(id - 1);
Schrödter, Tobias
committed
}
mControlWidget->trackShowOnlyNrList->setStyleSheet("");
return selectedIDs;
}
else
{
mControlWidget->trackShowOnlyNrList->setStyleSheet("border: 1px solid red");
}
}
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
/**
* @brief Splits the given text to get a set of integers.
*
* The given text will be split on ',' and then each element will be checked if it is a range. Ranges are marked with
* '-' as divider. Only positive integer values are allowed.
*
* Examples:
* '1,5,6' -> (1, 5, 6)
* '1-5' -> (1, 2, 3, 4, 5)
*
* @param input given text
* @return Set of int in the given text
*/
std::optional<QSet<int>> util::splitStringToInt(const QString &input)
{
QSet<int> ids;
for(const auto &id : input.split(",", Qt::SkipEmptyParts))
{
bool ok = false;
int enteredID = id.toInt(&ok);
if(ok && enteredID >= 0) // parse single values
{
ids.insert(enteredID);
}
else // error or IDs range (e.g. 1-3, 6-10, etc.)
{
if(id.startsWith("-"))
{
ok = false;
}
auto range = id.split("-");
int first = range[0].toInt(&ok);
ok = ok && range.size() == 2 && !range[1].isEmpty();
if(ok)
{
int last = range[1].toInt(&ok);
if(ok)
Schrödter, Tobias
committed
{
std::swap(first, last);
}
for(int i = first; i <= last; i++)
{
ids.insert(i);
if(!ok)
{
return std::nullopt;
}
Schrödter, Tobias
committed
}
Schrödter, Tobias
committed
}
/**
* @brief Checks which pedestrians/trajectories are selected for evaluation.
*
* If "only for selected" is checked, then only selected people (@see
* Petrack::getPedestrianUserSelection()) are going to be tracked, all people
* otherwise.
*
* @return all trajectories which should be evaluated; empty when all should be evaluated
*/
Schrödter, Tobias
committed
{
if(mControlWidget->trackOnlySelected->checkState() == Qt::Checked)
Schrödter, Tobias
committed
{
return getPedestrianUserSelection();
Schrödter, Tobias
committed
}
void Petrack::addManualTrackPointOnlyVisible(const QPointF &pos)
int pers = addOrMoveManualTrackPoint(pos) + 1;
if(pers == 0)
pers = static_cast<int>(mPersonStorage.nbPersons()) + 1;
mControlWidget->trackShowOnlyNr->setValue(pers);
mControlWidget->trackShowOnly->setChecked(true);
}
void Petrack::updateControlWidget()
{
mControlWidget->trackNumberAll->setText(QString("%1").arg(mPersonStorage.nbPersons()));
mControlWidget->trackShowOnlyNr->setMaximum(static_cast<int>(MAX(mPersonStorage.nbPersons(), 1)));
mControlWidget->trackNumberVisible->setText(
QString("%1").arg(mPersonStorage.visible(mAnimation->getCurrentFrameNum())));
mPersonStorage.splitPersonAt((Vec2F) pos, mAnimation->getCurrentFrameNum(), getPedestrianUserSelection());
* @brief Lets the user add or move a TrackPoint manually
*
* There is an check inside addPoint which inhibits adding a point,
* if only selected trajectories are visualized, since one wouldn't
* see the newly added TrackPoint.
*
* @param pos pixel position of mouse on image
* @return index of person whose point was moved; -1 if failed or new trajectory is started
int Petrack::addOrMoveManualTrackPoint(const QPointF &pos)
TrackPoint tP(Vec2F{pos}, 110); // 110 is higher than 100 (max. quality) and gets clamped to 100 after insertion
// allows replacemet of every point (check for better quality always passes)
tP, mAnimation->getCurrentFrameNum(), getPedestrianUserSelection(), mReco.getRecoMethod(), &pers);
}
// direction zeigt an, ob bis zum aktuellen (-1), ab dem aktuellen (1) oder ganzer trackpath (0)
// loeschen von Trackpoints einer Trajektorie
void Petrack::deleteTrackPoint(QPointF pos, int direction) // const QPoint &pos
mPersonStorage.delPoint((Vec2F) pos, direction, mAnimation->getCurrentFrameNum(), getPedestrianUserSelection());
updateControlWidget();
}
void Petrack::editTrackPersonComment(QPointF pos)
{
mPersonStorage.editTrackPersonComment((Vec2F) pos, mAnimation->getCurrentFrameNum(), getPedestrianUserSelection());
updateControlWidget();
}
void Petrack::setTrackPersonHeight(QPointF pos)
{
mPersonStorage.setTrackPersonHeight((Vec2F) pos, mAnimation->getCurrentFrameNum(), getPedestrianUserSelection());
updateControlWidget();
}
void Petrack::resetTrackPersonHeight(QPointF pos)
{
mPersonStorage.resetTrackPersonHeight((Vec2F) pos, mAnimation->getCurrentFrameNum(), getPedestrianUserSelection());
/**
* @brief Delete the following, previous or whole trajectory of **all** trajectories
* @param direction previous, following or whole
*/
void Petrack::deleteTrackPointAll(PersonStorage::Direction direction) // const QPoint &pos
mPersonStorage.delPointAll(direction, mAnimation->getCurrentFrameNum());
updateControlWidget();
}
void Petrack::deleteTrackPointROI()
{
mPersonStorage.delPointROI();
updateControlWidget();
mScene->update();
}
void Petrack::deleteTrackPointInsideROI()
{
getPersonStorage().delPointInsideROI();
d.kilic
committed
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
void Petrack::moveTrackPoint(QPointF pos)
{
mManualTrackPointMover.moveTrackPoint(pos, mPersonStorage);
mScene->update();
}
void Petrack::selectPersonForMoveTrackPoint(QPointF pos)
{
FrameRange range;
range.before = mControlWidget->trackShowBefore->value();
range.after = mControlWidget->trackShowAfter->value();
range.current = mPlayerWidget->getPos();
auto successfullySelected =
mManualTrackPointMover.selectTrackPoint(pos, mPersonStorage, getPedestrianUserSelection(), range);
if(successfullySelected)
{
setCursor(QCursor{Qt::CursorShape::DragMoveCursor});
}
}
void Petrack::releaseTrackPoint()
{
mManualTrackPointMover.setTrackPoint();
mAutosave.trackPersonModified();
setCursor(QCursor{});
}
void Petrack::scrollShowOnly(int delta)
{
if(delta < 0)
{
mControlWidget->trackShowOnlyNr->stepDown();
}
else
{
mControlWidget->trackShowOnlyNr->stepUp();
}
}
void Petrack::updateSourceInOutFrames()
{
mPlayerWidget->setFrameInNum(mAnimation->getSourceInFrameNum());
mPlayerWidget->setFrameOutNum(mAnimation->getSourceOutFrameNum());
}
// delta gibt menge an Umdrehungen und richtung an
void Petrack::skipToFrameWheel(int delta)
{
mPlayerWidget->skipToFrame(mPlayerWidget->getPos() + delta);
void Petrack::skipToFrameFromTrajectory(QPointF pos)
{
auto peds = getPedestrianUserSelection();
const auto before = mControlWidget->trackShowBefore->value();
const auto after = mControlWidget->trackShowAfter->value();
const auto currFrame = mPlayerWidget->getPos();
d.kilic
committed
FrameRange frameRange{before, after, currFrame};
d.kilic
committed
auto res = mPersonStorage.getProximalPersons(pos, peds, frameRange);
if(res.size() == 1)
{
mPlayerWidget->skipToFrame(res.front().frame);
}
else if(res.size() > 1)
{
PWarning(
this,
tr("Too many trajectories"),
tr("PeTrack can't determine which point you meant. Try selecting fewer trajectories first."));
}
}
void Petrack::setPeTrackVersion(const std::string &petrackVersion)
{
mPetrackVersion = QString::fromStdString(petrackVersion);
updateWindowTitle();
}
void Petrack::setGitInformation(
const std::string &gitCommitID,
const std::string &gitCommitDate,
const std::string &gitCommitBranch)
mGitCommitID = QString::fromStdString(gitCommitID);
mGitCommitDate = QString::fromStdString(gitCommitDate);
mGitCommitBranch = QString::fromStdString(gitCommitBranch);
}
void Petrack::setCompileInformation(
const std::string &compileTimeStamp,
const std::string &compilerID,
const std::string &compilerVersion)
mCompileDate = QString::fromStdString(compileTimeStamp);
mCompilerID = QString::fromStdString(compilerID);
mCompilerVersion = QString::fromStdString(compilerVersion);
}
#include "moc_petrack.cpp"