aboutsummaryrefslogtreecommitdiff
path: root/visualization/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'visualization/renderer')
-rw-r--r--visualization/renderer/main.cpp80
-rw-r--r--visualization/renderer/qmppluginapistub.cpp220
-rw-r--r--visualization/renderer/qmppluginapistub.hpp140
-rw-r--r--visualization/renderer/qmpsettingsro.cpp310
-rw-r--r--visualization/renderer/qmpsettingsro.hpp103
-rw-r--r--visualization/renderer/qmpvisrendercore.cpp463
-rw-r--r--visualization/renderer/qmpvisrendercore.hpp67
7 files changed, 723 insertions, 660 deletions
diff --git a/visualization/renderer/main.cpp b/visualization/renderer/main.cpp
index c651c54..7f25578 100644
--- a/visualization/renderer/main.cpp
+++ b/visualization/renderer/main.cpp
@@ -4,44 +4,46 @@
#include "qmpvisrendercore.hpp"
#include "qmpsettingsro.hpp"
-int main(int argc,char **argv)
+int main(int argc, char **argv)
{
- QCoreApplication::setApplicationName("qmpvisrender");
- QCoreApplication::setApplicationVersion("0.0.0");
- QCoreApplication a(argc,argv);
- QCommandLineParser clp;
- clp.setApplicationDescription("Renderer a visualization of a midi file.");
- clp.addHelpOption();
- clp.addVersionOption();
- clp.addOption({{"f","output-file"},"File name of the output file.","filename","output.mp4"});
- clp.addOption({
- "receiver",
- "Specify a program and its arguments to process the rendered frames. Supports parameter substitution. See documentation for details.",
- "command",
- "ffmpeg %i -vf vflip -pix_fmt yuv420p -c:v libx264 -preset slow -crf 22 %o"
- });
- clp.addOption({
- {"e","receiver-execution"},
- "Execution mode of the receiver command. Valid options are 'one-shot' and 'per-frame'",
- "mode",
- "one-shot"
- });
- clp.addOption({{"s","show-window"},"Do not hide the visualization window."});
- clp.addOption({{"c","config"},"Load options from the configuration file.","qmprc file"});
- clp.addOption({{"o","option"},"Set option for the visualization module.","key-value pair"});
- clp.addOption({"list-options","Show a list of recognized options and quit."});
- clp.addPositionalArgument("file","MIDI file to render");
- clp.process(a.arguments());
- qmpVisRenderCore core(&clp);
- if(clp.positionalArguments().empty()&&!clp.isSet("list-options"))
- clp.showHelp(1);
- core.loadSettings();
- if(!core.loadVisualizationLibrary())
- return 1;
- if(clp.positionalArguments().size())
- core.setMIDIFile(clp.positionalArguments().front().toStdString().c_str());
- core.startRender();
- int retval=a.exec();
- core.unloadVisualizationLibrary();
- return retval;
+ QCoreApplication::setApplicationName("qmpvisrender");
+ QCoreApplication::setApplicationVersion("0.0.0");
+ QCoreApplication a(argc, argv);
+ QCommandLineParser clp;
+ clp.setApplicationDescription("Renderer a visualization of a midi file.");
+ clp.addHelpOption();
+ clp.addVersionOption();
+ clp.addOption({{"f", "output-file"}, "File name of the output file.", "filename", "output.mp4"});
+ clp.addOption(
+ {
+ "receiver",
+ "Specify a program and its arguments to process the rendered frames. Supports parameter substitution. See documentation for details.",
+ "command",
+ "ffmpeg %i -vf vflip -pix_fmt yuv420p -c:v libx264 -preset slow -crf 22 %o"
+ });
+ clp.addOption(
+ {
+ {"e", "receiver-execution"},
+ "Execution mode of the receiver command. Valid options are 'one-shot' and 'per-frame'",
+ "mode",
+ "one-shot"
+ });
+ clp.addOption({{"s", "show-window"}, "Do not hide the visualization window."});
+ clp.addOption({{"c", "config"}, "Load options from the configuration file.", "qmprc file"});
+ clp.addOption({{"o", "option"}, "Set option for the visualization module.", "key-value pair"});
+ clp.addOption({"list-options", "Show a list of recognized options and quit."});
+ clp.addPositionalArgument("file", "MIDI file to render");
+ clp.process(a.arguments());
+ qmpVisRenderCore core(&clp);
+ if (clp.positionalArguments().empty() && !clp.isSet("list-options"))
+ clp.showHelp(1);
+ core.loadSettings();
+ if (!core.loadVisualizationLibrary())
+ return 1;
+ if (clp.positionalArguments().size())
+ core.setMIDIFile(clp.positionalArguments().front().toStdString().c_str());
+ core.startRender();
+ int retval = a.exec();
+ core.unloadVisualizationLibrary();
+ return retval;
}
diff --git a/visualization/renderer/qmppluginapistub.cpp b/visualization/renderer/qmppluginapistub.cpp
index 1be4880..b84a2b6 100644
--- a/visualization/renderer/qmppluginapistub.cpp
+++ b/visualization/renderer/qmppluginapistub.cpp
@@ -6,197 +6,245 @@
#include <QTextCodec>
qmpPluginAPIStub::qmpPluginAPIStub(qmpVisRenderCore *_core):
- core(_core)
+ core(_core)
{
}
qmpPluginAPIStub::~qmpPluginAPIStub()
{
- core=nullptr;
+ core = nullptr;
}
uint32_t qmpPluginAPIStub::getDivision()
{
- return core->player->getDivision();
+ return core->player->getDivision();
+}
+uint32_t qmpPluginAPIStub::getRawTempo()
+{
+ return 0;
+}
+double qmpPluginAPIStub::getRealTempo()
+{
+ return 0;
+}
+uint32_t qmpPluginAPIStub::getTimeSig()
+{
+ return 0;
+}
+int qmpPluginAPIStub::getKeySig()
+{
+ return 0;
+}
+uint32_t qmpPluginAPIStub::getNoteCount()
+{
+ return 0;
}
-uint32_t qmpPluginAPIStub::getRawTempo(){return 0;}
-double qmpPluginAPIStub::getRealTempo(){return 0;}
-uint32_t qmpPluginAPIStub::getTimeSig(){return 0;}
-int qmpPluginAPIStub::getKeySig(){return 0;}
-uint32_t qmpPluginAPIStub::getNoteCount(){return 0;}
uint32_t qmpPluginAPIStub::getMaxTick()
{
- return core->player->getMaxTick();
-}
-uint32_t qmpPluginAPIStub::getCurrentPolyphone(){return 0;}
-uint32_t qmpPluginAPIStub::getMaxPolyphone(){return 0;}
-uint32_t qmpPluginAPIStub::getCurrentTimeStamp(){return 0;}
-uint32_t qmpPluginAPIStub::getCurrentPlaybackPercentage(){return 0;}
-int qmpPluginAPIStub::getChannelCC(int ch, int cc){return 0;}
-int qmpPluginAPIStub::getChannelPreset(int ch){return 0;}
-void qmpPluginAPIStub::playerSeek(uint32_t percentage){}
-double qmpPluginAPIStub::getPitchBend(int ch){return 0;}
-void qmpPluginAPIStub::getPitchBendRaw(int ch,uint32_t *pb,uint32_t *pbr){}
-bool qmpPluginAPIStub::getChannelMask(int ch){return 0;}
+ return core->player->getMaxTick();
+}
+uint32_t qmpPluginAPIStub::getCurrentPolyphone()
+{
+ return 0;
+}
+uint32_t qmpPluginAPIStub::getMaxPolyphone()
+{
+ return 0;
+}
+uint32_t qmpPluginAPIStub::getCurrentTimeStamp()
+{
+ return 0;
+}
+uint32_t qmpPluginAPIStub::getCurrentPlaybackPercentage()
+{
+ return 0;
+}
+int qmpPluginAPIStub::getChannelCC(int ch, int cc)
+{
+ return 0;
+}
+int qmpPluginAPIStub::getChannelPreset(int ch)
+{
+ return 0;
+}
+void qmpPluginAPIStub::playerSeek(uint32_t percentage) {}
+double qmpPluginAPIStub::getPitchBend(int ch)
+{
+ return 0;
+}
+void qmpPluginAPIStub::getPitchBendRaw(int ch, uint32_t *pb, uint32_t *pbr) {}
+bool qmpPluginAPIStub::getChannelMask(int ch)
+{
+ return 0;
+}
std::string qmpPluginAPIStub::getTitle()
{
- if(core->settings()->getOptionEnumIntOptName("Midi/TextEncoding")=="Unicode")
- return std::string(core->player->getTitle());
- return QTextCodec::codecForName(
- core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
- toUnicode(core->player->getTitle()).toStdString();
+ if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
+ return std::string(core->player->getTitle());
+ return QTextCodec::codecForName(
+ core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
+ toUnicode(core->player->getTitle()).toStdString();
}
std::wstring qmpPluginAPIStub::getWTitle()
{
- if(core->settings()->getOptionEnumIntOptName("Midi/TextEncoding")=="Unicode")
- return QString(core->player->getTitle()).toStdWString();
- return QTextCodec::codecForName(
- core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
- toUnicode(core->player->getTitle()).toStdWString();
-}
-std::string qmpPluginAPIStub::getChannelPresetString(int ch){return std::string();}
-bool qmpPluginAPIStub::isDarkTheme(){return false;}
-void *qmpPluginAPIStub::getMainWindow(){return nullptr;}
-void qmpPluginAPIStub::discardCurrentEvent(){}
-void qmpPluginAPIStub::commitEventChange(SEvent d){}
-void qmpPluginAPIStub::callEventReaderCB(SEvent d){}
-void qmpPluginAPIStub::setFuncState(std::string name,bool state){}
+ if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
+ return QString(core->player->getTitle()).toStdWString();
+ return QTextCodec::codecForName(
+ core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
+ toUnicode(core->player->getTitle()).toStdWString();
+}
+std::string qmpPluginAPIStub::getChannelPresetString(int ch)
+{
+ return std::string();
+}
+bool qmpPluginAPIStub::isDarkTheme()
+{
+ return false;
+}
+void *qmpPluginAPIStub::getMainWindow()
+{
+ return nullptr;
+}
+void qmpPluginAPIStub::discardCurrentEvent() {}
+void qmpPluginAPIStub::commitEventChange(SEvent d) {}
+void qmpPluginAPIStub::callEventReaderCB(SEvent d) {}
+void qmpPluginAPIStub::setFuncState(std::string name, bool state) {}
void qmpPluginAPIStub::setFuncEnabled(std::string name, bool enable)
{}
void qmpPluginAPIStub::registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable)
{
- if(name=="Visualization")
- core->vf=i;
+ if (name == "Visualization")
+ core->vf = i;
}
void qmpPluginAPIStub::unregisterFunctionality(std::string name)
{
- if(name=="Visualization")
- core->vf=nullptr;
+ if (name == "Visualization")
+ core->vf = nullptr;
}
-int qmpPluginAPIStub::registerUIHook(std::string e, ICallBack *cb, void *userdat){}
+int qmpPluginAPIStub::registerUIHook(std::string e, ICallBack *cb, void *userdat) {}
int qmpPluginAPIStub::registerUIHook(std::string e, callback_t cb, void *userdat)
{
- if(e=="main.start")
- core->startcb=cb;
- if(e=="main.reset")
- core->resetcb=cb;
- return 0;
+ if (e == "main.start")
+ core->startcb = cb;
+ if (e == "main.reset")
+ core->resetcb = cb;
+ return 0;
}
void qmpPluginAPIStub::unregisterUIHook(std::string e, int hook)
{
- if(e=="main.start")
- core->startcb=nullptr;
- if(e=="main.reset")
- core->resetcb=nullptr;
+ if (e == "main.start")
+ core->startcb = nullptr;
+ if (e == "main.reset")
+ core->resetcb = nullptr;
}
-void qmpPluginAPIStub::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name){}
-void qmpPluginAPIStub::unregisterMidiOutDevice(std::string name){}
+void qmpPluginAPIStub::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name) {}
+void qmpPluginAPIStub::unregisterMidiOutDevice(std::string name) {}
-int qmpPluginAPIStub::registerEventReaderIntf(ICallBack *cb, void *userdata){}
-void qmpPluginAPIStub::unregisterEventReaderIntf(int intfhandle){}
-int qmpPluginAPIStub::registerEventHandlerIntf(ICallBack *cb, void *userdata){}
-void qmpPluginAPIStub::unregisterEventHandlerIntf(int intfhandle){}
-int qmpPluginAPIStub::registerFileReadFinishedHandlerIntf(ICallBack *cb, void *userdata){}
-void qmpPluginAPIStub::unregisterFileReadFinishedHandlerIntf(int intfhandle){}
+int qmpPluginAPIStub::registerEventReaderIntf(ICallBack *cb, void *userdata) {}
+void qmpPluginAPIStub::unregisterEventReaderIntf(int intfhandle) {}
+int qmpPluginAPIStub::registerEventHandlerIntf(ICallBack *cb, void *userdata) {}
+void qmpPluginAPIStub::unregisterEventHandlerIntf(int intfhandle) {}
+int qmpPluginAPIStub::registerFileReadFinishedHandlerIntf(ICallBack *cb, void *userdata) {}
+void qmpPluginAPIStub::unregisterFileReadFinishedHandlerIntf(int intfhandle) {}
-int qmpPluginAPIStub::registerEventHandler(callback_t cb, void *userdata, bool post){}
-void qmpPluginAPIStub::unregisterEventHandler(int id){}
+int qmpPluginAPIStub::registerEventHandler(callback_t cb, void *userdata, bool post) {}
+void qmpPluginAPIStub::unregisterEventHandler(int id) {}
int qmpPluginAPIStub::registerEventReadHandler(callback_t cb, void *userdata)
{
- return core->player->registerEventReadHandler(cb,userdata);
+ return core->player->registerEventReadHandler(cb, userdata);
}
void qmpPluginAPIStub::unregisterEventReadHandler(int id)
{
- core->player->unregisterEventReadHandler(id);
+ core->player->unregisterEventReadHandler(id);
}
int qmpPluginAPIStub::registerFileReadFinishHook(callback_t cb, void *userdata)
{
- return core->player->registerFileReadFinishHook(cb,userdata);
+ return core->player->registerFileReadFinishHook(cb, userdata);
}
void qmpPluginAPIStub::unregisterFileReadFinishHook(int id)
{
- core->player->unregisterFileReadFinishHook(id);
+ core->player->unregisterFileReadFinishHook(id);
}
-void qmpPluginAPIStub::registerFileReader(qmpFileReader *reader, std::string name){}
-void qmpPluginAPIStub::unregisterFileReader(std::string name){}
+void qmpPluginAPIStub::registerFileReader(qmpFileReader *reader, std::string name) {}
+void qmpPluginAPIStub::unregisterFileReader(std::string name) {}
void qmpPluginAPIStub::registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval)
{
- core->settings()->registerOptionInt(tab,desc,key,min,max,defaultval);
+ core->settings()->registerOptionInt(tab, desc, key, min, max, defaultval);
}
int qmpPluginAPIStub::getOptionInt(std::string key)
{
- return core->settings()->getOptionInt(key);
+ return core->settings()->getOptionInt(key);
}
void qmpPluginAPIStub::setOptionInt(std::string key, int val)
{
- core->settings()->setOptionInt(key,val);
+ core->settings()->setOptionInt(key, val);
}
void qmpPluginAPIStub::registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval)
{
- core->settings()->registerOptionUint(tab,desc,key,min,max,defaultval);
+ core->settings()->registerOptionUint(tab, desc, key, min, max, defaultval);
}
unsigned qmpPluginAPIStub::getOptionUint(std::string key)
{
- return core->settings()->getOptionUint(key);
+ return core->settings()->getOptionUint(key);
}
void qmpPluginAPIStub::setOptionUint(std::string key, unsigned val)
{
- return core->settings()->setOptionUint(key,val);
+ return core->settings()->setOptionUint(key, val);
}
void qmpPluginAPIStub::registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval)
{
- core->settings()->registerOptionBool(tab,desc,key,defaultval);
+ core->settings()->registerOptionBool(tab, desc, key, defaultval);
}
bool qmpPluginAPIStub::getOptionBool(std::string key)
{
- return core->settings()->getOptionBool(key);
+ return core->settings()->getOptionBool(key);
}
void qmpPluginAPIStub::setOptionBool(std::string key, bool val)
{
- core->settings()->setOptionBool(key,val);
+ core->settings()->setOptionBool(key, val);
}
void qmpPluginAPIStub::registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval)
{
- core->settings()->registerOptionDouble(tab,desc,key,min,max,defaultval);
+ core->settings()->registerOptionDouble(tab, desc, key, min, max, defaultval);
}
double qmpPluginAPIStub::getOptionDouble(std::string key)
{
- return core->settings()->getOptionDouble(key);
+ return core->settings()->getOptionDouble(key);
}
void qmpPluginAPIStub::setOptionDouble(std::string key, double val)
{
- core->settings()->setOptionDouble(key,val);
+ core->settings()->setOptionDouble(key, val);
}
void qmpPluginAPIStub::registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool ispath)
{
- core->settings()->registerOptionString(tab,desc,key,defaultval,ispath);
+ core->settings()->registerOptionString(tab, desc, key, defaultval, ispath);
}
std::string qmpPluginAPIStub::getOptionString(std::string key)
{
- return core->settings()->getOptionString(key);
+ return core->settings()->getOptionString(key);
}
void qmpPluginAPIStub::setOptionString(std::string key, std::string val)
{
- core->settings()->setOptionString(key,val);
+ core->settings()->setOptionString(key, val);
}
void qmpPluginAPIStub::registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> options, int defaultval)
{
- core->settings()->registerOptionEnumInt(tab,desc,key,options,defaultval);
+ core->settings()->registerOptionEnumInt(tab, desc, key, options, defaultval);
}
int qmpPluginAPIStub::getOptionEnumInt(std::string key)
{
- return core->settings()->getOptionEnumInt(key);
+ return core->settings()->getOptionEnumInt(key);
}
void qmpPluginAPIStub::setOptionEnumInt(std::string key, int val)
{
- core->settings()->setOptionEnumInt(key,val);
+ core->settings()->setOptionEnumInt(key, val);
}
diff --git a/visualization/renderer/qmppluginapistub.hpp b/visualization/renderer/qmppluginapistub.hpp
index d96cfca..4a9024d 100644
--- a/visualization/renderer/qmppluginapistub.hpp
+++ b/visualization/renderer/qmppluginapistub.hpp
@@ -4,82 +4,82 @@
#include "qmpcorepublic.hpp"
class qmpVisRenderCore;
-class qmpPluginAPIStub:public qmpPluginAPI
+class qmpPluginAPIStub: public qmpPluginAPI
{
public:
- qmpPluginAPIStub(qmpVisRenderCore *_core);
- ~qmpPluginAPIStub();
- uint32_t getDivision();
- uint32_t getRawTempo();
- double getRealTempo();
- uint32_t getTimeSig();
- int getKeySig();
- uint32_t getNoteCount();
- uint32_t getMaxTick();
- uint32_t getCurrentPolyphone();
- uint32_t getMaxPolyphone();
- uint32_t getCurrentTimeStamp();
- uint32_t getCurrentPlaybackPercentage();
- int getChannelCC(int ch,int cc);
- int getChannelPreset(int ch);
- void playerSeek(uint32_t percentage);
- double getPitchBend(int ch);
- void getPitchBendRaw(int ch,uint32_t *pb,uint32_t *pbr);
- bool getChannelMask(int ch);
- std::string getTitle();
- std::wstring getWTitle();
- std::string getChannelPresetString(int ch);
- bool isDarkTheme();
- void* getMainWindow();
+ qmpPluginAPIStub(qmpVisRenderCore *_core);
+ ~qmpPluginAPIStub();
+ uint32_t getDivision();
+ uint32_t getRawTempo();
+ double getRealTempo();
+ uint32_t getTimeSig();
+ int getKeySig();
+ uint32_t getNoteCount();
+ uint32_t getMaxTick();
+ uint32_t getCurrentPolyphone();
+ uint32_t getMaxPolyphone();
+ uint32_t getCurrentTimeStamp();
+ uint32_t getCurrentPlaybackPercentage();
+ int getChannelCC(int ch, int cc);
+ int getChannelPreset(int ch);
+ void playerSeek(uint32_t percentage);
+ double getPitchBend(int ch);
+ void getPitchBendRaw(int ch, uint32_t *pb, uint32_t *pbr);
+ bool getChannelMask(int ch);
+ std::string getTitle();
+ std::wstring getWTitle();
+ std::string getChannelPresetString(int ch);
+ bool isDarkTheme();
+ void *getMainWindow();
- void discardCurrentEvent();
- void commitEventChange(SEvent d);
- void callEventReaderCB(SEvent d);
- void setFuncState(std::string name,bool state);
- void setFuncEnabled(std::string name,bool enable);
+ void discardCurrentEvent();
+ void commitEventChange(SEvent d);
+ void callEventReaderCB(SEvent d);
+ void setFuncState(std::string name, bool state);
+ void setFuncEnabled(std::string name, bool enable);
- void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable);
- void unregisterFunctionality(std::string name);
- int registerUIHook(std::string e,ICallBack* cb,void* userdat);
- int registerUIHook(std::string e,callback_t cb,void* userdat);
- void unregisterUIHook(std::string e,int hook);
- void registerMidiOutDevice(qmpMidiOutDevice* dev,std::string name);
- void unregisterMidiOutDevice(std::string name);
- int registerEventReaderIntf(ICallBack* cb,void* userdata);
- void unregisterEventReaderIntf(int intfhandle);
- int registerEventHandlerIntf(ICallBack* cb,void* userdata);
- void unregisterEventHandlerIntf(int intfhandle);
- int registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata);
- void unregisterFileReadFinishedHandlerIntf(int intfhandle);
- int registerEventHandler(callback_t cb,void *userdata,bool post=false);
- void unregisterEventHandler(int id);
- int registerEventReadHandler(callback_t cb,void *userdata);
- void unregisterEventReadHandler(int id);
- int registerFileReadFinishHook(callback_t cb,void *userdata);
- void unregisterFileReadFinishHook(int id);
- void registerFileReader(qmpFileReader* reader,std::string name);
- void unregisterFileReader(std::string name);
+ void registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable);
+ void unregisterFunctionality(std::string name);
+ int registerUIHook(std::string e, ICallBack *cb, void *userdat);
+ int registerUIHook(std::string e, callback_t cb, void *userdat);
+ void unregisterUIHook(std::string e, int hook);
+ void registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name);
+ void unregisterMidiOutDevice(std::string name);
+ int registerEventReaderIntf(ICallBack *cb, void *userdata);
+ void unregisterEventReaderIntf(int intfhandle);
+ int registerEventHandlerIntf(ICallBack *cb, void *userdata);
+ void unregisterEventHandlerIntf(int intfhandle);
+ int registerFileReadFinishedHandlerIntf(ICallBack *cb, void *userdata);
+ void unregisterFileReadFinishedHandlerIntf(int intfhandle);
+ int registerEventHandler(callback_t cb, void *userdata, bool post = false);
+ void unregisterEventHandler(int id);
+ int registerEventReadHandler(callback_t cb, void *userdata);
+ void unregisterEventReadHandler(int id);
+ int registerFileReadFinishHook(callback_t cb, void *userdata);
+ void unregisterFileReadFinishHook(int id);
+ void registerFileReader(qmpFileReader *reader, std::string name);
+ void unregisterFileReader(std::string name);
- void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval);
- int getOptionInt(std::string key);
- void setOptionInt(std::string key,int val);
- void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval);
- unsigned getOptionUint(std::string key);
- void setOptionUint(std::string key,unsigned val);
- void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval);
- bool getOptionBool(std::string key);
- void setOptionBool(std::string key,bool val);
- void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval);
- double getOptionDouble(std::string key);
- void setOptionDouble(std::string key,double val);
- void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath=false);
- std::string getOptionString(std::string key);
- void setOptionString(std::string key,std::string val);
- void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval);
- int getOptionEnumInt(std::string key);
- void setOptionEnumInt(std::string key,int val);
+ void registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval);
+ int getOptionInt(std::string key);
+ void setOptionInt(std::string key, int val);
+ void registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval);
+ unsigned getOptionUint(std::string key);
+ void setOptionUint(std::string key, unsigned val);
+ void registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval);
+ bool getOptionBool(std::string key);
+ void setOptionBool(std::string key, bool val);
+ void registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval);
+ double getOptionDouble(std::string key);
+ void setOptionDouble(std::string key, double val);
+ void registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool ispath = false);
+ std::string getOptionString(std::string key);
+ void setOptionString(std::string key, std::string val);
+ void registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> options, int defaultval);
+ int getOptionEnumInt(std::string key);
+ void setOptionEnumInt(std::string key, int val);
private:
- qmpVisRenderCore* core;
+ qmpVisRenderCore *core;
};
#endif // QMPPLUGINAPISTUB_HPP
diff --git a/visualization/renderer/qmpsettingsro.cpp b/visualization/renderer/qmpsettingsro.cpp
index 034f073..67dc257 100644
--- a/visualization/renderer/qmpsettingsro.cpp
+++ b/visualization/renderer/qmpsettingsro.cpp
@@ -9,218 +9,218 @@ qmpSettingsRO::qmpSettingsRO()
{
}
-void qmpSettingsRO::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval)
+void qmpSettingsRO::registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval)
{
- Q_UNUSED(tab)
- optionlist.push_back(key);
- options[key]=qmpOptionR(desc,qmpOptionR::ParameterType::parameter_int,defaultval,min,max);
+ Q_UNUSED(tab)
+ optionlist.push_back(key);
+ options[key] = qmpOptionR(desc, qmpOptionR::ParameterType::parameter_int, defaultval, min, max);
}
int qmpSettingsRO::getOptionInt(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_int)
- return settings.value(QString(key.c_str()),options[key].defaultval).toInt();
- return options[key].defaultval.toInt();
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_int)
+ return settings.value(QString(key.c_str()), options[key].defaultval).toInt();
+ return options[key].defaultval.toInt();
}
-void qmpSettingsRO::setOptionInt(std::string key,int val)
+void qmpSettingsRO::setOptionInt(std::string key, int val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_int)
- settings.insert(QString(key.c_str()),val);
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_int)
+ settings.insert(QString(key.c_str()), val);
}
-void qmpSettingsRO::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval)
+void qmpSettingsRO::registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval)
{
- Q_UNUSED(tab)
- optionlist.push_back(key);
- options[key]=qmpOptionR(desc,qmpOptionR::ParameterType::parameter_uint,defaultval,min,max);
+ Q_UNUSED(tab)
+ optionlist.push_back(key);
+ options[key] = qmpOptionR(desc, qmpOptionR::ParameterType::parameter_uint, defaultval, min, max);
}
unsigned qmpSettingsRO::getOptionUint(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_uint)
- return settings.value(QString(key.c_str()),options[key].defaultval).toUInt();
- return options[key].defaultval.toUInt();
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_uint)
+ return settings.value(QString(key.c_str()), options[key].defaultval).toUInt();
+ return options[key].defaultval.toUInt();
}
-void qmpSettingsRO::setOptionUint(std::string key,unsigned val)
+void qmpSettingsRO::setOptionUint(std::string key, unsigned val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_uint)
- settings.insert(QString(key.c_str()),val);
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_uint)
+ settings.insert(QString(key.c_str()), val);
}
-void qmpSettingsRO::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval)
+void qmpSettingsRO::registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval)
{
- Q_UNUSED(tab)
- optionlist.push_back(key);
- options[key]=qmpOptionR(desc,qmpOptionR::ParameterType::parameter_bool,defaultval);
+ Q_UNUSED(tab)
+ optionlist.push_back(key);
+ options[key] = qmpOptionR(desc, qmpOptionR::ParameterType::parameter_bool, defaultval);
}
bool qmpSettingsRO::getOptionBool(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_bool)
- return settings.value(QString(key.c_str()),options[key].defaultval).toBool();
- return options[key].defaultval.toBool();
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_bool)
+ return settings.value(QString(key.c_str()), options[key].defaultval).toBool();
+ return options[key].defaultval.toBool();
}
-void qmpSettingsRO::setOptionBool(std::string key,bool val)
+void qmpSettingsRO::setOptionBool(std::string key, bool val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_bool)
- settings.insert(QString(key.c_str()),val);
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_bool)
+ settings.insert(QString(key.c_str()), val);
}
-void qmpSettingsRO::registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval)
+void qmpSettingsRO::registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval)
{
- Q_UNUSED(tab)
- optionlist.push_back(key);
- options[key]=qmpOptionR(desc,qmpOptionR::ParameterType::parameter_double,defaultval,min,max);
+ Q_UNUSED(tab)
+ optionlist.push_back(key);
+ options[key] = qmpOptionR(desc, qmpOptionR::ParameterType::parameter_double, defaultval, min, max);
}
double qmpSettingsRO::getOptionDouble(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_double)
- return settings.value(QString(key.c_str()),options[key].defaultval).toDouble();
- return options[key].defaultval.toDouble();
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_double)
+ return settings.value(QString(key.c_str()), options[key].defaultval).toDouble();
+ return options[key].defaultval.toDouble();
}
-void qmpSettingsRO::setOptionDouble(std::string key,double val)
+void qmpSettingsRO::setOptionDouble(std::string key, double val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_double)
- settings.insert(QString(key.c_str()),val);
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_double)
+ settings.insert(QString(key.c_str()), val);
}
-void qmpSettingsRO::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool is_url)
+void qmpSettingsRO::registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool is_url)
{
- Q_UNUSED(tab)
- optionlist.push_back(key);
- options[key]=qmpOptionR(desc,
- is_url?qmpOptionR::ParameterType::parameter_url:qmpOptionR::ParameterType::parameter_str,
- QString(defaultval.c_str()));
+ Q_UNUSED(tab)
+ optionlist.push_back(key);
+ options[key] = qmpOptionR(desc,
+ is_url ? qmpOptionR::ParameterType::parameter_url : qmpOptionR::ParameterType::parameter_str,
+ QString(defaultval.c_str()));
}
std::string qmpSettingsRO::getOptionString(std::string key)
{
- if(options.find(key)!=options.end()&&
- (options[key].type==qmpOptionR::ParameterType::parameter_str||options[key].type==qmpOptionR::ParameterType::parameter_url))
- return settings.value(QString(key.c_str()),options[key].defaultval).toString().toStdString();
- return options[key].defaultval.toString().toStdString();
+ if (options.find(key) != options.end() &&
+ (options[key].type == qmpOptionR::ParameterType::parameter_str || options[key].type == qmpOptionR::ParameterType::parameter_url))
+ return settings.value(QString(key.c_str()), options[key].defaultval).toString().toStdString();
+ return options[key].defaultval.toString().toStdString();
}
-void qmpSettingsRO::setOptionString(std::string key,std::string val)
+void qmpSettingsRO::setOptionString(std::string key, std::string val)
{
- if(options.find(key)!=options.end()&&
- (options[key].type==qmpOptionR::ParameterType::parameter_str||options[key].type==qmpOptionR::ParameterType::parameter_url))
- settings.insert(QString(key.c_str()),QString(val.c_str()));
+ if (options.find(key) != options.end() &&
+ (options[key].type == qmpOptionR::ParameterType::parameter_str || options[key].type == qmpOptionR::ParameterType::parameter_url))
+ settings.insert(QString(key.c_str()), QString(val.c_str()));
}
-void qmpSettingsRO::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> enumlist,int defaultval)
+void qmpSettingsRO::registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> enumlist, int defaultval)
{
- Q_UNUSED(tab)
- optionlist.push_back(key);
- options[key]=qmpOptionR(desc,qmpOptionR::ParameterType::parameter_enum,defaultval);
- options[key].enumlist=enumlist;
+ Q_UNUSED(tab)
+ optionlist.push_back(key);
+ options[key] = qmpOptionR(desc, qmpOptionR::ParameterType::parameter_enum, defaultval);
+ options[key].enumlist = enumlist;
}
int qmpSettingsRO::getOptionEnumInt(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_enum)
- {
- std::string curitm=settings.value(QString(key.c_str()),options[key].defaultval).toString().toStdString();
- auto curidx=std::find(options[key].enumlist.begin(),options[key].enumlist.end(),curitm);
- if(curidx!=options[key].enumlist.end())
- return static_cast<int>(curidx-options[key].enumlist.begin());
- else
- {
- return options[key].defaultval.toInt();
- }
- }
- return options[key].defaultval.toInt();
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_enum)
+ {
+ std::string curitm = settings.value(QString(key.c_str()), options[key].defaultval).toString().toStdString();
+ auto curidx = std::find(options[key].enumlist.begin(), options[key].enumlist.end(), curitm);
+ if (curidx != options[key].enumlist.end())
+ return static_cast<int>(curidx - options[key].enumlist.begin());
+ else
+ {
+ return options[key].defaultval.toInt();
+ }
+ }
+ return options[key].defaultval.toInt();
}
std::string qmpSettingsRO::getOptionEnumIntOptName(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_enum)
- {
- std::string curitm=settings.value(QString(key.c_str()),options[key].defaultval).toString().toStdString();
- auto curidx=std::find(options[key].enumlist.begin(),options[key].enumlist.end(),curitm);
- if(curidx!=options[key].enumlist.end())
- return curitm;
- else
- {
- return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
- }
- }
- return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
-}
-void qmpSettingsRO::setOptionEnumInt(std::string key,int val)
-{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_enum)
- {
- if(static_cast<size_t>(val)<options[key].enumlist.size())
- settings.insert(QString(key.c_str()),QString(options[key].enumlist[static_cast<size_t>(val)].c_str()));
- }
-}
-void qmpSettingsRO::setOptionEnumIntOptName(std::string key,std::string valname)
-{
- if(options.find(key)!=options.end()&&options[key].type==qmpOptionR::ParameterType::parameter_enum)
- {
- auto curidx=std::find(options[key].enumlist.begin(),options[key].enumlist.end(),valname);
- if(curidx!=options[key].enumlist.end())
- settings.insert(QString(key.c_str()),QString(valname.c_str()));
- }
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_enum)
+ {
+ std::string curitm = settings.value(QString(key.c_str()), options[key].defaultval).toString().toStdString();
+ auto curidx = std::find(options[key].enumlist.begin(), options[key].enumlist.end(), curitm);
+ if (curidx != options[key].enumlist.end())
+ return curitm;
+ else
+ {
+ return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
+ }
+ }
+ return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
+}
+void qmpSettingsRO::setOptionEnumInt(std::string key, int val)
+{
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_enum)
+ {
+ if (static_cast<size_t>(val) < options[key].enumlist.size())
+ settings.insert(QString(key.c_str()), QString(options[key].enumlist[static_cast<size_t>(val)].c_str()));
+ }
+}
+void qmpSettingsRO::setOptionEnumIntOptName(std::string key, std::string valname)
+{
+ if (options.find(key) != options.end() && options[key].type == qmpOptionR::ParameterType::parameter_enum)
+ {
+ auto curidx = std::find(options[key].enumlist.begin(), options[key].enumlist.end(), valname);
+ if (curidx != options[key].enumlist.end())
+ settings.insert(QString(key.c_str()), QString(valname.c_str()));
+ }
}
void qmpSettingsRO::load(const char *path)
{
- QScopedPointer<QSettings> qsettings(new QSettings(path,QSettings::Format::IniFormat));
- settings.clear();
- for(QString&k:qsettings->allKeys())
- {
- settings.insert(k,qsettings->value(k));
- }
+ QScopedPointer<QSettings> qsettings(new QSettings(path, QSettings::Format::IniFormat));
+ settings.clear();
+ for (QString &k : qsettings->allKeys())
+ {
+ settings.insert(k, qsettings->value(k));
+ }
}
void qmpSettingsRO::setopt(std::string key, std::string val)
{
- settings.insert(QString(key.c_str()),QString(val.c_str()));
- if(key.find("Visualization/")!=0)
- settings.insert("Visualization/"+QString(key.c_str()),QString(val.c_str()));
+ settings.insert(QString(key.c_str()), QString(val.c_str()));
+ if (key.find("Visualization/") != 0)
+ settings.insert("Visualization/" + QString(key.c_str()), QString(val.c_str()));
}
void qmpSettingsRO::listopt()
{
- for(auto&k:optionlist)
- {
- printf("Option key: %s\n",k.c_str());
- if(options[k].desc.length())
- printf("Description: %s\n",options[k].desc.c_str());
- switch(options[k].type)
- {
- case qmpOptionR::ParameterType::parameter_int:
- printf("Type: int\n");
- printf("Range: [%d,%d]\n",options[k].minv.toInt(),options[k].maxv.toInt());
- printf("Default value: %d\n",options[k].defaultval.toInt());
- break;
- case qmpOptionR::ParameterType::parameter_uint:
- printf("Type: uint\n");
- printf("Range: [%u,%u]\n",options[k].minv.toUInt(),options[k].maxv.toUInt());
- printf("Default value: %u\n",options[k].defaultval.toUInt());
- break;
- case qmpOptionR::ParameterType::parameter_double:
- printf("Type: double\n");
- printf("Range: [%.2f,%.2f]\n",options[k].minv.toDouble(),options[k].maxv.toDouble());
- printf("Default value: %.f2\n",options[k].defaultval.toDouble());
- break;
- case qmpOptionR::ParameterType::parameter_bool:
- printf("Type: bool\n");
- printf("Default value: %s\n",options[k].defaultval.toBool()?"true":"false");
- break;
- case qmpOptionR::ParameterType::parameter_str:
- printf("Type: str\n");
- printf("Default value: %s\n",options[k].defaultval.toString().toStdString().c_str());
- break;
- case qmpOptionR::ParameterType::parameter_url:
- printf("Type: url\n");
- printf("Default value: %s\n",options[k].defaultval.toString().toStdString().c_str());
- break;
- case qmpOptionR::ParameterType::parameter_enum:
- printf("Type: enum\n");
- printf("Possible values: ");
- for(size_t i=0;i<options[k].enumlist.size();++i)
- printf("%s%s",options[k].enumlist[i].c_str(),i==options[k].enumlist.size()-1?"\n":", ");
- printf("Default value: %s\n",options[k].enumlist[options[k].defaultval.toInt()].c_str());
- break;
- default:
- printf("Type: unknown\n");
- }
- puts("");
- }
+ for (auto &k : optionlist)
+ {
+ printf("Option key: %s\n", k.c_str());
+ if (options[k].desc.length())
+ printf("Description: %s\n", options[k].desc.c_str());
+ switch (options[k].type)
+ {
+ case qmpOptionR::ParameterType::parameter_int:
+ printf("Type: int\n");
+ printf("Range: [%d,%d]\n", options[k].minv.toInt(), options[k].maxv.toInt());
+ printf("Default value: %d\n", options[k].defaultval.toInt());
+ break;
+ case qmpOptionR::ParameterType::parameter_uint:
+ printf("Type: uint\n");
+ printf("Range: [%u,%u]\n", options[k].minv.toUInt(), options[k].maxv.toUInt());
+ printf("Default value: %u\n", options[k].defaultval.toUInt());
+ break;
+ case qmpOptionR::ParameterType::parameter_double:
+ printf("Type: double\n");
+ printf("Range: [%.2f,%.2f]\n", options[k].minv.toDouble(), options[k].maxv.toDouble());
+ printf("Default value: %.f2\n", options[k].defaultval.toDouble());
+ break;
+ case qmpOptionR::ParameterType::parameter_bool:
+ printf("Type: bool\n");
+ printf("Default value: %s\n", options[k].defaultval.toBool() ? "true" : "false");
+ break;
+ case qmpOptionR::ParameterType::parameter_str:
+ printf("Type: str\n");
+ printf("Default value: %s\n", options[k].defaultval.toString().toStdString().c_str());
+ break;
+ case qmpOptionR::ParameterType::parameter_url:
+ printf("Type: url\n");
+ printf("Default value: %s\n", options[k].defaultval.toString().toStdString().c_str());
+ break;
+ case qmpOptionR::ParameterType::parameter_enum:
+ printf("Type: enum\n");
+ printf("Possible values: ");
+ for (size_t i = 0; i < options[k].enumlist.size(); ++i)
+ printf("%s%s", options[k].enumlist[i].c_str(), i == options[k].enumlist.size() - 1 ? "\n" : ", ");
+ printf("Default value: %s\n", options[k].enumlist[options[k].defaultval.toInt()].c_str());
+ break;
+ default:
+ printf("Type: unknown\n");
+ }
+ puts("");
+ }
}
diff --git a/visualization/renderer/qmpsettingsro.hpp b/visualization/renderer/qmpsettingsro.hpp
index c5dd8af..1a3927b 100644
--- a/visualization/renderer/qmpsettingsro.hpp
+++ b/visualization/renderer/qmpsettingsro.hpp
@@ -10,66 +10,67 @@
struct qmpOptionR
{
- enum ParameterType{
- parameter_int=0,
- parameter_uint,
- parameter_bool,
- parameter_double,
- parameter_str,
- parameter_enum,
- parameter_url,
- parameter_custom=0x100
- };
+ enum ParameterType
+ {
+ parameter_int = 0,
+ parameter_uint,
+ parameter_bool,
+ parameter_double,
+ parameter_str,
+ parameter_enum,
+ parameter_url,
+ parameter_custom = 0x100
+ };
- std::string desc;
- ParameterType type;
- QVariant defaultval,minv,maxv;
- std::vector<std::string> enumlist;
+ std::string desc;
+ ParameterType type;
+ QVariant defaultval, minv, maxv;
+ std::vector<std::string> enumlist;
- qmpOptionR(){}
- qmpOptionR(
- std::string _desc,
- ParameterType _t,QVariant _def=QVariant(),
- QVariant _min=QVariant(),QVariant _max=QVariant()):
- desc(_desc),
- type(_t),
- defaultval(_def),
- minv(_min),
- maxv(_max){}
+ qmpOptionR() {}
+ qmpOptionR(
+ std::string _desc,
+ ParameterType _t, QVariant _def = QVariant(),
+ QVariant _min = QVariant(), QVariant _max = QVariant()):
+ desc(_desc),
+ type(_t),
+ defaultval(_def),
+ minv(_min),
+ maxv(_max) {}
};
class qmpSettingsRO
{
public:
- qmpSettingsRO();
- void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval);
- int getOptionInt(std::string key);
- void setOptionInt(std::string key,int val);
- void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval);
- unsigned getOptionUint(std::string key);
- void setOptionUint(std::string key,unsigned val);
- void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval);
- bool getOptionBool(std::string key);
- void setOptionBool(std::string key,bool val);
- void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval);
- double getOptionDouble(std::string key);
- void setOptionDouble(std::string key,double val);
- void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool is_url);
- std::string getOptionString(std::string key);
- void setOptionString(std::string key,std::string val);
- void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> enumlist,int defaultval);
- int getOptionEnumInt(std::string key);
- std::string getOptionEnumIntOptName(std::string key);
- void setOptionEnumInt(std::string key,int val);
- void setOptionEnumIntOptName(std::string key,std::string valname);
+ qmpSettingsRO();
+ void registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval);
+ int getOptionInt(std::string key);
+ void setOptionInt(std::string key, int val);
+ void registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval);
+ unsigned getOptionUint(std::string key);
+ void setOptionUint(std::string key, unsigned val);
+ void registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval);
+ bool getOptionBool(std::string key);
+ void setOptionBool(std::string key, bool val);
+ void registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval);
+ double getOptionDouble(std::string key);
+ void setOptionDouble(std::string key, double val);
+ void registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool is_url);
+ std::string getOptionString(std::string key);
+ void setOptionString(std::string key, std::string val);
+ void registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> enumlist, int defaultval);
+ int getOptionEnumInt(std::string key);
+ std::string getOptionEnumIntOptName(std::string key);
+ void setOptionEnumInt(std::string key, int val);
+ void setOptionEnumIntOptName(std::string key, std::string valname);
- void load(const char* path);
- void setopt(std::string key,std::string val);
- void listopt();
+ void load(const char *path);
+ void setopt(std::string key, std::string val);
+ void listopt();
private:
- std::map<std::string,qmpOptionR> options;
- std::vector<std::string> optionlist;
- QVariantMap settings;
+ std::map<std::string, qmpOptionR> options;
+ std::vector<std::string> optionlist;
+ QVariantMap settings;
};
#endif
diff --git a/visualization/renderer/qmpvisrendercore.cpp b/visualization/renderer/qmpvisrendercore.cpp
index b12ed91..9d58206 100644
--- a/visualization/renderer/qmpvisrendercore.cpp
+++ b/visualization/renderer/qmpvisrendercore.cpp
@@ -19,262 +19,271 @@
#include <QCommandLineParser>
#include <QDebug>
#include <QThread>
-qmpVisRenderCore *qmpVisRenderCore::inst=nullptr;
+qmpVisRenderCore *qmpVisRenderCore::inst = nullptr;
-qmpVisRenderCore::qmpVisRenderCore(QCommandLineParser *_clp):QObject(nullptr),clp(_clp)
+qmpVisRenderCore::qmpVisRenderCore(QCommandLineParser *_clp): QObject(nullptr), clp(_clp)
{
- inst=this;
- player=new CMidiPlayer();
- api=new qmpPluginAPIStub(this);
- msettings=new qmpSettingsRO();
- frameno=0;
- msettings->registerOptionEnumInt("MIDI","Text encoding","Midi/TextEncoding",{"Unicode","Big5","Big5-HKSCS","CP949","EUC-JP","EUC-KR","GB18030","KOI8-R","KOI8-U","Macintosh","Shift-JIS"},0);
+ inst = this;
+ player = new CMidiPlayer();
+ api = new qmpPluginAPIStub(this);
+ msettings = new qmpSettingsRO();
+ frameno = 0;
+ msettings->registerOptionEnumInt("MIDI", "Text encoding", "Midi/TextEncoding", {"Unicode", "Big5", "Big5-HKSCS", "CP949", "EUC-JP", "EUC-KR", "GB18030", "KOI8-R", "KOI8-U", "Macintosh", "Shift-JIS"}, 0);
}
bool qmpVisRenderCore::loadVisualizationLibrary()
{
#ifdef _WIN32
- std::vector<std::wstring> libpath={
- QCoreApplication::applicationDirPath().toStdWString()+L"/plugins/libvisualization.dll",
- L"libvisualization.dll",
- L"../libvisualization.dll"//for debugging only...?
- };
+ std::vector<std::wstring> libpath =
+ {
+ QCoreApplication::applicationDirPath().toStdWString() + L"/plugins/libvisualization.dll",
+ L"libvisualization.dll",
+ L"../libvisualization.dll"//for debugging only...?
+ };
#else
- std::vector<std::string> libpath={
- QCoreApplication::applicationDirPath().toStdString()+"/plugins/libvisualization.so",
- QT_STRINGIFY(INSTALL_PREFIX)+std::string("/lib/qmidiplayer/libvisualization.so"),
- "../libvisualization.so"//for debugging only
- };
+ std::vector<std::string> libpath =
+ {
+ QCoreApplication::applicationDirPath().toStdString() + "/plugins/libvisualization.so",
+ QT_STRINGIFY(INSTALL_PREFIX) + std::string("/lib/qmidiplayer/libvisualization.so"),
+ "../libvisualization.so"//for debugging only
+ };
#endif
- for(auto&l:libpath)
- {
- mp=dlopen(l.c_str(),RTLD_LAZY);
- if(mp)break;
- }
- if(!mp)
- {
- fprintf(stderr,"failed to load the visualization module!\n");
- return false;
- }
- GetInterface_func getintf=reinterpret_cast<GetInterface_func>(dlsym(mp,"qmpPluginGetInterface"));
- SwitchMode_func switchmode=reinterpret_cast<SwitchMode_func>(dlsym(mp,"switchToRenderMode"));
- vf=nullptr;
- vp=getintf(api);
- switchmode(&qmpVisRenderCore::framefunc,!clp->isSet("show-window"));
- vp->init();
- resetcb(nullptr,nullptr);
- if(clp->isSet("list-options"))
- {
- msettings->listopt();
- exit(0);
- }
- return true;
+ for (auto &l : libpath)
+ {
+ mp = dlopen(l.c_str(), RTLD_LAZY);
+ if (mp)
+ break;
+ }
+ if (!mp)
+ {
+ fprintf(stderr, "failed to load the visualization module!\n");
+ return false;
+ }
+ GetInterface_func getintf = reinterpret_cast<GetInterface_func>(dlsym(mp, "qmpPluginGetInterface"));
+ SwitchMode_func switchmode = reinterpret_cast<SwitchMode_func>(dlsym(mp, "switchToRenderMode"));
+ vf = nullptr;
+ vp = getintf(api);
+ switchmode(&qmpVisRenderCore::framefunc, !clp->isSet("show-window"));
+ vp->init();
+ resetcb(nullptr, nullptr);
+ if (clp->isSet("list-options"))
+ {
+ msettings->listopt();
+ exit(0);
+ }
+ return true;
}
void qmpVisRenderCore::unloadVisualizationLibrary()
{
- vp->deinit();
- dlclose(mp);
+ vp->deinit();
+ dlclose(mp);
}
void qmpVisRenderCore::loadSettings()
{
- if(clp->isSet("config"))
- msettings->load(clp->value("config").toStdString().c_str());
- for(auto &o:clp->values("option"))
- {
- int sp=o.indexOf('=');
- if(!~sp)
- {
- qDebug("invalid option pair: %s",o.toStdString().c_str());
- continue;
- }
- QString key=o.left(sp);
- QString value=o.mid(sp+1);
- msettings->setopt(key.toStdString(),value.toStdString());
- }
+ if (clp->isSet("config"))
+ msettings->load(clp->value("config").toStdString().c_str());
+ for (auto &o : clp->values("option"))
+ {
+ int sp = o.indexOf('=');
+ if (!~sp)
+ {
+ qDebug("invalid option pair: %s", o.toStdString().c_str());
+ continue;
+ }
+ QString key = o.left(sp);
+ QString value = o.mid(sp + 1);
+ msettings->setopt(key.toStdString(), value.toStdString());
+ }
}
void qmpVisRenderCore::setMIDIFile(const char *url)
{
- player->playerLoadFile(url);
+ player->playerLoadFile(url);
}
void qmpVisRenderCore::startRender()
{
- assert(vf);
- subst={
- {'w',QString::number(msettings->getOptionInt("Visualization/wwidth"))},
- {'h',QString::number(msettings->getOptionInt("Visualization/wheight"))},
- {'r',QString::number(msettings->getOptionInt("Visualization/tfps"))},
- {'i',
- QStringList()
- <<"-f"<<"rawvideo"
- <<"-pixel_format"<<"rgba"
- <<"-video_size"<<QString("%1x%2").arg(msettings->getOptionInt("Visualization/wwidth")).arg(msettings->getOptionInt("Visualization/wheight"))
- <<"-framerate"<<QString::number(msettings->getOptionInt("Visualization/tfps"))
- <<"-i"<<"pipe:"
- },
- {'o',clp->value("output-file")}
- };
- if(clp->value("receiver-execution")=="per-frame")
- {
- subst['o']=clp->value("output-file").replace("%f",QString("%1").arg(frameno,6,10,QChar('0')));
- oneshot=false;
- }
- else
- {
- oneshot=true;
- if(clp->value("receiver-execution")!="one-shot")
- qWarning("Invalid value set for --receiver-execution. Using default value.");
- }
- rxproc=new QProcess();
- QStringList arguments=process_arguments(clp->value("receiver"),subst);
- assert(arguments.length()>0);
- rxproc->setProgram(arguments.front());
- arguments.pop_front();
- rxproc->setArguments(arguments);
- frameconn=connect(this,&qmpVisRenderCore::frameRendered,this,
- [this](void* px,size_t sz,uint32_t c,uint32_t t)
- {
- if(sz)
- {
- if(!oneshot)
- {
- subst['f']=QString("%1").arg(frameno,6,10,QChar('0'));
- subst['o']=clp->value("output-file").replace("%f",QString("%1").arg(frameno,6,10,QChar('0')));
- frameno++;
- QStringList arguments=process_arguments(clp->value("receiver"),subst);
- arguments.pop_front();
- rxproc->setArguments(arguments);
- rxproc->start();
- rxproc->waitForStarted();
- }
- if(!rxproc->isOpen())return;
- rxproc->write(static_cast<const char*>(px),static_cast<qint64>(sz));
- while(rxproc->bytesToWrite()>(oneshot?(1<<26):0))
- rxproc->waitForBytesWritten();
- if(!oneshot)
- {
- rxproc->closeWriteChannel();
- rxproc->waitForFinished(-1);
- }
- }
- fprintf(stderr,"Rendered tick %u of %u, %.2f%% done.\r",c,t,std::min(100.,100.*c/t));
- if(c>t)
- {
- this->rxproc->closeWriteChannel();
- disconnect(frameconn);
- qApp->exit(0);
- }
- },Qt::ConnectionType::BlockingQueuedConnection);
- connect(rxproc,QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished),
- [this](int x,QProcess::ExitStatus st){
- qDebug("%s",this->rxproc->readAllStandardError().data());
- if(oneshot)
- {
- disconnect(frameconn);
- if(x||st==QProcess::ExitStatus::CrashExit)
- qApp->exit(1);
- else
- qApp->exit(0);
- }
- });
- QMetaObject::invokeMethod(this,[this](){
- if(oneshot)
- rxproc->start();
- vf->show();
- startcb(nullptr,nullptr);
- },Qt::ConnectionType::QueuedConnection);
+ assert(vf);
+ subst =
+ {
+ {'w', QString::number(msettings->getOptionInt("Visualization/wwidth"))},
+ {'h', QString::number(msettings->getOptionInt("Visualization/wheight"))},
+ {'r', QString::number(msettings->getOptionInt("Visualization/tfps"))},
+ {
+ 'i',
+ QStringList()
+ << "-f" << "rawvideo"
+ << "-pixel_format" << "rgba"
+ << "-video_size" << QString("%1x%2").arg(msettings->getOptionInt("Visualization/wwidth")).arg(msettings->getOptionInt("Visualization/wheight"))
+ << "-framerate" << QString::number(msettings->getOptionInt("Visualization/tfps"))
+ << "-i" << "pipe:"
+ },
+ {'o', clp->value("output-file")}
+ };
+ if (clp->value("receiver-execution") == "per-frame")
+ {
+ subst['o'] = clp->value("output-file").replace("%f", QString("%1").arg(frameno, 6, 10, QChar('0')));
+ oneshot = false;
+ }
+ else
+ {
+ oneshot = true;
+ if (clp->value("receiver-execution") != "one-shot")
+ qWarning("Invalid value set for --receiver-execution. Using default value.");
+ }
+ rxproc = new QProcess();
+ QStringList arguments = process_arguments(clp->value("receiver"), subst);
+ assert(arguments.length() > 0);
+ rxproc->setProgram(arguments.front());
+ arguments.pop_front();
+ rxproc->setArguments(arguments);
+ frameconn = connect(this, &qmpVisRenderCore::frameRendered, this,
+ [this](void *px, size_t sz, uint32_t c, uint32_t t)
+ {
+ if (sz)
+ {
+ if (!oneshot)
+ {
+ subst['f'] = QString("%1").arg(frameno, 6, 10, QChar('0'));
+ subst['o'] = clp->value("output-file").replace("%f", QString("%1").arg(frameno, 6, 10, QChar('0')));
+ frameno++;
+ QStringList arguments = process_arguments(clp->value("receiver"), subst);
+ arguments.pop_front();
+ rxproc->setArguments(arguments);
+ rxproc->start();
+ rxproc->waitForStarted();
+ }
+ if (!rxproc->isOpen())
+ return;
+ rxproc->write(static_cast<const char *>(px), static_cast<qint64>(sz));
+ while (rxproc->bytesToWrite() > (oneshot ? (1 << 26) : 0))
+ rxproc->waitForBytesWritten();
+ if (!oneshot)
+ {
+ rxproc->closeWriteChannel();
+ rxproc->waitForFinished(-1);
+ }
+ }
+ fprintf(stderr, "Rendered tick %u of %u, %.2f%% done.\r", c, t, std::min(100., 100.*c / t));
+ if (c > t)
+ {
+ this->rxproc->closeWriteChannel();
+ disconnect(frameconn);
+ qApp->exit(0);
+ }
+ }, Qt::ConnectionType::BlockingQueuedConnection);
+ connect(rxproc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
+ [this](int x, QProcess::ExitStatus st)
+ {
+ qDebug("%s", this->rxproc->readAllStandardError().data());
+ if (oneshot)
+ {
+ disconnect(frameconn);
+ if (x || st == QProcess::ExitStatus::CrashExit)
+ qApp->exit(1);
+ else
+ qApp->exit(0);
+ }
+ });
+ QMetaObject::invokeMethod(this, [this]()
+ {
+ if (oneshot)
+ rxproc->start();
+ vf->show();
+ startcb(nullptr, nullptr);
+ }, Qt::ConnectionType::QueuedConnection);
}
-QStringList qmpVisRenderCore::process_arguments(QString a,QMap<QChar,QVariant> subst)
+QStringList qmpVisRenderCore::process_arguments(QString a, QMap<QChar, QVariant> subst)
{
- QStringList ret;
- QString buf;
- bool escaped=false;
- bool substi=false;
- for(int i=0;i<a.length();++i)
- {
- if(a[i]=='%')
- {
- if(escaped)
- {
- buf+='%';
- escaped=false;
- }
- else if(substi)
- {
- buf+='%';
- substi=false;
- }
- else substi=true;
- }
- else if(a[i]=='\\')
- {
- if(substi)
- {
- buf+='%';
- substi=false;
- }
- if(escaped)
- {
- buf+='\\';
- escaped=false;
- }
- else escaped=true;
- }
- else if(a[i]==' ')
- {
- if(substi)
- {
- buf+='%';
- substi=false;
- }
- if(escaped)buf+=' ';
- else
- {
- if(buf.length())
- ret.append(buf);
- buf.clear();
- }
- escaped=false;
- }
- else
- {
- if(substi&&subst.contains(a[i]))
- {
- if(subst[a[i]].canConvert(QMetaType::QString))
- buf+=subst[a[i]].toString();
- else
- {
- if(buf.length())
- {
- ret.append(buf);
- buf.clear();
- }
- for(auto &it:subst[a[i]].toStringList())
- ret.append(it);
- }
- substi=false;
- }
- else
- {
- if(escaped)
- {
- buf+='\\';
- escaped=false;
- }
- buf+=a[i];
- }
- }
- }
- if(buf.length())
- ret.append(buf);
- return ret;
+ QStringList ret;
+ QString buf;
+ bool escaped = false;
+ bool substi = false;
+ for (int i = 0; i < a.length(); ++i)
+ {
+ if (a[i] == '%')
+ {
+ if (escaped)
+ {
+ buf += '%';
+ escaped = false;
+ }
+ else if (substi)
+ {
+ buf += '%';
+ substi = false;
+ }
+ else substi = true;
+ }
+ else if (a[i] == '\\')
+ {
+ if (substi)
+ {
+ buf += '%';
+ substi = false;
+ }
+ if (escaped)
+ {
+ buf += '\\';
+ escaped = false;
+ }
+ else escaped = true;
+ }
+ else if (a[i] == ' ')
+ {
+ if (substi)
+ {
+ buf += '%';
+ substi = false;
+ }
+ if (escaped)
+ buf += ' ';
+ else
+ {
+ if (buf.length())
+ ret.append(buf);
+ buf.clear();
+ }
+ escaped = false;
+ }
+ else
+ {
+ if (substi && subst.contains(a[i]))
+ {
+ if (subst[a[i]].canConvert(QMetaType::QString))
+ buf += subst[a[i]].toString();
+ else
+ {
+ if (buf.length())
+ {
+ ret.append(buf);
+ buf.clear();
+ }
+ for (auto &it : subst[a[i]].toStringList())
+ ret.append(it);
+ }
+ substi = false;
+ }
+ else
+ {
+ if (escaped)
+ {
+ buf += '\\';
+ escaped = false;
+ }
+ buf += a[i];
+ }
+ }
+ }
+ if (buf.length())
+ ret.append(buf);
+ return ret;
}
-void qmpVisRenderCore::framefunc(void *px, size_t sz,uint32_t curf,uint32_t totf)
+void qmpVisRenderCore::framefunc(void *px, size_t sz, uint32_t curf, uint32_t totf)
{
- emit inst->frameRendered(px,sz,curf,totf);
+ emit inst->frameRendered(px, sz, curf, totf);
}
diff --git a/visualization/renderer/qmpvisrendercore.hpp b/visualization/renderer/qmpvisrendercore.hpp
index 71eeaed..ba978f4 100644
--- a/visualization/renderer/qmpvisrendercore.hpp
+++ b/visualization/renderer/qmpvisrendercore.hpp
@@ -15,44 +15,47 @@ class QCommandLineParser;
class QProcess;
-class qmpVisRenderCore:public QObject
+class qmpVisRenderCore: public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- qmpVisRenderCore(QCommandLineParser *_clp);
- bool loadVisualizationLibrary();
- void unloadVisualizationLibrary();
- void loadSettings();
- void setMIDIFile(const char* url);
- void startRender();
-
- qmpSettingsRO* settings(){return msettings;}
+ qmpVisRenderCore(QCommandLineParser *_clp);
+ bool loadVisualizationLibrary();
+ void unloadVisualizationLibrary();
+ void loadSettings();
+ void setMIDIFile(const char *url);
+ void startRender();
+
+ qmpSettingsRO *settings()
+ {
+ return msettings;
+ }
signals:
- void frameRendered(void* px,size_t sz,uint32_t current_tick,uint32_t total_ticks);
+ void frameRendered(void *px, size_t sz, uint32_t current_tick, uint32_t total_ticks);
private:
- qmpPluginIntf *vp;
- qmpFuncBaseIntf *vf;
- callback_t startcb;
- callback_t resetcb;
- void *mp;
- qmpPluginAPIStub *api;
- CMidiPlayer *player;
- qmpSettingsRO *msettings;
- QProcess *rxproc;
- QMap<QChar,QVariant> subst;
- QCommandLineParser *clp;
- QStringList process_arguments(QString a, QMap<QChar,QVariant> subst);
- int frameno;
- bool oneshot;
- QMetaObject::Connection frameconn;
- typedef qmpPluginIntf*(*GetInterface_func)(qmpPluginAPI*);
- typedef void(*SwitchMode_func)(void(*frameCallback)(void*,size_t,uint32_t,uint32_t),bool hidewindow);
-
- friend class qmpPluginAPIStub;
- static void framefunc(void* px, size_t sz, uint32_t curf, uint32_t totf);
- static qmpVisRenderCore *inst;
+ qmpPluginIntf *vp;
+ qmpFuncBaseIntf *vf;
+ callback_t startcb;
+ callback_t resetcb;
+ void *mp;
+ qmpPluginAPIStub *api;
+ CMidiPlayer *player;
+ qmpSettingsRO *msettings;
+ QProcess *rxproc;
+ QMap<QChar, QVariant> subst;
+ QCommandLineParser *clp;
+ QStringList process_arguments(QString a, QMap<QChar, QVariant> subst);
+ int frameno;
+ bool oneshot;
+ QMetaObject::Connection frameconn;
+ typedef qmpPluginIntf *(*GetInterface_func)(qmpPluginAPI *);
+ typedef void(*SwitchMode_func)(void(*frameCallback)(void *, size_t, uint32_t, uint32_t), bool hidewindow);
+
+ friend class qmpPluginAPIStub;
+ static void framefunc(void *px, size_t sz, uint32_t curf, uint32_t totf);
+ static qmpVisRenderCore *inst;
};
#endif // QMPVISRENDERCORE_HPP