![]() |
RTXI 1.3
|
00001 /* 00002 Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 */ 00018 00019 // Risa Lin 00020 // Wed 13 Jul 2011 18:58:18 PM EDT 00021 // Now accepts ", " or "," as delimiters between integers. 00022 00023 00024 #include <synch.h> 00025 #include <qwhatsthis.h> 00026 00027 extern "C" Plugin::Object * 00028 createRTXIPlugin(void) { 00029 return new Synch(); 00030 } 00031 00032 static DefaultGUIModel::variable_t vars[] = 00033 { 00034 { "Models", "Models to synch 0-255", DefaultGUIModel::PARAMETER, }, }; 00035 00036 static size_t num_vars = sizeof(vars) / sizeof(DefaultGUIModel::variable_t); 00037 00038 Synch::Synch(void) : 00039 DefaultGUIModel("Synch", ::vars, ::num_vars), ModelIDString("0") { 00040 00041 QWhatsThis::add( 00042 this, 00043 "<p><b>Synch:</b><br>This module allows you to synchronize other modules that are derived from the DefaultGUIModel class. It does not work with other custom user modules. Type in a comma-separated list (with or without spaces) of numbers that are the instance IDs of the modules you want to synchronize. Instance IDs are located in the left-hand corner of the module's toolbar.</p>"); 00044 update(INIT); 00045 ListLen = 0; 00046 createGUI(vars, num_vars); 00047 refresh(); 00048 } 00049 00050 Synch::~Synch(void) { 00051 } 00052 00053 void 00054 Synch::execute(void) { 00055 return; 00056 } 00057 00058 void 00059 Synch::update(DefaultGUIModel::update_flags_t flag) { 00060 switch (flag) { 00061 case INIT: 00062 setParameter("Models", ModelIDString); 00063 break; 00064 case MODIFY: 00065 ModelIDString = getParameter("Models"); 00066 ModelIDString.replace(QChar(', '), QChar(',')); 00067 ModelIDList = QStringList::split(",", ModelIDString); 00068 ListLen = ModelIDList.count(); 00069 Model_ID_List = new int[ListLen]; 00070 i = 0; 00071 for (QStringList::Iterator it = ModelIDList.begin(); it != ModelIDList.end(); ++it) { 00072 Model_ID_List[i] = (*it).toInt(); 00073 printf("%d\n", Model_ID_List[i]); 00074 i++; 00075 } 00076 00077 break; 00078 case UNPAUSE: 00079 printf("SYNCH UNPAUSE\n"); 00080 for (i = 0; i < ListLen; i++) { 00081 Model = dynamic_cast<DefaultGUIModel*> (Settings::Manager::getInstance()->getObject(Model_ID_List[i])); 00082 Model->setActive(true); 00083 Model->refresh(); 00084 } 00085 break; 00086 case PAUSE: 00087 printf("SYNCH PAUSE\n"); 00088 for (i = 0; i < ListLen; i++) { 00089 Model = dynamic_cast<DefaultGUIModel*> (Settings::Manager::getInstance()->getObject(Model_ID_List[i])); 00090 Model->setActive(false); 00091 Model->refresh(); 00092 } 00093 break; 00094 default: 00095 break; 00096 00097 } 00098 00099 }