diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt new file mode 100644 index 000000000..de5083dad --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/CMakeLists.txt @@ -0,0 +1,44 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_DISP_SHEET_ID_PLUGIN_HDR + bin_reader.h + dialog.h + disp_sheet_id_plugin.h) + +SET(OVQT_DISP_SHEET_ID_PLUGIN_UIS + dialog.ui) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_WRAP_CPP(OVQT_DISP_SHEET_ID_PLUGIN_MOC_SRC ${OVQT_DISP_SHEET_ID_PLUGIN_HDR}) +QT4_WRAP_UI(OVQT_DISP_SHEET_ID_PLUGIN_UI_HDRS ${OVQT_DISP_SHEET_ID_PLUGIN_UIS}) + +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_DISP_SHEET_ID_PLUGIN_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_DISP_SHEET_ID_PLUGIN_MOC_SRC}) +SOURCE_GROUP("Display sheet id Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_disp_sheet_id MODULE ${SRC} ${OVQT_DISP_SHEET_ID_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_DISP_SHEET_ID_PLUGIN_UI_HDRS}) + +TARGET_LINK_LIBRARIES(ovqt_plugin_disp_sheet_id nelmisc nel3d ${QT_LIBRARIES}) + +IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(ovqt_plugin_disp_sheet_id ${CMAKE_THREAD_LIBS_INIT}) +ENDIF(WITH_STLPORT) + +NL_DEFAULT_PROPS(ovqt_plugin_disp_sheet_id "NeL, Tools, 3D: Object Viewer Qt Plugin: Display sheet id") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_disp_sheet_id) +NL_ADD_LIB_SUFFIX(ovqt_plugin_disp_sheet_id) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_disp_sheet_id LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp new file mode 100644 index 000000000..720dc6af5 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.cpp @@ -0,0 +1,55 @@ +#include "nel/misc/types_nl.h" +#include +#include "bin_reader.h" +#include +#include +#include +#include +#include "nel/misc/path.h" +#include "nel/misc/sheet_id.h" +#include +#include "nel/misc/types_nl.h" + +class CPred +{ +public: + bool operator()(const CSheetId &a, const CSheetId &b) + { + return a.toString()SheetList); + CPred Pred; + sort(this->SheetList.begin(), this->SheetList.end(), Pred); +// this->SheetList.fromStdVector(sheets); +} +int BinReader::count() +{ + return this->SheetList.size(); +} +std::vector BinReader::getVector() const +{ + return this->SheetList; +} +void BinReader::pushToTable(QTableWidget*& table) +{ + table->clear(); + table->setRowCount(this->SheetList.size()); + table->setColumnCount(2); + for (int i = 0; i < this->SheetList.size(); i++) + { + QTableWidgetItem* item1 = new QTableWidgetItem(QString(this->SheetList[i].toString().c_str())); + QTableWidgetItem* item2 = new QTableWidgetItem(QString("%1").arg(this->SheetList[i].asInt())); + table->setItem(i,1,item1); + table->setItem(i,2,item2); + } + +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h new file mode 100644 index 000000000..a63bd6b90 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/bin_reader.h @@ -0,0 +1,24 @@ +#include "nel/misc/types_nl.h" +#include +#include +#include +#include +#include +#include "nel/misc/path.h" +#include "nel/misc/sheet_id.h" +#include +#include "nel/misc/types_nl.h" + +using namespace std; +using namespace NLMISC; + +class BinReader +{ +public: + BinReader(QString dir); + int count(); + void pushToTable(QTableWidget*& table); + std::vector getVector() const; +private: + std::vector SheetList; +}; \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp new file mode 100644 index 000000000..8ea976369 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.cpp @@ -0,0 +1,47 @@ +#include "dialog.h" +#include "ui_dialog.h" +#include "bin_reader.h" + +#include "QMessageBox" +#include "QSettings" + +Dialog::Dialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog) +{ + ui->setupUi(this); + QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat); + dir = settings.value("PathToSheetId", "").toString(); + connect(ui->reloadButton,SIGNAL(clicked()),this,SLOT(reloadTable())); + connect(ui->browseButton,SIGNAL(clicked()),this,SLOT(getDir())); + +} + +Dialog::~Dialog() +{ + delete ui; +} +void Dialog::reloadTable() +{ + QFile file(dir + QString("./sheet_id.bin")); + if(file.exists() == true) + { + QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat); + settings.setValue("PathToSheetId", dir); + BinReader reader(this->dir); + reader.pushToTable(ui->table); + + } + else + { + QMessageBox errorBox; + errorBox.setText(QString("File sheet_id.bin doesn't exist in direcotry: \n") + this->dir); + errorBox.exec(); + } +} +void Dialog::getDir() +{ + QFileDialog fileDialog(this); + fileDialog.setFileMode(QFileDialog::DirectoryOnly); + this->dir = fileDialog.getExistingDirectory(); +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h new file mode 100644 index 000000000..6c33c3797 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.h @@ -0,0 +1,28 @@ +#ifndef DIALOG_H +#define DIALOG_H + +#include +#include + +namespace Ui +{ +class Dialog; +} + +class Dialog : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog(QWidget *parent = 0); + ~Dialog(); +public Q_SLOTS: + void reloadTable(); + void getDir(); + +private: + QString dir; + Ui::Dialog *ui; +}; + +#endif // DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.ui new file mode 100644 index 000000000..23e88c691 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/dialog.ui @@ -0,0 +1,80 @@ + + + Dialog + + + + 0 + 0 + 508 + 531 + + + + Dialog + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Browse + + + + + + + Display + + + + + + + Close + + + + + + + + + + + + endButton + clicked() + Dialog + reject() + + + 371 + 282 + + + 199 + 149 + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp new file mode 100644 index 000000000..7a45fc8cb --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.cpp @@ -0,0 +1,97 @@ +#include "disp_sheet_id_plugin.h" +#include "dialog.h" +#include +#include +#include +#include +#include +#include + +#include "../../extension_system/iplugin_spec.h" + +#include "nel/misc/debug.h" + +using namespace Plugin; + +bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +{ + Q_UNUSED(errorString); + _plugMan = pluginManager; + QMainWindow *wnd = qobject_cast(objectByName("CMainWindow")); + if (!wnd) + { + *errorString = tr("Not found QMainWindow Object Viewer Qt."); + return false; + } + return true; +} + +void MyPlugin::extensionsInitialized() +{ + QMenu *toolsMenu = qobject_cast(objectByName("ovqt.Menu.Tools")); + nlassert(toolsMenu); + + QAction *newAction = toolsMenu->addAction("Display sheet id"); + + connect(newAction, SIGNAL(triggered()), this, SLOT(execMessageBox())); +} + +void MyPlugin::execMessageBox() +{ + Dialog dialog; + dialog.show(); + dialog.exec(); +} + +void MyPlugin::setNelContext(NLMISC::INelContext *nelContext) +{ +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + _LibContext = new NLMISC::CLibraryContext(*nelContext); +} + +QString MyPlugin::name() const +{ + return "Display sheet id"; +} + +QString MyPlugin::version() const +{ + return "0.1"; +} + +QString MyPlugin::vendor() const +{ + return "pemeon"; +} + +QString MyPlugin::description() const +{ + return "Display sheet id"; +} + +QList MyPlugin::dependencies() const +{ + return QList(); +} + +QObject* MyPlugin::objectByName(const QString &name) const +{ + Q_FOREACH (QObject *qobj, _plugMan->allObjects()) + if (qobj->objectName() == name) + return qobj; + return 0; +} + +ExtensionSystem::IPluginSpec *MyPlugin::pluginByName(const QString &name) const +{ + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) + if (spec->name() == name) + return spec; + return 0; +} + +Q_EXPORT_PLUGIN(MyPlugin) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h new file mode 100644 index 000000000..4c9eb78a6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/disp_sheet_id/disp_sheet_id_plugin.h @@ -0,0 +1,56 @@ +#ifndef PLUGIN1_H +#define PLUGIN1_H + +#include "../../extension_system/iplugin.h" + +#include "nel/misc/app_context.h" + +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace NLQT +{ +class IPluginSpec; +} + +namespace Plugin +{ + +class MyPlugin : public QObject, public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) +public: + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + void extensionsInitialized(); + + void setNelContext(NLMISC::INelContext *nelContext); + + QString name() const; + QString version() const; + QString vendor() const; + QString description() const; + QList dependencies() const; + + QObject *objectByName(const QString &name) const; + ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; + +private Q_SLOTS: + void execMessageBox(); + +protected: + NLMISC::CLibraryContext *_LibContext; + +private: + ExtensionSystem::IPluginManager *_plugMan; + +}; + +} // namespace Plugin1 + +#endif // PLUGIN1_H