jhalkjar created page: DrawSetup_executable authored by Jesper Halkjær's avatar Jesper Halkjær
# What can this do? AUSADraw
This is a small utility tool to draw a AUSAlib setup file. ---------------
AUSADraw is a small framework to draw AUSA setups. It comes as a library and an [executable](https://git.kern.phys.au.dk/ausa/Drawer/wikis/home). The executable can handle most situation, but if you want to use it in your own projects you can use the library.
In the current state you need to be on the povray-branch in AUSAlib. Just give the defaults...
----------------------
This will read in a setup from json and produce 1280x960 test.png.
The camera viewpoint will be from (650, 500, 600)mm.
So far we can draw W1, S3 and a somewhat adapted version of a (BB7) 32x32 DSSD. ```c++
#include "ausa/json/IO.h"
#include "ausa/povray/SetupRender.h"
using namespace AUSA;
It is also possible to get the coordinate axes drawn. int main() {
auto s = JSON::readSetupFromJSON("setup/setup.json");
# Syntax Povray::render(*s, "test.png", {650, 500, 600}, 1280, 960);
``DrawSetup [-options] [setup.json]`` }
```
# Options: With the IFA002 setup this will output:
| Option | Name | Example | ![test](https://git.kern.phys.au.dk/ausa/ausalib/uploads/2d9b2c691e3e7ee6b2f7f77b0bf48f6c/test.png)
| :-- | :--- | :------------ |
| c | Camera position | ``-c '(100, 500, 0)'`` |
| l | Camera look | ``-l '(0,0,10)'`` |
| z | Zoom level | ``-z 7`` |
| o | Output file | ``-o myimage.png`` |
| a | Draw axes | ``-a``|
| t | Draws a target | ``-t target.json``|
| d | Disable double sided detectors | ``-d``|
| s | Disable single sided detectors | ``-s``|
The grid is drawn on the front side of the detector.
Notice that this will mark pixel (1,1) of the W1 and spoke 1 of the S3 red.
# Example
``DrawSetup -a -l '(0,0,0)' myNewAwesomeSetupImage.png`` Detailed example
\ No newline at end of file ----------------------
Below is shown an example, where `SetupRender` object is created an several of its properties modified.
Please refer to the [docs](http://docs.kern.phys.au.dk/classAUSA_1_1Povray_1_1SetupRender.html) for complete list.
Please note that distance are specified in mm.
```c++
#include "ausa/json/IO.h"
#include "ausa/povray/SetupRender.h"
using namespace AUSA;
int main() {
auto s = JSON::readSetupFromJSON("setup/setup.json");
Povray::SetupRender render; // Create render object
render.setCamera(TVector3(0, 500, 0)); // Camera location
render.setLook(TVector3(0,0,10)); // Camera focus point
render.setZoom(3); // Camera zoom level
render.setDebug(true); // Output debug markers
render.setRenderSingle(false); // Do _not_ render SingleSided Detectors.
render.renderImage(*s, "test.png"); // Render the image
toFile(render.render(*s), "test.pov"); // Save pov file.
}
```
![test](https://git.kern.phys.au.dk/ausa/ausalib/uploads/e3d9b8a68514c2f215dcba0a57e671fc/test.png)
Drawing targets
----------------------
It is possible to draw a Target. So far it only supports box-targets. Whenever AUSAlib support other geometries it will be updated here too. In order to add a Target, you simply add it to the renderer:
```c++
Povray::SetupRender render;
Target target;
...
render.setTarget(make_shared<Target>(target));
```
What if my detector is not supported?
--------------------------------------
Fear not. That is fixable.
Simple - I'm never going to draw this again solution: Just add to the pov file.
However if you have added your own Detector class or a render is missing for an AUSAlib one then you need to
1. Subclass the virtual class [DetectorRender](include/ausa/povray/DetectorRender.h).
Have a look at [W1Render.h](include/ausa/povray/renders/W1Render.h) and [W1Render.cpp](source/povray/renders/W1Render.cpp)
Let us say I have defined `FooRender` for `FooDetector`.
2. Register render
```c++
Povray::SetupRender r;
r.registerRender<FooDetector>(std::make_unique<FooRender>());
```
Now this `SetupRender` will use `FooRender` for all detectors of type `FooDetector` but not any other.
The SetupRender registers both the `S3Render` and `W1Render` so have a look at the if your are in doubt.
\ No newline at end of file