| 87 | //------------------------------------------------------------------------------ |
| 88 | |
| 89 | static std::unique_ptr<ScaleFactor> createScaleFactor(const Options& options) |
| 90 | { |
| 91 | std::unique_ptr<ScaleFactor> scale_factor; |
| 92 | |
| 93 | if (options.hasSamplesPerPixel() && options.hasEndTime()) { |
| 94 | throwError("Specify either --end or --zoom but not both"); |
| 95 | } |
| 96 | else if (options.hasPixelsPerSecond() && options.hasEndTime()) { |
| 97 | throwError("Specify either --end or --pixels-per-second but not both"); |
| 98 | } |
| 99 | else if (options.hasSamplesPerPixel() && options.hasPixelsPerSecond()) { |
| 100 | throwError("Specify either --zoom or --pixels-per-second but not both"); |
| 101 | } |
| 102 | else if (options.hasEndTime()) { |
| 103 | scale_factor.reset(new DurationScaleFactor( |
| 104 | options.getStartTime(), |
| 105 | options.getEndTime(), |
| 106 | options.getImageWidth() |
| 107 | )); |
| 108 | } |
| 109 | else if (options.hasPixelsPerSecond()) { |
| 110 | scale_factor.reset( |
| 111 | new PixelsPerSecondScaleFactor(options.getPixelsPerSecond()) |
| 112 | ); |
| 113 | } |
| 114 | else { |
| 115 | scale_factor.reset( |
| 116 | new SamplesPerPixelScaleFactor(options.getSamplesPerPixel()) |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | return scale_factor; |
| 121 | } |
| 122 | |
| 123 | //------------------------------------------------------------------------------ |
| 124 |
no test coverage detected