You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
3.7 KiB
167 lines
3.7 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LocatorWnd.h
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Header file of LocatorWnd.h
|
|
//----------------------------------------------------------------------------
|
|
#ifndef __LOCATOR__WND__H__INCLUDED__
|
|
#define __LOCATOR__WND__H__INCLUDED__
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif
|
|
|
|
#include "GenericWnd.h"
|
|
#include "..\LgLib\Templ.h"
|
|
#include "..\LgLib\LgAux.h"
|
|
|
|
class CLocatorRegion : public CLgArray<CLgDPoint>
|
|
{
|
|
public:
|
|
CLocatorRegion();
|
|
CLocatorRegion( const CLocatorRegion& );
|
|
virtual ~CLocatorRegion();
|
|
|
|
public:
|
|
virtual BOOL Add( CLgDPoint& data );
|
|
virtual BOOL Remove( INT nIndex );
|
|
virtual BOOL RemoveAll();
|
|
|
|
public:
|
|
BOOL Load( HANDLE hFile );
|
|
BOOL Store( HANDLE hFile );
|
|
|
|
public:
|
|
void SetColor( COLORREF nColor ) { m_nColor = nColor; }
|
|
COLORREF GetColor() { return m_nColor; }
|
|
|
|
public:
|
|
BOOL PtInRegion( CLgDPoint &dp );
|
|
HRGN GetRgn() { return m_hRgn; }
|
|
|
|
private:
|
|
COLORREF m_nColor;
|
|
|
|
private:
|
|
BOOL UpdateRgn();
|
|
HRGN m_hRgn;
|
|
};
|
|
|
|
class CLocatorRegionArray : public CLgArray<CLocatorRegion>
|
|
{
|
|
public:
|
|
INT PtInRegion( CLgDPoint &dp );
|
|
|
|
public:
|
|
BOOL Load( LPCTSTR pFile );
|
|
BOOL Store( LPCTSTR pFile );
|
|
|
|
public:
|
|
BOOL ProduceHiddenZones();
|
|
|
|
private:
|
|
struct VERTEX
|
|
{
|
|
double x, y, r;
|
|
BOOL f;
|
|
int n;
|
|
|
|
};
|
|
|
|
typedef VERTEX* LPVERTEX;
|
|
|
|
struct SEGMENT
|
|
{
|
|
INT pPoints[2];
|
|
INT nIndex;
|
|
};
|
|
|
|
typedef SEGMENT* LPSEGMENT;
|
|
|
|
struct SEGMENTS
|
|
{
|
|
LPVERTEX pPoints;
|
|
INT nCount;
|
|
|
|
};
|
|
|
|
typedef SEGMENTS* LPSEGMENTS;
|
|
|
|
private:
|
|
static int DBL_CMP(const double& a, const double& b, const double quality = 1e-10);
|
|
static BOOL CrossProduct( LPVERTEX ln0, LPVERTEX ln1, LPVERTEX pCross, BOOL fCheck0 = TRUE, BOOL fCheck1 = TRUE );
|
|
static BOOL PtInLine(LPVERTEX ln, VERTEX& p);
|
|
static int comparePoints(const void *arg1, const void *arg2);
|
|
static void AddPointToSegment(LPSEGMENTS pSegments, INT nIndex, LPVERTEX pPoint);
|
|
static void StickSegments(LPSEGMENTS pSegments, INT nIndex);
|
|
static int compareSegments(const void *arg1, const void *arg2);
|
|
};
|
|
|
|
class CLocatorWnd : public CGenericWnd
|
|
{
|
|
public:
|
|
CLocatorWnd();
|
|
virtual ~CLocatorWnd();
|
|
|
|
public:
|
|
BOOL Create( HWND hParentWnd, INT x, INT y, INT cx, INT cy );
|
|
|
|
public:
|
|
void SetRegionArray( CLocatorRegionArray *pRegionArray ) { m_RegionArray = *pRegionArray; }
|
|
CLocatorRegionArray& GetRegionArray() { return m_RegionArray; }
|
|
|
|
public:
|
|
void SetBackground( HBITMAP hBitmap, BOOL bCopy = TRUE );
|
|
|
|
public:
|
|
BOOL ClearRegions();
|
|
|
|
public:
|
|
typedef enum{ EDIT_MODE_LINE, EDIT_MODE_POINT } EDIT_MODE;
|
|
void SetEditMode( BOOL bEditMode, COLORREF nEditColor = RGB(0,0,0), EDIT_MODE eEditMode = EDIT_MODE_POINT );
|
|
BOOL GetEditMode( COLORREF *pColor = NULL );
|
|
|
|
private:
|
|
virtual LRESULT OnMouseMove( WPARAM, LPARAM );
|
|
virtual LRESULT OnLButtonUp( WPARAM, LPARAM );
|
|
virtual LRESULT OnLButtonDown( WPARAM, LPARAM );
|
|
virtual LRESULT OnRButtonUp( WPARAM, LPARAM );
|
|
virtual LRESULT OnSize( WPARAM, LPARAM );
|
|
virtual LRESULT OnDestroy( WPARAM, LPARAM );
|
|
virtual void OnPaint( HDC );
|
|
|
|
private:
|
|
void OnDraw( HDC );
|
|
|
|
private:
|
|
POINT LocatorToClient( CLgDPoint& dp );
|
|
CLgDPoint ClientToLocator( POINT& p );
|
|
|
|
private:
|
|
CLocatorRegionArray m_RegionArray;
|
|
|
|
private:
|
|
BOOL m_bEditMode;
|
|
EDIT_MODE m_eEditMode;
|
|
CLocatorRegion m_EditRegion;
|
|
|
|
private:
|
|
BOOL m_bEditStart;
|
|
|
|
private:
|
|
HDC m_hMemDC;
|
|
HBITMAP m_hMemBitmap;
|
|
|
|
private:
|
|
HDC m_hBackgroundDC;
|
|
HBITMAP m_hBackgroundBitmap;
|
|
};
|
|
|
|
#endif
|