-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenu.h
105 lines (89 loc) · 3.16 KB
/
MainMenu.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
94
95
96
97
98
99
100
101
102
103
104
105
/**
* @file MainMenu.h
* Declares the MainMenu class.
* @ingroup meshtex-ui
*/
/*
* Copyright 2012 Joel Baxter
*
* This file is part of MeshTex.
*
* MeshTex 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.
*
* MeshTex 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 MeshTex. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(INCLUDED_MAINMENU_H)
#define INCLUDED_MAINMENU_H
#include "GenericMainMenu.h"
#include "MeshVisitor.h"
/**
* Subclass of GenericMainMenu that constructs the commands for this plugin.
*
* @ingroup meshtex-ui
*/
class MainMenu : public GenericMainMenu
{
private: // private types
/**
* Visitor for invoking a function on a MeshEntity when that function does
* not require any arguments other than the texture axes. These operations
* are triggered immediately on selecting a menu entry, rather than being
* triggered by applying some other dialog.
*/
class PresetFuncVisitor : public MeshVisitor
{
public:
/**
* Function signature for a preset function.
*/
typedef void(MeshEntity::*VisitorFunctor)(MeshEntity::TextureAxisSelection axes);
public:
PresetFuncVisitor(const VisitorFunctor& visitorFunctor,
MeshEntity::TextureAxisSelection axes);
private:
bool Execute(MeshEntity& meshEntity) const;
private:
const VisitorFunctor _visitorFunctor;
const MeshEntity::TextureAxisSelection _axes;
};
public: // public methods
MainMenu(SmartPointer<GenericDialog>& setScaleDialog,
SmartPointer<GenericDialog>& getInfoDialog,
SmartPointer<GenericDialog>& genFuncDialog);
~MainMenu();
void CommandMeshVisitor(const std::string& commandString);
void CommandHelp(const std::string& commandString);
void CommandAbout(const std::string& commandString);
private: // private methods
void AddMeshVisitorEntry(const char *commandLabel,
const char *command,
const SmartPointer<MeshVisitor>& visitor);
private: // private types
/**
* Type for a map between a string and a reference-counted visitor.
*/
typedef std::map<std::string, SmartPointer<MeshVisitor> > VisitorMap;
private:
/**
* Associations between commands and visitors that implement them.
*/
VisitorMap _visitorMap;
/**
* Callback for all of the commands that trigger CommandMeshVisitor. This is
* stored in a member var rather than a local var just because otherwise it
* would need to be passed around and clutter up an already ugly set of
* invocations.
*/
const CommandCallbackMethod
<MainMenu, &MainMenu::CommandMeshVisitor> _commandMeshVisitor;
};
#endif // #if !defined(INCLUDED_MAINMENU_H)