vogleditor_qtextureviewer.cpp
vogleditor_qtimelineview.cpp
vogleditor_qtrimdialog.cpp
+ vogleditor_settings.cpp
vogleditor_statetreearbprogramitem.cpp
vogleditor_statetreearbprogramenvitem.cpp
vogleditor_statetreebufferitem.cpp
vogleditor_apicalltreeitem.h
vogleditor_frameitem.h
vogleditor_gl_state_snapshot.h
+ vogleditor_settings.h
vogleditor_snapshotitem.h
vogleditor_statetreearbprogramitem.h
vogleditor_statetreearbprogramenvitem.h
#include "vogl_trace_file_reader.h"
#include "vogl_trace_file_writer.h"
#include "vogleditor_qstatetreemodel.h"
+#include "vogleditor_settings.h"
#include "vogleditor_statetreetextureitem.h"
#include "vogleditor_statetreeprogramitem.h"
#include "vogleditor_statetreeshaderitem.h"
//----------------------------------------------------------------------------------------------------------------------
static void *g_actual_libgl_module_handle;
static QString g_PROJECT_NAME = "Vogl Editor";
+static vogleditor_settings g_settings;
+static const char* g_SETTINGS_FILE = "./vogleditor_settings.json";
//----------------------------------------------------------------------------------------------------------------------
// vogl_get_proc_address_helper
vogl_init_actual_gl_entrypoints(vogl_get_proc_address_helper);
}
+ // load the settings file. This will only succeed if the file already exists
+ g_settings.load(g_SETTINGS_FILE);
+
+ // always save/resave the file wiill either be created or so that new settings will be added
+ g_settings.save(g_SETTINGS_FILE);
+
+ this->move(g_settings.window_position_left(), g_settings.window_position_top());
+ this->resize(g_settings.window_size_width(), g_settings.window_size_height());
+
m_pStatusLabel = new QLabel(ui->statusBar);
m_pStatusLabel->setBaseSize(150, 12);
ui->statusBar->addWidget(m_pStatusLabel, 1);
VoglEditor::~VoglEditor()
{
- close_trace_file();
- delete ui;
+ // update any settings and save the settings file
+ g_settings.set_window_position_left(this->x());
+ g_settings.set_window_position_top(this->y());
+ g_settings.set_window_size_width(this->width());
+ g_settings.set_window_size_height(this->height());
+ g_settings.save(g_SETTINGS_FILE);
- if (m_pStatusLabel != NULL)
- {
- delete m_pStatusLabel;
- m_pStatusLabel = NULL;
- }
+ close_trace_file();
+ delete ui;
- if (m_pFramebufferExplorer != NULL)
- {
- delete m_pFramebufferExplorer;
- m_pFramebufferExplorer = NULL;
- }
+ if (m_pStatusLabel != NULL)
+ {
+ delete m_pStatusLabel;
+ m_pStatusLabel = NULL;
+ }
- if (m_pTextureExplorer != NULL)
- {
- delete m_pTextureExplorer;
- m_pTextureExplorer = NULL;
- }
+ if (m_pFramebufferExplorer != NULL)
+ {
+ delete m_pFramebufferExplorer;
+ m_pFramebufferExplorer = NULL;
+ }
- if (m_pRenderbufferExplorer != NULL)
- {
- delete m_pRenderbufferExplorer;
- m_pRenderbufferExplorer = NULL;
- }
+ if (m_pTextureExplorer != NULL)
+ {
+ delete m_pTextureExplorer;
+ m_pTextureExplorer = NULL;
+ }
- if (m_pProgramExplorer != NULL)
- {
- delete m_pProgramExplorer;
- m_pProgramExplorer = NULL;
- }
+ if (m_pRenderbufferExplorer != NULL)
+ {
+ delete m_pRenderbufferExplorer;
+ m_pRenderbufferExplorer = NULL;
+ }
- if (m_pShaderExplorer != NULL)
- {
- delete m_pShaderExplorer;
- m_pShaderExplorer = NULL;
- }
+ if (m_pProgramExplorer != NULL)
+ {
+ delete m_pProgramExplorer;
+ m_pProgramExplorer = NULL;
+ }
- if (m_pPlayButton != NULL)
- {
- delete m_pPlayButton;
- m_pPlayButton = NULL;
- }
+ if (m_pShaderExplorer != NULL)
+ {
+ delete m_pShaderExplorer;
+ m_pShaderExplorer = NULL;
+ }
- if (m_pTrimButton != NULL)
- {
- delete m_pTrimButton;
- m_pTrimButton = NULL;
- }
+ if (m_pPlayButton != NULL)
+ {
+ delete m_pPlayButton;
+ m_pPlayButton = NULL;
+ }
- if (m_pFramebufferTab_layout != NULL)
- {
- delete m_pFramebufferTab_layout;
- m_pFramebufferTab_layout = NULL;
- }
+ if (m_pTrimButton != NULL)
+ {
+ delete m_pTrimButton;
+ m_pTrimButton = NULL;
+ }
- if (m_pTextureTab_layout != NULL)
- {
- delete m_pTextureTab_layout;
- m_pTextureTab_layout = NULL;
- }
+ if (m_pFramebufferTab_layout != NULL)
+ {
+ delete m_pFramebufferTab_layout;
+ m_pFramebufferTab_layout = NULL;
+ }
- if (m_pRenderbufferTab_layout != NULL)
- {
- delete m_pRenderbufferTab_layout;
- m_pRenderbufferTab_layout = NULL;
- }
+ if (m_pTextureTab_layout != NULL)
+ {
+ delete m_pTextureTab_layout;
+ m_pTextureTab_layout = NULL;
+ }
- if (m_pProgramTab_layout != NULL)
- {
- delete m_pProgramTab_layout;
- m_pProgramTab_layout = NULL;
- }
+ if (m_pRenderbufferTab_layout != NULL)
+ {
+ delete m_pRenderbufferTab_layout;
+ m_pRenderbufferTab_layout = NULL;
+ }
- if (m_pShaderTab_layout != NULL)
- {
- delete m_pShaderTab_layout;
- m_pShaderTab_layout = NULL;
- }
+ if (m_pProgramTab_layout != NULL)
+ {
+ delete m_pProgramTab_layout;
+ m_pProgramTab_layout = NULL;
+ }
- if (m_pStateTreeModel != NULL)
- {
- delete m_pStateTreeModel;
- m_pStateTreeModel = NULL;
- }
+ if (m_pShaderTab_layout != NULL)
+ {
+ delete m_pShaderTab_layout;
+ m_pShaderTab_layout = NULL;
+ }
- if (m_pVoglReplayProcess != NULL)
- {
- delete m_pVoglReplayProcess;
- m_pVoglReplayProcess = NULL;
- }
+ if (m_pStateTreeModel != NULL)
+ {
+ delete m_pStateTreeModel;
+ m_pStateTreeModel = NULL;
+ }
+
+ if (m_pVoglReplayProcess != NULL)
+ {
+ delete m_pVoglReplayProcess;
+ m_pVoglReplayProcess = NULL;
+ }
}
void VoglEditor::playCurrentTraceFile()
void VoglEditor::trimCurrentTraceFile()
{
- trim_trace_file(m_openFilename, static_cast<uint>(m_pTraceReader->get_max_frame_index()), 200);
+ trim_trace_file(m_openFilename, static_cast<uint>(m_pTraceReader->get_max_frame_index()), g_settings.trim_large_trace_prompt_size());
}
/// \return True if the new trim file is now open in the editor
m_pStatusLabel->clear();
}
- if (tmpReader->get_max_frame_index() > 200)
+ if (tmpReader->get_max_frame_index() > g_settings.trim_large_trace_prompt_size())
{
int ret = QMessageBox::warning(this, tr(g_PROJECT_NAME.toStdString().c_str()), tr("The loaded trace file has many frames and debugging may be difficult.\nWould you like to trim the trace?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (ret == QMessageBox::Yes)
{
- if (trim_trace_file(filename.c_str(), static_cast<uint>(tmpReader->get_max_frame_index()), 200))
+ if (trim_trace_file(filename.c_str(), static_cast<uint>(tmpReader->get_max_frame_index()), g_settings.trim_large_trace_prompt_size()))
{
// user decided to open the new trim file, and the UI should already be updated
// clean up here and return
{
gl_entrypoint_id_t entrypointId = static_cast<gl_entrypoint_id_t>(pItem->apiCallItem()->getGLPacket()->m_entrypoint_id);
if (vogl_is_draw_entrypoint(entrypointId) ||
- vogl_is_clear_entrypoint(entrypointId))
+ vogl_is_clear_entrypoint(entrypointId) ||
+ (entrypointId == VOGL_ENTRYPOINT_glBitmap) ||
+ (entrypointId == VOGL_ENTRYPOINT_glEnd))
{
pFound = iter.peekPrevious();
break;
{
gl_entrypoint_id_t entrypointId = static_cast<gl_entrypoint_id_t>(pItem->apiCallItem()->getGLPacket()->m_entrypoint_id);
if (vogl_is_draw_entrypoint(entrypointId) ||
- vogl_is_clear_entrypoint(entrypointId))
+ vogl_is_clear_entrypoint(entrypointId) ||
+ (entrypointId == VOGL_ENTRYPOINT_glBitmap) ||
+ (entrypointId == VOGL_ENTRYPOINT_glEnd))
{
pFound = iter.peekNext();
break;
#include "vogleditor_qtrimdialog.h"
#include "ui_vogleditor_qtrimdialog.h"
#include <QFileDialog>
+#include <QMessageBox>
vogleditor_QTrimDialog::vogleditor_QTrimDialog(QString parentTraceFile, uint maxFrameIndex, uint maxTrimLength, QWidget *parent) :
QDialog(parent),
delete ui;
}
-void vogleditor_QTrimDialog::on_buttonBox_accepted()
+void vogleditor_QTrimDialog::on_buttonBox_clicked(QAbstractButton *button)
{
- // verify all input
- bool bValidFrame = false;
- uint tmpFrame = ui->trimFrameLineEdit->text().toUInt(&bValidFrame);
- bValidFrame = bValidFrame && (tmpFrame <= m_maxFrameIndex);
+ if (button == ui->buttonBox->button(QDialogButtonBox::Ok))
+ {
+ // validate the trim start frame
+ bool bValidFrame = false;
+ uint tmpFrame = ui->trimFrameLineEdit->text().toUInt(&bValidFrame);
+ bValidFrame = bValidFrame && (tmpFrame <= m_maxFrameIndex);
- bool bValidLen = false;
- uint tmpLen = ui->trimLenLineEdit->text().toUInt(&bValidLen);
- bValidLen = bValidLen && (tmpLen > 0 && tmpLen < m_maxTrimLength);
+ if (!bValidFrame)
+ {
+ QMessageBox::warning(this, tr("Invalid Trim Frame"), tr("Please enter a valid frame number at which to start the trim."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ ui->trimFrameLineEdit->setFocus();
+ return;
+ }
- bool bValidFile = (ui->trimFrameLineEdit->text().isEmpty() == false);
+ // validate the trim length
+ bool bValidLen = false;
+ uint tmpLen = ui->trimLenLineEdit->text().toUInt(&bValidLen);
+ bValidLen = bValidLen && (tmpLen > 0 && tmpLen <= m_maxTrimLength);
+
+ if (!bValidLen)
+ {
+ QMessageBox::warning(this, tr("Invalid Trim Count"), tr("Please enter a valid nubmer of frames to trim."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ ui->trimLenLineEdit->setFocus();
+ return;
+ }
+
+ // validate the filename
+ QFile file(ui->trimFileLineEdit->text());
+ if (file.exists())
+ {
+ QString message = ui->trimFileLineEdit->text();
+ message += " already exits.\nWould you like to overwrite it?";
+ int ret = QMessageBox::warning(this, tr("File Already Exists"), tr(message.toStdString().c_str()),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+ if (ret == QMessageBox::No)
+ {
+ // return so that the user can update the path
+ ui->trimFileLineEdit->setFocus();
+ return;
+ }
+ }
- if (bValidFrame && bValidLen && bValidFile)
- {
m_trim_frame = ui->trimFrameLineEdit->text();
m_trim_len = ui->trimLenLineEdit->text();
m_trim_file = ui->trimFileLineEdit->text();
#include <QDialog>
#include <QString>
+class QAbstractButton;
+
namespace Ui {
class vogleditor_QTrimDialog;
}
}
private slots:
- void on_buttonBox_accepted();
+ void on_buttonBox_clicked(QAbstractButton *button);
void on_buttonBox_rejected();
<item>
<widget class="QLabel" name="label_2">
<property name="text">
- <string>trim_frame:</string>
+ <string>trim_frame</string>
</property>
</widget>
</item>
</widget>
<resources/>
<connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>vogleditor_QTrimDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
--- /dev/null
+#include "vogleditor_settings.h"
+#include "vogl_common.h"
+#include "vogl_file_utils.h"
+
+static const unsigned int VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION_1 = 1;
+static const unsigned int VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION = VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION_1;
+
+vogleditor_settings::vogleditor_settings()
+ : m_file_format_version(VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION_1)
+{
+ m_defaults.trim_large_trace_prompt_size = 200;
+ m_defaults.window_position_left = 0;
+ m_defaults.window_position_top = 0;
+ m_defaults.window_size_width = 1024;
+ m_defaults.window_size_height = 768;
+
+ m_settings = m_defaults;
+}
+
+dynamic_string vogleditor_settings::get_settings_path(const char* settingsFilename)
+{
+ dynamic_string settingsPath;
+ const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
+ const char* home = getenv("HOME");
+ if (xdgConfigHome != NULL && strlen(xdgConfigHome) != 0)
+ {
+ settingsPath = xdgConfigHome;
+ settingsPath += "/vogleditor/";
+ if (vogl::file_utils::does_dir_exist(settingsPath.c_str()) == false)
+ {
+ if (vogl::file_utils::create_directories_from_full_path(settingsPath) == false)
+ {
+ VOGL_ASSERT(!"Failed to create directories for settings file.");
+ }
+ }
+ }
+ else if (home != NULL && strlen(home) != 0)
+ {
+ settingsPath += home;
+ settingsPath += "/.config/vogleditor/";
+ if (vogl::file_utils::does_dir_exist(settingsPath.c_str())== false)
+ {
+ if (vogl::file_utils::create_directories_from_full_path(settingsPath) == false)
+ {
+ VOGL_ASSERT(!"Failed to create directories for settings file.");
+ }
+ }
+ }
+ else
+ {
+ // the settings file will end up in the current working directory
+ }
+
+ settingsPath += settingsFilename;
+ return settingsPath;
+}
+
+bool vogleditor_settings::load(const char* settingsFile)
+{
+ bool bLoaded = false;
+ json_document settingsDoc;
+ dynamic_string path = get_settings_path(settingsFile);
+ if (settingsDoc.deserialize_file(path.c_str()))
+ {
+ // validate metadata
+ json_node* pMetadata = settingsDoc.get_root()->find_child_object("metadata");
+ if (pMetadata == NULL)
+ {
+ return false;
+ }
+
+ const json_value& rFormatVersion = pMetadata->find_value("vogleditor_settings_file_format_version");
+ if (!rFormatVersion.is_valid() || rFormatVersion.as_uint32() != VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION_1)
+ {
+ return false;
+ }
+
+ m_file_format_version = rFormatVersion.as_uint32(VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION);
+
+ // validate that settings node exists
+ json_node* pSettingsNode = settingsDoc.get_root()->find_child_object("settings");
+ if (pSettingsNode == NULL)
+ {
+ return false;
+ }
+
+ // if so, consider the file successfully loaded
+ bLoaded = true;
+
+ // all settings should be considered optional, if they are not in the file, then the default value is used
+ m_settings.trim_large_trace_prompt_size = pSettingsNode->value_as_uint32("trim_large_trace_prompt_size", m_defaults.trim_large_trace_prompt_size);
+
+ m_settings.window_position_left = pSettingsNode->value_as_int("window_position_left", m_defaults.window_position_left);
+ m_settings.window_position_top = pSettingsNode->value_as_int("window_position_top", m_defaults.window_position_top);
+ m_settings.window_size_width = pSettingsNode->value_as_int("window_size_width", m_defaults.window_size_width);
+ m_settings.window_size_height = pSettingsNode->value_as_int("window_size_height", m_defaults.window_size_height);
+ }
+
+ return bLoaded;
+}
+
+bool vogleditor_settings::save(const char* settingsFile)
+{
+ json_document settingsDoc;
+ json_node& metadata = settingsDoc.get_root()->add_object("metadata");
+ metadata.add_key_value("vogleditor_settings_file_format_version", to_hex_string(VOGLEDITOR_SETTINGS_FILE_FORMAT_VERSION));
+
+ // settings
+ json_node& settings = settingsDoc.get_root()->add_object("settings");
+ settings.add_key_value("trim_large_trace_prompt_size", m_settings.trim_large_trace_prompt_size);
+
+ settings.add_key_value("window_position_left", m_settings.window_position_left);
+ settings.add_key_value("window_position_top", m_settings.window_position_top);
+ settings.add_key_value("window_size_width", m_settings.window_size_width);
+ settings.add_key_value("window_size_height", m_settings.window_size_height);
+
+ dynamic_string path = get_settings_path(settingsFile);
+ bool bSavedSuccessfully = settingsDoc.serialize_to_file(path.c_str());
+ return bSavedSuccessfully;
+}
--- /dev/null
+#ifndef VOGLEDITOR_SETTINGS_H
+#define VOGLEDITOR_SETTINGS_H
+
+#include "vogl_dynamic_string.h"
+
+struct vogleditor_setting_struct
+{
+ int window_position_left;
+ int window_position_top;
+ int window_size_width;
+ int window_size_height;
+ unsigned int trim_large_trace_prompt_size;
+};
+
+class vogleditor_settings
+{
+public:
+ vogleditor_settings();
+ virtual ~vogleditor_settings() {}
+
+ bool load(const char* settingsFile);
+ bool save(const char* settingsFile);
+
+ int window_position_left() { return m_settings.window_position_left; }
+ int window_position_top() { return m_settings.window_position_top; }
+ int window_size_width() { return m_settings.window_size_width; }
+ int window_size_height() { return m_settings.window_size_height; }
+ void set_window_position_left(int window_position_left) { m_settings.window_position_left = window_position_left; }
+ void set_window_position_top(int window_position_top) { m_settings.window_position_top = window_position_top; }
+ void set_window_size_width(int window_size_width) { m_settings.window_size_width = window_size_width; }
+ void set_window_size_height(int window_size_height) { m_settings.window_size_height = window_size_height; }
+
+ unsigned int trim_large_trace_prompt_size() { return m_settings.trim_large_trace_prompt_size; }
+ void set_trim_large_trace_prompt_size(unsigned int trim_large_trace_prompt_size) { m_settings.trim_large_trace_prompt_size = trim_large_trace_prompt_size; }
+
+private:
+ unsigned int m_file_format_version;
+ vogleditor_setting_struct m_settings;
+ vogleditor_setting_struct m_defaults;
+
+ vogl::dynamic_string get_settings_path(const char* settingsFilename);
+};
+
+#endif // VOGLEDITOR_SETTINGS_H