qtvplugin_grid.h 2.9 KB
Newer Older
1 2 3 4 5 6
#ifndef QTVPLUGIN_GRID_H
#define QTVPLUGIN_GRID_H

#include <QWidget>
#include <QTranslator>
#include <QVector>
丁劲犇's avatar
丁劲犇 已提交
7
#include <QStandardItemModel>
8 9 10 11 12 13
#include "../qtviewer_planetosm/osmtiles/layer_interface.h"
#include "../qtviewer_planetosm/osmtiles/viewer_interface.h"
namespace Ui {
	class qtvplugin_grid;
}
using namespace QTVOSM;
丁劲犇's avatar
丁劲犇 已提交
14
/*!	qtvplugin_grid support distance and area measuring. function calls avaliable:
15
	1.function=get_polygon, no other para needed. returns current selected polygon's cornor points, in lat, lon; size=N;lat0=XX;lon0=XX;
丁劲犇's avatar
丁劲犇 已提交
16 17 18
	lat1=XX;lon1=XX;lat2=XX;lon2=XX;...;latN-1=XX;lonN-1=XX.
	2.function=get_ruler_status, no other para needed.returns whether ruler tool is active now, status=0 means not active, status=-1 means active.
	3.function=set_ruler_status, with para status, will set ruler status to given value.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 \class qtvplugin_grid qtvplugin_grid.h "qtvplugin_grid/qtvplugin_grid.h"
*/
class qtvplugin_grid : public QWidget,public layer_interface
{
	Q_OBJECT
	Q_PLUGIN_METADATA(IID OSMLayerInterface_iid )
	Q_INTERFACES(QTVOSM::layer_interface)
public:
	qtvplugin_grid(QWidget *parent = 0);
	~qtvplugin_grid();
	//Properties
	bool		is_active();
	void		set_active(bool ab);
	bool		is_visible();
	void		set_visible(bool vb);
	QString		get_name();
	void		set_name(QString vb);
	QWidget *	get_propWindow() {return this;}
37
	QMap<QString, QVariant> call_func(const  QMap<QString, QVariant> & /*paras*/);
38 39 40
private:
	int m_nInstance;
	//International Translator
41 42
	QTranslator				pluginTranslator;
	Ui::qtvplugin_grid *	ui;
43
	//the pointer to main MAP functions
44
	viewer_interface *		m_pVi;
45
	//Flags
46 47
	bool					m_bVisible;
	bool					m_bActive;
48
	//Lib Name
49 50
	QString					m_SLLibName;
	QString					m_SLLibPath;
51
	//Measure
52 53 54 55 56 57
	QPointF					m_pt_end;
	QPoint					m_mousePos;
	QVector<QPointF>		m_list_points;
	bool					bFinished;
	//simple mark
	int						m_nMarks;
丁劲犇's avatar
丁劲犇 已提交
58
	QStandardItemModel *	m_pModelCombo;
59 60 61 62 63 64 65 66 67
	//measure method
	void	CalArea();
	double	GetArea(double * PointX,double * PointY,int Count);
	double	CalDistance(double,double,double,double,double * psita);
	bool	loadTranslation();
protected:
	layer_interface *	load_initial_plugin(QString strSLibPath,viewer_interface  * ptrviewer);
	QWidget *			load_prop_window();
	void				load_retranslate_UI();
68 69 70
	void				load_ini();
	void				save_ini();
	QString				ini_file();
71 72 73 74 75 76 77 78
protected:
	//Events
	void cb_paintEvent( QPainter * pImage );
	bool cb_mouseMoveEvent(QMouseEvent *);
	bool cb_mousePressEvent(QMouseEvent *);
	//Event filters
	bool cb_event(const QMap<QString, QVariant>);
protected slots:
79 80 81 82
	void on_checkBox_QTV_measure_clicked(bool);
	void on_pushButton_QTV_add_mark_clicked();
	void on_pushButton_QTV_clear_clicked();
	void on_pushButton_QTV_clear_all_clicked();
丁劲犇's avatar
丁劲犇 已提交
83 84
	void on_pushButton_QTV_centerFill_clicked();
	void on_pushButton_QTV_gridCircle_clicked();
85 86 87 88 89
};

#endif // QTVPLUGIN_GRID_H