NDEVR
API Documentation
ReportIterator.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/SoftwareService.h>
4#include <NDEVR/WidgetIterator.h>
5#include <NDEVR/TranslatedString.h>
6#include <NDEVR/BaseValues.h>
7#include <NDEVR/UUID.h>
8#include <NDEVR/String.h>
9#include <NDEVR/JSONNode.h>
10#include <QSize>
11#include <QRect>
12class QWidget;
13class QMenu;
14namespace NDEVR
15{
16 class JSONNode;
17 class QTModelManager;
18 class File;
19 class Model;
23 struct NDEVR_API ReportTemplate
24 {
33 ReportTemplate(const StringView& id, File resource);
40 };
41
67
71 class NDEVR_API ReportHandler : public SoftwareService
72 {
73 public:
85 virtual ~ReportHandler() {};
90 const TranslatedString& name() const { return m_name; }
95 const TranslatedString& description() const { return m_description; }
100 const String& icon() const { return m_icon; }
108
113 virtual QMenu* popupOptions() const { return nullptr; }
118 virtual bool canHandle(UUID, QTModelManager*) const { return false; };
119
124 virtual QWidget* getReport(const UUID&, QTModelManager*, const QRect&) const { return nullptr; };
125
130 virtual void createReportJSON(const UUID&, JSONNode&, ReportJSONMaker&) const {};
131
136 virtual UUID id() const { return m_name.translationID(); }
141 virtual bool defaultEnabled() const { return m_default_enabled; }
142 protected:
146 bool m_default_enabled = true;
147 };
148
220
223 class NDEVR_API ReportManager : public SoftwareServiceManager
224 {
225 public:
230 static void RegisterReportHandler(const ReportHandler* handler);
236 protected:
238 };
239}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:149
A core class that represents a node on model hierarchy.
Definition Model.h:292
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Handles creating a report page from some given data.
const TranslatedString & description() const
Retrieves the description of this report handler.
virtual void createReportJSON(const UUID &, JSONNode &, ReportJSONMaker &) const
Creates JSON nodes containing report data for the given ID.
virtual bool defaultEnabled() const
Checks whether this report handler is enabled by default.
virtual UUID id() const
Retrieves the unique identifier for this report handler.
TranslatedString m_description
The description of this report handler.
virtual QMenu * popupOptions() const
Retrieves an optional popup menu with additional report options.
virtual Buffer< UUID > defaultReportIDs(const Buffer< UUID > &, QTModelManager *) const
Given a list of model objects, returns report IDs this handler requests to process.
TranslatedString m_name
The display name of this report handler.
const TranslatedString & name() const
Retrieves the display name of this report handler.
bool m_default_enabled
Whether this handler is enabled by default.
const String & icon() const
Retrieves the icon identifier for this report handler.
virtual bool canHandle(UUID, QTModelManager *) const
Checks whether this handler can generate a report for the given ID.
String m_icon
The icon identifier for this report handler.
virtual QWidget * getReport(const UUID &, QTModelManager *, const QRect &) const
Creates a report widget for the given ID within the specified bounds.
ReportHandler(const TranslatedString &name, const TranslatedString &description, const StringView &icon)
Constructs a report handler with the given display properties.
ReportIterator(const Buffer< const ReportHandler * > &reports, const Buffer< UUID > &objects_to_report, QTModelManager *manager)
Constructs a report iterator with specific handlers and objects.
const Buffer< const ReportHandler * > & reportHandlers()
Retrieves the current report handlers.
ReportIterator(QTModelManager *manager)
Constructs a report iterator using all registered report handlers.
JSONNode createJSONNode() const
Creates a JSON representation of the report data.
void setObjectsToReport(const Buffer< UUID > &objects_to_report)
Sets the objects to include in the report.
Buffer< const ReportHandler * > m_report_handlers
The report handlers used for generation.
void updateAvailableReports()
Updates the list of available reports based on current objects and handlers.
QWidget * getReport(uint04 report_index) const override
Generates a report widget for the given report index.
void sortIDs()
Sorts the report object IDs for consistent ordering.
Buffer< UUID > m_objects_to_report
UUIDs of objects to include in reports.
void setReportHandlers(const Buffer< const ReportHandler * > &handlers)
Sets the report handlers used for generating reports.
void saveReportMetaData(const File &file) const
Saves report metadata to a file.
QTModelManager * m_manager
The model manager providing data.
Buffer< std::pair< const ReportHandler *, UUID > > m_report_objects
Paired handler-object entries for report generation.
ReportIterator(const Buffer< const ReportHandler * > &reports, QTModelManager *manager)
Constructs a report iterator with specific report handlers.
virtual bool canHandle(UUID model_id, QTModelManager *)
Checks whether any handler can process a report for the given model.
Storage class for all ReportHandlers.
static Buffer< const ReportHandler * > s_report_handlers
All registered report handlers.
static void RegisterReportHandler(const ReportHandler *handler)
Registers a report handler for use in report generation.
static const Buffer< const ReportHandler * > & ReportHandlers()
Retrieves all registered report handlers.
Software Service Managers take a Software service to modify the behavior of the software.
Base interface for services that extend or modify software behavior through modules.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
WidgetIterator()
Constructs an empty WidgetIterator.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Creates a JSON data structure that can be used for generating a report in MSWord.
void setTemplate(const ReportTemplate &report_template, JSONNode &node)
Sets the report template data into a JSON node.
QTModelManager * manager
The model manager providing data for the report.
void addProjectUnits()
Adds project unit information to the JSON structure.
JSONNode & templateRoot()
Retrieves the template root node within the JSON structure.
JSONNode root
The root JSON node of the report data.
ReportJSONMaker(QTModelManager *manager)
Constructs a report JSON maker for the given model manager.
A simple Template for a report.
ReportTemplate(const StringView &id, File resource)
Constructs a report template from a file resource.
ReportTemplate(const StringView &id, const StringView &base_64)
Constructs a report template from base64-encoded data.
File file
File path to the template resource.
String base_64
Base64-encoded template data.
String id
Unique identifier for the report template.