2 * @file PluginModule.cpp
3 * Implements the PluginModule class.
4 * @ingroup generic-plugin
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 #include "PluginModule.h"
27 #include "GenericPluginUI.h"
31 * Plugin function table.
33 _QERPluginTable PluginModule::_pluginAPI;
36 * Default constructor. Initialize the function table.
38 PluginModule::PluginModule()
40 _pluginAPI.m_pfnQERPlug_Init = &QERPluginInit;
41 _pluginAPI.m_pfnQERPlug_GetName = &QERPluginGetName;
42 _pluginAPI.m_pfnQERPlug_GetCommandList = &QERPluginGetCommandList;
43 _pluginAPI.m_pfnQERPlug_GetCommandTitleList = &QERPluginGetCommandTitleList;
44 _pluginAPI.m_pfnQERPlug_Dispatch = &QERPluginDispatch;
50 PluginModule::~PluginModule()
55 * Fetch a pointer to the function table.
58 PluginModule::getTable()
66 * @param hApp Dummy arg; ignored.
67 * @param pMainWidget Main window widget.
69 * @return The plugin name.
72 PluginModule::QERPluginInit(void *hApp,
75 // Inform the UI of the main app window.
76 UIInstance().SetWindow((GtkWidget *)pMainWidget);
77 // Return the plugin name.
82 * Get the plugin's name.
84 * @return The plugin name.
87 PluginModule::QERPluginGetName()
89 // Return the plugin name.
94 * Get the command list for the plugin menu, as a semicolon-separated string
95 * of tokens representing each command.
97 * @return The command list string.
100 PluginModule::QERPluginGetCommandList()
102 // Bail out if the plugin menu doesn't exist.
103 if (UIInstance().MainMenu() == NULL)
107 // Get the command list from the menu.
108 return UIInstance().MainMenu()->GetCommandList().c_str();
112 * Get the command label list for the plugin menu, as a semicolon-separated
113 * string of labels to appear in the menu.
115 * @return The command label list string.
118 PluginModule::QERPluginGetCommandTitleList()
120 // Bail out if the plugin menu doesn't exist.
121 if (UIInstance().MainMenu() == NULL)
125 // Get the command label list from the menu.
126 return UIInstance().MainMenu()->GetCommandLabelList().c_str();
130 * Invoke a plugin command.
132 * @param command The command token.
133 * @param vMin 3-element float vector definining min corner of
135 * @param vMax 3-element float vector definining max corner of
137 * @param bSingleBrush Dummy arg; ignored.
140 PluginModule::QERPluginDispatch(const char *command,
145 // Bail out if the plugin menu doesn't exist.
146 if (UIInstance().MainMenu() == NULL)
148 // XXX This shouldn't happen; might as well drop an ASSERT or error
149 // message in here. First make sure there's no odd Radiant-exiting
150 // corner case race that could trigger it though.
153 // Send the command dispatch to the menu.
154 // XXX For my particular use case I don't need vMin or vMax, but for
155 // generality's sake those values should be passed along here, and then I
156 // can drop them when the flow gets to MeshTex-specific code... that will
157 // require changes for several types/signatures though.
158 UIInstance().MainMenu()->Dispatch(command);