3 * Declares the MainMenu class.
8 * Copyright 2012 Joel Baxter
10 * This file is part of MeshTex.
12 * MeshTex is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 2 of the License, or
15 * (at your option) any later version.
17 * MeshTex is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with MeshTex. If not, see <http://www.gnu.org/licenses/>.
26 #if !defined(INCLUDED_MAINMENU_H)
27 #define INCLUDED_MAINMENU_H
29 #include "GenericMainMenu.h"
30 #include "MeshVisitor.h"
33 * Subclass of GenericMainMenu that constructs the commands for this plugin.
37 class MainMenu : public GenericMainMenu
39 private: // private types
42 * Visitor for invoking a function on a MeshEntity when that function does
43 * not require any arguments other than the texture axes. These operations
44 * are triggered immediately on selecting a menu entry, rather than being
45 * triggered by applying some other dialog.
47 class PresetFuncVisitor : public MeshVisitor
51 * Function signature for a preset function.
53 typedef void(MeshEntity::*VisitorFunctor)(MeshEntity::TextureAxisSelection axes);
55 PresetFuncVisitor(const VisitorFunctor& visitorFunctor,
56 MeshEntity::TextureAxisSelection axes);
58 bool Execute(MeshEntity& meshEntity) const;
61 const VisitorFunctor _visitorFunctor;
62 const MeshEntity::TextureAxisSelection _axes;
65 public: // public methods
67 MainMenu(SmartPointer<GenericDialog>& setScaleDialog,
68 SmartPointer<GenericDialog>& getInfoDialog,
69 SmartPointer<GenericDialog>& genFuncDialog);
71 void CommandMeshVisitor(const std::string& commandString);
72 void CommandHelp(const std::string& commandString);
73 void CommandAbout(const std::string& commandString);
75 private: // private methods
77 void AddMeshVisitorEntry(const char *commandLabel,
79 const SmartPointer<MeshVisitor>& visitor);
81 private: // private types
84 * Type for a map between a string and a reference-counted visitor.
86 typedef std::map<std::string, SmartPointer<MeshVisitor> > VisitorMap;
91 * Associations between commands and visitors that implement them.
93 VisitorMap _visitorMap;
96 * Callback for all of the commands that trigger CommandMeshVisitor. This is
97 * stored in a member var rather than a local var just because otherwise it
98 * would need to be passed around and clutter up an already ugly set of
101 const CommandCallbackMethod
102 <MainMenu, &MainMenu::CommandMeshVisitor> _commandMeshVisitor;
105 #endif // #if !defined(INCLUDED_MAINMENU_H)