12#include "../../MetaInstruments/Camera.h"
13#include "../../MetaInstruments/AnalogOut.h"
14#include "../../Instruments/InterModuleCommunicator.h"
19#include "ui_ImageViewer.h"
45 bool AllowResize() const noexcept override final {
return true; }
47 void SetImage(
const QImage& NewImage)
noexcept;
59 bool eventFilter(QObject* obj, QEvent* event)
override;
60 virtual void resizeEvent(QResizeEvent* event)
override;
133 void ResetImpl(dispatch_tag<QModuleDataBase>)
override final;
145 virtual const char*
GetParamClassTag() const noexcept
override {
return "ImageViewerParams"; }
152 "Specifies how fine the focus is scanned during the autofocus algorithm. Higher values lead to higher precision and longer execution times.",
153 false, 10, 3, 10000, 10, 0};
155 "Focus change time (ms)",
"Time it takes to change the focus after applying a new focus voltage.",
156 false, 500, 0, 10000, 10, 0 };
158 "InterModuleCommunicator",
"Inter-module communicator",
"Inter-module communicator to control this module with",
DynExpUI::Icons::Instrument,
true };
184 constexpr static auto Name() noexcept {
return "Image Viewer"; }
185 constexpr static auto Category() noexcept {
return "Image Capturing"; }
194 std::chrono::milliseconds
GetMainLoopDelay() const override final {
return std::chrono::milliseconds(16); }
202 void ResetImpl(dispatch_tag<QModuleBase>)
override final;
204 std::unique_ptr<DynExp::QModuleWidget>
MakeUIWidget() override final;
219 std::chrono::milliseconds WaitTimeBeforeCapture{};
221 constexpr auto GetVoltageDiff() const noexcept {
return MaxVoltage - MinVoltage; }
222 constexpr auto GetVoltageIncrement(
bool Fine =
false) const noexcept {
return GetVoltageDiff() / NumSteps / (Fine ? NumSteps : 1); }
Defines DynExp's core module as an interface between the UI and DynExp objects.
Events for inter-module communication handled by the DynExpModule::ImageViewer::ImageViewer module.
CapturingStateType
Type indicating whether the camera is currently capturing images.
@ Stopped
The camera is not capturing.
std::chrono::milliseconds TimeType
Time type describing the camera's times like its exposure time.
std::vector< std::string > CameraModesType
List type containing strings of modes the camera can operate in.
ComputeHistogramType
Type indicating whether histograms should be computed for newly captured images.
@ NoHistogram
Histogram computation is disabled.
SampleT SampleType
Alias for SampleT.
virtual ~ImageViewerConfigurator()=default
virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core) const override final
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
ImageViewerConfigurator()=default
Util::ImageRGBHistogramType RGBHistogram
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
bool ImageCapturingPaused
DynExp::LinkedObjectWrapperContainer< DynExpInstr::InterModuleCommunicator > Communicator
double CalcBrennerGradientFromImage() const
Calculates the Brenner gradient of CurrentImage. Refer to J. F. Brenner et al. J. Histochem....
DynExpInstr::CameraData::TimeType TimeType
DynExpInstr::CameraData::CameraModesType CameraModes
virtual ~ImageViewerData()=default
DynExpInstr::CameraData::ComputeHistogramType ComputeHistogram
DynExpInstr::CameraData::CapturingStateType CapturingState
DynExp::LinkedObjectWrapperContainer< DynExpInstr::Camera > Camera
TimeType CurrentExposureTime
Util::ImageHistogramType IntensityHistogram
DynExp::LinkedObjectWrapperContainer< DynExpInstr::AnalogOut > Focus
virtual void ResetImpl(dispatch_tag< ImageViewerData >)
Param< ParamsConfigDialog::NumberType > AutofocusNumSteps
Param< DynExp::ObjectLink< DynExpInstr::Camera > > Camera
Param< DynExp::ObjectLink< DynExpInstr::InterModuleCommunicator > > Communicator
virtual ~ImageViewerParams()=default
virtual const char * GetParamClassTag() const noexcept override
This function is intended to be overridden once in each derived class returning the name of the respe...
Param< DynExp::ObjectLink< DynExpInstr::AnalogOut > > Focus
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) override final
Param< ParamsConfigDialog::NumberType > AutofocusFocusChangeTime
ImageViewerParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
static constexpr auto AutofocusGotoSampleState
StateType AutofocusStepStateFunc(DynExp::ModuleInstance &Instance)
StateType AutofocusInitStateFunc(DynExp::ModuleInstance &Instance)
void FinishAutofocus(Util::SynchronizedPointer< ModuleDataType > &ModuleData, const FinishedAutofocusEvent &Event) const
static constexpr auto AutofocusFinishedState
void OnResumeImageCapturing(DynExp::ModuleInstance *Instance) const
void OnAutofocus(DynExp::ModuleInstance *Instance, bool ResetImageTransformation=false) const
StateType AutofocusFinishedStateFunc(DynExp::ModuleInstance &Instance)
void OnCaptureSingle(DynExp::ModuleInstance *Instance, bool) const
ImageViewerData ModuleDataType
std::unique_ptr< DynExp::QModuleWidget > MakeUIWidget() override final
Used by InitUI() as a factory function for the module's user interface widget. Create the widget here...
void OnInit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread starts. Override it to lock instruments this m...
Util::DynExpErrorCodes::DynExpErrorCodes ModuleMainLoop(DynExp::ModuleInstance &Instance) override final
Module main loop. The function is executed periodically by the module thread. Also refer to GetMainLo...
void OnCaptureContinuously(DynExp::ModuleInstance *Instance, bool Checked) const
virtual std::string GetCategory() const override
Returns the category of this Object type.
bool IsAutofocusingState() const
AutofocusParamsType AutofocusParams
static constexpr auto AutofocusInitState
virtual std::string GetName() const override
Returns the name of this Object type.
StateType ReadyStateFunc(DynExp::ModuleInstance &Instance)
StateType AutofocusGotoSampleStateFunc(DynExp::ModuleInstance &Instance)
void OnExposureTimeChanged(DynExp::ModuleInstance *Instance, int Value) const
static constexpr auto AutofocusStepState
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
StateType AutofocusWaitForImageStateFunc(DynExp::ModuleInstance &Instance)
std::vector< AutofocusSampleType >::iterator AutofocusCurrentSample
static constexpr auto AutofocusWaitForImageState
std::vector< AutofocusSampleType > AutofocusSamples
StateType AutofocusWaitBeforeCaptureStateFunc(DynExp::ModuleInstance &Instance)
bool IsReadyState() const
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
bool AutofocusIsPerformingFineSweep
void OnAutofocusClicked(DynExp::ModuleInstance *Instance, bool Checked) const
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
AutofocusResultsType AutofocusResults
const std::shared_ptr< std::atomic< bool > > PauseUpdatingUI
static constexpr auto ReadyState
Util::StateMachine< StateMachineStateType > StateMachine
static constexpr auto AutofocusWaitBeforeCaptureState
size_t NumFailedUpdateAttempts
void ResetImpl(dispatch_tag< QModuleBase >) override final
void OnCameraModeChanged(DynExp::ModuleInstance *Instance, int Index) const
void OnSaveImage(DynExp::ModuleInstance *Instance, QString Filename) const
std::chrono::system_clock::time_point AutofocusWaitingEndTimePoint
static constexpr auto Name() noexcept
static constexpr auto Category() noexcept
void OnPauseImageCapturing(DynExp::ModuleInstance *Instance, bool ResetImageTransformation=false) const
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
This class holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Util::CallableMemberWrapper< ModuleBase, ModuleDataTypeSyncPtrType(ModuleBase::*)(const std::chrono::milliseconds)> ModuleDataGetterType
Invoking an instance of this alias is supposed to call ModuleBase::GetModuleData() of the instance th...
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Refer to ParamsBase::dispatch_tag.
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
const DynExpCore & Core
Reference to DynExp's core.
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Base class for modules with a Qt-based user interface. Derive from this class to implement modules wi...
Configurator class for QModuleBase.
Data class for QModuleBase.
Parameter class for QModuleBase.
QModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a QModuleBase instance.
double NumberType
Number type used for numeric parameters (DynExp::ParamsBase::Param)
Implements a QGraphicsView the user can interact with to insert graphical markers....
State machine state as used by class StateMachine. A state mainly wraps a state function of the membe...
This class models a state machine. It keeps track of the current state and allows to invoke its assoc...
@ AutofocusWaitBeforeCapture
constexpr auto Instrument
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
size_t ItemIDType
ID type of objects/items managed by DynExp.
DynExpErrorCodes
DynExp's error codes
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
std::array< unsigned long long, 256 > ImageHistogramType
Alias which represents a histogram as a std::array with 256 numeric bins. The lowest (highest) index ...
std::tuple< ImageHistogramType, ImageHistogramType, ImageHistogramType > ImageRGBHistogramType
Alias which represents a RGB histogram as a std::tuple of three ImageHistogramType elements....
Accumulates include statements to provide a precompiled header.
constexpr auto GetVoltageDiff() const noexcept
constexpr auto GetVoltageIncrement(bool Fine=false) const noexcept