-
Notifications
You must be signed in to change notification settings - Fork 0
/
constructiondatumview.h
93 lines (81 loc) · 2.99 KB
/
constructiondatumview.h
1
2
3
4
5
6
7
8
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
39
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
/* -*- c++ -*-
* constructiondatumview.h
*
* Header for the Constructiondatumview class
* Copyright (C) 2002 lignum Computing, Inc. <lignumcad@lignumcomputing.com>
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef CONSTRUCTIONDATUMVIEW_H
#define CONSTRUCTIONDATUMVIEW_H
#include <map>
#include "graphics.h"
#include "constructiondatum.h"
class OpenGLBase;
namespace Space3D {
/*!
* Abstract view of a construction datum. Mostly virtual.
*/
class ConstructionDatumView {
public:
virtual ~ConstructionDatumView ( void ) {}
virtual void draw ( OpenGLBase* view ) const = 0;
virtual void select ( SelectionType select_type ) const = 0;
};
/*!
* The metadata defines a couple of methods to invoke in order to
* create construction datum views without knowing exactly what
* kind of datum it is. (Too complicated?...)
*/
class ConstructionDatumViewMetadata {
public:
ConstructionDatumViewMetadata ( void ) {}
//! Subclass may have something to do (but probably not).
virtual ~ConstructionDatumViewMetadata ( void ) {}
//! \return a view for this construction datum.
virtual ConstructionDatumView* create ( const ConstructionDatum* datum ) const = 0;
};
/*!
* The ConstructionDatumView factory constructs concrete graphics objects
* for datums.
*/
class ConstructionDatumViewFactory {
public:
//! \return the singleton instance of the constructiondatumview factory.
static ConstructionDatumViewFactory* instance( void );
void addConstructionDatumViewMetadata ( const QString& type,
const ConstructionDatumViewMetadata* view );
/*!
* Create a page and its view from its factory.
* \param type of construction datum.
* \param datum construction datum to view.
* \return the pointer to the new construction datum view.
*/
ConstructionDatumView* create ( const ConstructionDatum* datum )
{
return views_[ datum->type() ]->create( datum );
}
protected:
//! Per "Design Patterns": It can only construct itself.
ConstructionDatumViewFactory();
private:
//! The singleton instance of the constructiondatumview factory.
static ConstructionDatumViewFactory* instance_;
std::map< QString, const ConstructionDatumViewMetadata*> views_;
};
} // end of Space3D namespace
#endif // CONSTRUCTIONDATUMVIEW_H