Scope
ScannerVectorFrameBasic.cpp
1 #include "stdafx.h"
2 #include "ScannerVectorFrameBasic.h"
3 #include "ScannerVectorFrameSaw.h"
4 #include "ScannerVectorFrameBiDi.h"
5 #include "ScannerVectorFramePlaneHopper.h"
6 #include "ScannerVectorFrameResonanceBiDi.h"
7 #include "ScannerVectorFrameResonanceHopper.h"
8 
9 namespace scope {
10 
12  : type(_type)
13  , filltype(_filltype)
14  , daqparameters(nullptr)
15  , svparameters(parameters::ScannerVectorFrameBasic::Factory(_type).release())
16  , zparameters(nullptr)
17  , lookup_rotation(0) {
18  vecptr = std::make_shared<std::vector<int16_t>>(svparameters->TotalPixels() * 4); // for x, y, fast z, Pockels
19  lookup = std::make_shared<std::vector<std::size_t>>(svparameters->TotalPixels());
20  UpdateVector();
21 }
22 
24 
25 }
26 
27 std::unique_ptr<ScannerVectorFrameBasic> ScannerVectorFrameBasic::Factory(const ScannerVectorType& _type, const ScannerVectorFillType& _filltype) {
28  switch ( _type.t ) {
29  case ScannerVectorTypeHelper::Sawtooth:
30  return std::unique_ptr<ScannerVectorFrameBasic>(new ScannerVectorFrameSaw(_filltype));
31  case ScannerVectorTypeHelper::Bidirectional:
32  return std::unique_ptr<ScannerVectorFrameBasic>(new ScannerVectorFrameBiDi(_filltype));
33  case ScannerVectorTypeHelper::Planehopper:
34  return std::unique_ptr<ScannerVectorFrameBasic>(new ScannerVectorFramePlaneHopper(_filltype));
35  case ScannerVectorTypeHelper::ResonanceBiDi:
36  return std::unique_ptr<ScannerVectorFrameBasic>(new ScannerVectorFrameResonanceBiDi(_filltype));
37  case ScannerVectorTypeHelper::ResonanceHopper:
38  return std::unique_ptr<ScannerVectorFrameBasic>(new ScannerVectorFrameResonanceHopper(_filltype));
39 
40  }
41 }
42 
44 }
45 
46 void ScannerVectorFrameBasic::SetParameters(parameters::Daq* const _daqparameters, parameters::ScannerVectorFrameBasic* const _svparameters, parameters::SCOPE_FPUZCONTROL_T* const _zparameters) {
47  this->daqparameters = _daqparameters;
48  this->svparameters = _svparameters;
49  this->zparameters = _zparameters;
50  UpdateVector();
51 }
52 
53 void ScannerVectorFrameBasic::SetPockels(const double& _pockelsval) {
54  svparameters->pockels.Set(_pockelsval);
55  UpdateVector();
56 }
57 
58 void ScannerVectorFrameBasic::SetZoom(const double& _zoom) {
59  svparameters->zoom.Set(_zoom);
60  UpdateVector();
61 }
62 
63 /*
64 void ScannerVectorFrameBasic::SetFastZ(const double& _fastz) {
65  svparameters->fastz.Set(_fastz);
66  UpdateVector();
67 }
68 
69 */
70 void ScannerVectorFrameBasic::SetScannderdelay(const uint32_t& _scannerdelaysamples) {
71  const uint32_t newrot = _scannerdelaysamples - lookup_rotation; // how far do we have to rotate now (taking into account earlier rotation);
72  if ( newrot > 0 )
73  std::rotate(std::begin(*lookup), std::begin(*lookup)+newrot, std::end(*lookup));
74  if ( newrot < 0 )
75  std::rotate(std::begin(*lookup), std::end(*lookup)+newrot, std::end(*lookup));
76  lookup_rotation = _scannerdelaysamples;
77 }
78 
79 std::shared_ptr<const std::vector<int16_t>> ScannerVectorFrameBasic::GetInterleavedVector() const {
80  return vecptr;
81 }
82 
83 std::shared_ptr<const std::vector<std::size_t>> ScannerVectorFrameBasic::GetLookupVector() const {
84  return lookup;
85 }
86 
88  return svparameters;
89 }
90 
91 
92 
93 }
virtual T Set(const T &_v, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the value and calls both change signals if the value actually changed.
Definition: ScopeValue.h:67
ScopeNumber< double > pockels
pockels cell value
Definition: Framescan.h:163
virtual std::shared_ptr< const std::vector< int16_t > > GetInterleavedVector() const
Frame scanning with ETL plane hopping.
Calculates scanner, fast z, and pockels control voltages for a saw tooth frame scan.
virtual void UpdateVector()
Calculate the scanner vector based on the current parameters.
Parent class for frame scans.
virtual void SetPockels(const double &_pockelsval)
Set current pockels value and update.
ScannerVectorFrameBasic(const ScannerVectorType &_type, const ScannerVectorFillType &_filltype)
Initialize data vector.
All parameters for scanner data generation and pixel acquisition If you add/remove parameters or deri...
Definition: IO.h:747
virtual parameters::ScannerVectorFrameBasic * GetSVParameters() const
A scanner vector for bidirectional frame scanning.
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
This is the include file for standard system include files, or project specific include files that ar...
T::Mode t
the enum from the template class
virtual ~ScannerVectorFrameBasic()
We need a virtual destructor here, so that derived types get correctly destroyed. ...
parameters::ScannerVectorFrameBasic * svparameters
current scanner vector parameter set (needs to be pointer for dynamic_cast in derived classes and bec...
int32_t lookup_rotation
how much is the current lookup vector rotated to adjust for scannerdelay
std::shared_ptr< std::vector< std::size_t > > lookup
gives the position in the image vector for each position in the acquired data vector (keep in mind th...
static std::unique_ptr< ScannerVectorFrameBasic > Factory(const ScannerVectorType &_type, const ScannerVectorFillType &_filltype)
A static factory method for scan vectors.
virtual void SetZoom(const double &_zoom)
Set current zoom factor and update.
virtual std::shared_ptr< const std::vector< size_t > > GetLookupVector() const
parameters::Daq * daqparameters
current daq parameter set
virtual void SetParameters(parameters::Daq *const _daqparameters, parameters::ScannerVectorFrameBasic *const _svparameters, parameters::SCOPE_FPUZCONTROL_T *const _zparameters)
Set current parameters and update vector.
std::shared_ptr< std::vector< int16_t > > vecptr
the actual scanner vector (if fullframevector) with x, y, fast z, Pockels either interleaved (for ful...
Parameters for a ScannerVectorFrameBasic.
Definition: Framescan.h:45
ScopeNumber< double > zoom
current zoom factor (from 1 to 20).
Definition: Framescan.h:151
uint32_t TotalPixels() const override
Definition: Framescan.h:183
parameters::SCOPE_FPUZCONTROL_T * zparameters
current fast z parameter set
Calculates scanner, fast z, and pockels control voltages for a bidirectional frame scan with a resona...
virtual void SetScannderdelay(const uint32_t &_scannerdelaysamples)
Set the current position for the fast z control.