keypointmanagement.hpp 2.98 KB
Newer Older
1 2 3 4 5 6 7
#ifndef CVVISUAL_KEYPOINT_MANAGEMENT
#define CVVISUAL_KEYPOINT_MANAGEMENT

#include <QCheckBox>

#include "../../util/util.hpp"

Maksim Shabunin's avatar
Maksim Shabunin committed
8
#include "opencv2/features2d.hpp"
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

#include "keypointselectionselector.hpp"
#include "keypointsettingsselector.hpp"
#include "keypointsettings.hpp"
#include "cvvkeypoint.hpp"

namespace cvv
{
namespace qtutil
{

/**
 * @brief the keypointmanagement class coordinates the selections and use settings for the selection.
 */
class KeyPointManagement : public KeyPointSettings
{

	Q_OBJECT

public:
	/**
	 * @brief the constructor
	 * @param univers all keypoints which can be selected
	 * @param parent the parent widget
	 */
	KeyPointManagement(std::vector<cv::KeyPoint> univers,QWidget *parent = nullptr);

	/**
	 * @brief set the settings if this KeyPoint is selected
	 */
39
    virtual void setSettings(CVVKeyPoint &match) CV_OVERRIDE;
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

	/**
	 * @brief add the given KeyPointSettingsSelector to the list
	 */
	void addSetting(std::unique_ptr<KeyPointSettingsSelector>);

	/**
	 * @brief add the given KeyPointSelectionSelector to the list
	 */
	void addSelection(std::unique_ptr<KeyPointSelectionSelector>);

	/**
	 * @brief returns the current selection.
	 */
	std::vector<cv::KeyPoint> getCurrentSelection()
		{return selection_;}

public slots:

	//selection
	/**
	 * @brief add the given keypoint to the current selection.
	 */
	void addToSelection(const cv::KeyPoint &key);

	/**
	 * @brief set the selection to the given single match
	 */
	void singleSelection(const cv::KeyPoint &key);

	/**
	 * @brief set the current selection to the given selection
	 */
	void setSelection(const std::vector<cv::KeyPoint> &selection);

	//KeyPointSettingSelector
	/**
	 * @brief add a new Setting
	 */
	void addSetting();

	void removeSetting(KeyPointSettingsSelector *setting);

	//Match Selection
	/**
	 * @brief add a KeyPointSelectionSelector to the list
	 */
	void addSelection();

	/**
	 * @brief remove a given KeyPointSelector from the list
	 */
	void removeSelection(KeyPointSelectionSelector *selector);

	/**
	 * @brief select with the selections
	 */
	void applySelection();

	/**
	 * @brief set Selection to univers.
	 */
	void selectAll()
		{setSelection(univers_);}

	/**
	 * @brief set selection to an empty list.
	 */
	void selectNone()
		{setSelection(std::vector<cv::KeyPoint>{});}


signals:

	/**
Brian Wignall's avatar
Brian Wignall committed
115
	 * @brief this signal will be emitted when the selection was changed.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
	 * it can be used for syncronisation with other selector
	 */
	void updateSelection(const std::vector<cv::KeyPoint> &selection);

	/**
	 * @brief this singal has the same function like settingsChanged from KeyPointSettings,
	 * but this will be only connect to the current selection
	 */
	void applySettingsToSelection(KeyPointSettings&);

private:
	std::vector<cv::KeyPoint> univers_;
	std::vector<cv::KeyPoint> selection_;
	std::vector<KeyPointSettingsSelector*> settingsList_;
	std::vector<KeyPointSelectionSelector*> selectorList_;

	QLayout *settingsLayout_;
	QLayout *selectorLayout_;
	QCheckBox *showOnlySelection_;
};
}}

#endif