Commit bff9d5aea9ffcede0ad18269dcf8d8a1f228bc1c
1 parent
5f0cf293
Exact pixelation in GlScope and documentation updates
Showing
13 changed files
with
182 additions
and
84 deletions
openhantek/ChangeLog
| ... | ... | @@ -136,3 +136,10 @@ |
| 136 | 136 | |
| 137 | 137 | 2011-12-02 Oliver Haag <oliver.haag@gmail.com> |
| 138 | 138 | * Moved values needed to control gain into lists, initialized in connectDevice |
| 139 | + | |
| 140 | +2012-07-08 Oliver Haag <oliver.haag@gmail.com> | |
| 141 | +* Exact pixelation in GlScope and LevelSlider | |
| 142 | + | |
| 143 | +2012-09-01 Oliver Haag <oliver.haag@gmail.com> | |
| 144 | +* Updated documentation with first DSO-2250 details | |
| 145 | +* General documentation improvements | ... | ... |
openhantek/mainpage.dox
| ... | ... | @@ -50,7 +50,7 @@ After building it, you can just run the fwget.sh script inside the openhantek-ex |
| 50 | 50 | </pre> |
| 51 | 51 | You can also do it manually by placing the DSO*1.SYS file into the same directory and running the built binary: |
| 52 | 52 | <pre> |
| 53 | - $ ./openhantek-extractfw <driver file> | |
| 53 | + $ ./openhantek-extractfw <driver file> | |
| 54 | 54 | </pre> |
| 55 | 55 | This should create two .hex files that should be placed into /usr/local/share/hantek/. |
| 56 | 56 | \subsection ssec_firmware Installing the firmware | ... | ... |
openhantek/src/dso.cpp
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | |
| 31 | 31 | namespace Dso { |
| 32 | 32 | /// \brief Return string representation of the given channel mode. |
| 33 | - /// \param mode The #ChannelMode that should be returned as string. | |
| 33 | + /// \param mode The ::ChannelMode that should be returned as string. | |
| 34 | 34 | /// \return The string that should be used in labels etc., empty when invalid. |
| 35 | 35 | QString channelModeString(ChannelMode mode) { |
| 36 | 36 | switch(mode) { |
| ... | ... | @@ -44,7 +44,7 @@ namespace Dso { |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /// \brief Return string representation of the given graph format. |
| 47 | - /// \param format The #GraphFormat that should be returned as string. | |
| 47 | + /// \param format The ::GraphFormat that should be returned as string. | |
| 48 | 48 | /// \return The string that should be used in labels etc. |
| 49 | 49 | QString graphFormatString(GraphFormat format) { |
| 50 | 50 | switch(format) { |
| ... | ... | @@ -58,7 +58,7 @@ namespace Dso { |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /// \brief Return string representation of the given channel coupling. |
| 61 | - /// \param coupling The #Coupling that should be returned as string. | |
| 61 | + /// \param coupling The ::Coupling that should be returned as string. | |
| 62 | 62 | /// \return The string that should be used in labels etc. |
| 63 | 63 | QString couplingString(Coupling coupling) { |
| 64 | 64 | switch(coupling) { |
| ... | ... | @@ -74,7 +74,7 @@ namespace Dso { |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /// \brief Return string representation of the given math mode. |
| 77 | - /// \param mode The #MathMode that should be returned as string. | |
| 77 | + /// \param mode The ::MathMode that should be returned as string. | |
| 78 | 78 | /// \return The string that should be used in labels etc. |
| 79 | 79 | QString mathModeString(MathMode mode) { |
| 80 | 80 | switch(mode) { |
| ... | ... | @@ -90,7 +90,7 @@ namespace Dso { |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /// \brief Return string representation of the given trigger mode. |
| 93 | - /// \param mode The #TriggerMode that should be returned as string. | |
| 93 | + /// \param mode The ::TriggerMode that should be returned as string. | |
| 94 | 94 | /// \return The string that should be used in labels etc. |
| 95 | 95 | QString triggerModeString(TriggerMode mode) { |
| 96 | 96 | switch(mode) { |
| ... | ... | @@ -106,7 +106,7 @@ namespace Dso { |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /// \brief Return string representation of the given trigger slope. |
| 109 | - /// \param slope The #Slope that should be returned as string. | |
| 109 | + /// \param slope The ::Slope that should be returned as string. | |
| 110 | 110 | /// \return The string that should be used in labels etc. |
| 111 | 111 | QString slopeString(Slope slope) { |
| 112 | 112 | switch(slope) { |
| ... | ... | @@ -120,7 +120,7 @@ namespace Dso { |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /// \brief Return string representation of the given dft window function. |
| 123 | - /// \param window The #WindowFunction that should be returned as string. | |
| 123 | + /// \param window The ::WindowFunction that should be returned as string. | |
| 124 | 124 | /// \return The string that should be used in labels etc. |
| 125 | 125 | QString windowFunctionString(WindowFunction window) { |
| 126 | 126 | switch(window) { |
| ... | ... | @@ -160,7 +160,7 @@ namespace Dso { |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /// \brief Return string representation of the given graph interpolation mode. |
| 163 | - /// \param interpolation The #InterpolationMode that should be returned as string. | |
| 163 | + /// \param interpolation The ::InterpolationMode that should be returned as string. | |
| 164 | 164 | /// \return The string that should be used in labels etc. |
| 165 | 165 | QString interpolationModeString(InterpolationMode interpolation) { |
| 166 | 166 | switch(interpolation) { | ... | ... |
openhantek/src/dsowidget.h
| ... | ... | @@ -110,7 +110,7 @@ class DsoWidget : public QWidget { |
| 110 | 110 | void updateSpectrumUsed(unsigned int channel, bool used); |
| 111 | 111 | |
| 112 | 112 | // Vertical axis |
| 113 | - void updateVoltageCoupling(unsigned int channel); | |
| 113 | + void updateVoltageCoupling(unsigned int channel); | |
| 114 | 114 | void updateMathMode(); |
| 115 | 115 | void updateVoltageGain(unsigned int channel); |
| 116 | 116 | void updateVoltageUsed(unsigned int channel, bool used); | ... | ... |
openhantek/src/glgenerator.cpp
| ... | ... | @@ -310,13 +310,12 @@ void GlGenerator::generateGrid() { |
| 310 | 310 | |
| 311 | 311 | // Border |
| 312 | 312 | this->vaGrid[2].setSize(4 * 2); |
| 313 | - // The 1e-4 offsets avoid that the border is outside our drawing area | |
| 314 | - this->vaGrid[2].data[0] = -DIVS_TIME / 2 + 1e-4; | |
| 315 | - this->vaGrid[2].data[1] = -DIVS_VOLTAGE / 2 + 1e-4; | |
| 316 | - this->vaGrid[2].data[2] = DIVS_TIME / 2 - 1e-4; | |
| 317 | - this->vaGrid[2].data[3] = -DIVS_VOLTAGE / 2 + 1e-4; | |
| 318 | - this->vaGrid[2].data[4] = DIVS_TIME / 2 - 1e-4; | |
| 319 | - this->vaGrid[2].data[5] = DIVS_VOLTAGE / 2 - 1e-4; | |
| 320 | - this->vaGrid[2].data[6] = -DIVS_TIME / 2 + 1e-4; | |
| 321 | - this->vaGrid[2].data[7] = DIVS_VOLTAGE / 2 - 1e-4; | |
| 313 | + this->vaGrid[2].data[0] = -DIVS_TIME / 2; | |
| 314 | + this->vaGrid[2].data[1] = -DIVS_VOLTAGE / 2; | |
| 315 | + this->vaGrid[2].data[2] = DIVS_TIME / 2; | |
| 316 | + this->vaGrid[2].data[3] = -DIVS_VOLTAGE / 2; | |
| 317 | + this->vaGrid[2].data[4] = DIVS_TIME / 2; | |
| 318 | + this->vaGrid[2].data[5] = DIVS_VOLTAGE / 2; | |
| 319 | + this->vaGrid[2].data[6] = -DIVS_TIME / 2; | |
| 320 | + this->vaGrid[2].data[7] = DIVS_VOLTAGE / 2; | |
| 322 | 321 | } | ... | ... |
openhantek/src/glscope.cpp
| ... | ... | @@ -181,10 +181,15 @@ void GlScope::paintGL() { |
| 181 | 181 | /// \param height The new height of the widget. |
| 182 | 182 | void GlScope::resizeGL(int width, int height) { |
| 183 | 183 | glViewport(0, 0, (GLint) width, (GLint) height); |
| 184 | - //glViewport(1, 0, (GLint) width - 1, (GLint) height - 1); | |
| 184 | + | |
| 185 | 185 | glMatrixMode(GL_PROJECTION); |
| 186 | + | |
| 187 | + // Set axes to div-scale and apply correction for exact pixelization | |
| 186 | 188 | glLoadIdentity(); |
| 187 | - glOrtho(-DIVS_TIME / 2, DIVS_TIME / 2, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2, -1.0, 1.0); | |
| 189 | + GLdouble pixelizationWidthCorrection = (width > 0) ? (GLdouble) width / (width - 1) : 1; | |
| 190 | + GLdouble pixelizationHeightCorrection = (height > 0) ? (GLdouble) height / (height - 1) : 1; | |
| 191 | + glOrtho(-(DIVS_TIME / 2) * pixelizationWidthCorrection, (DIVS_TIME / 2) * pixelizationWidthCorrection, -(DIVS_VOLTAGE / 2) * pixelizationHeightCorrection, (DIVS_VOLTAGE / 2) * pixelizationHeightCorrection, -1.0, 1.0); | |
| 192 | + | |
| 188 | 193 | glMatrixMode(GL_MODELVIEW); |
| 189 | 194 | } |
| 190 | 195 | ... | ... |
openhantek/src/hantek/control.cpp
| ... | ... | @@ -285,14 +285,14 @@ namespace Hantek { |
| 285 | 285 | /// \param value The data value that contains the trigger point. |
| 286 | 286 | /// \return The calculated trigger point for the given data. |
| 287 | 287 | unsigned short int Control::calculateTriggerPoint(unsigned short int value) { |
| 288 | - unsigned short int result = value; | |
| 289 | - | |
| 288 | + unsigned short int result = value; | |
| 289 | + | |
| 290 | 290 | // Each set bit inverts all bits with a lower value |
| 291 | 291 | for(unsigned short int bitValue = 1; bitValue; bitValue <<= 1) |
| 292 | 292 | if(result & bitValue) |
| 293 | 293 | result ^= bitValue - 1; |
| 294 | - | |
| 295 | - return result; | |
| 294 | + | |
| 295 | + return result; | |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /// \brief Gets the current state. |
| ... | ... | @@ -546,7 +546,6 @@ namespace Hantek { |
| 546 | 546 | // Determine the command version we need for this model |
| 547 | 547 | bool unsupported = false; |
| 548 | 548 | switch(this->device->getModel()) { |
| 549 | - case MODEL_DSO2100: | |
| 550 | 549 | case MODEL_DSO2150: |
| 551 | 550 | unsupported = true; |
| 552 | 551 | ... | ... |
openhantek/src/hantek/control.h
| ... | ... | @@ -72,7 +72,7 @@ namespace Hantek { |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | 74 | ////////////////////////////////////////////////////////////////////////////// |
| 75 | - /// \struct ControlSpecificationCommandsControlValues hantek/control.h | |
| 75 | + /// \struct ControlSpecificationCommandsValues hantek/control.h | |
| 76 | 76 | /// \brief Stores the control value codes used for this device. |
| 77 | 77 | struct ControlSpecificationCommandsValues { |
| 78 | 78 | ControlValue offsetLimits; ///< Code for channel offset limits |
| ... | ... | @@ -137,7 +137,7 @@ namespace Hantek { |
| 137 | 137 | }; |
| 138 | 138 | |
| 139 | 139 | ////////////////////////////////////////////////////////////////////////////// |
| 140 | - /// \struct ControlSettingsSamplerate hantek/control.h | |
| 140 | + /// \struct ControlSettingsTrigger hantek/control.h | |
| 141 | 141 | /// \brief Stores the current trigger settings of the device. |
| 142 | 142 | struct ControlSettingsTrigger { |
| 143 | 143 | double level[HANTEK_CHANNELS]; ///< The trigger level for each channel in V |
| ... | ... | @@ -150,7 +150,7 @@ namespace Hantek { |
| 150 | 150 | }; |
| 151 | 151 | |
| 152 | 152 | ////////////////////////////////////////////////////////////////////////////// |
| 153 | - /// \struct ControlSettingsSamplerate hantek/control.h | |
| 153 | + /// \struct ControlSettingsVoltage hantek/control.h | |
| 154 | 154 | /// \brief Stores the current amplification settings of the device. |
| 155 | 155 | struct ControlSettingsVoltage { |
| 156 | 156 | unsigned int gain; ///< The gain id | ... | ... |
openhantek/src/hantek/device.cpp
| ... | ... | @@ -460,7 +460,7 @@ namespace Hantek { |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /// \brief Gets the speed of the connection. |
| 463 | - /// \return The #ConnectionSpeed of the USB connection. | |
| 463 | + /// \return The ::ConnectionSpeed of the USB connection. | |
| 464 | 464 | int Device::getConnectionSpeed() { |
| 465 | 465 | int errorCode; |
| 466 | 466 | ControlGetSpeed response; |
| ... | ... | @@ -473,7 +473,7 @@ namespace Hantek { |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /// \brief Get the oscilloscope model. |
| 476 | - /// \return The #Model of the connected Hantek DSO. | |
| 476 | + /// \return The ::Model of the connected Hantek DSO. | |
| 477 | 477 | Model Device::getModel() { |
| 478 | 478 | return this->model; |
| 479 | 479 | } | ... | ... |
openhantek/src/hantek/device.h
| ... | ... | @@ -79,8 +79,8 @@ namespace Hantek { |
| 79 | 79 | |
| 80 | 80 | protected: |
| 81 | 81 | // Lists for enums |
| 82 | - QList<unsigned short int> modelIds; ///< Product ID for each #Model | |
| 83 | - QStringList modelStrings; ///< The name as QString for each #Model | |
| 82 | + QList<unsigned short int> modelIds; ///< Product ID for each ::Model | |
| 83 | + QStringList modelStrings; ///< The name as QString for each ::Model | |
| 84 | 84 | |
| 85 | 85 | // Command buffers |
| 86 | 86 | ControlBeginCommand *beginCommandControl; ///< Buffer for the CONTROL_BEGINCOMMAND control command | ... | ... |
openhantek/src/hantek/types.cpp
| ... | ... | @@ -135,13 +135,13 @@ namespace Hantek { |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /// \brief Get the bufferSize value in Tsr1Bits. |
| 138 | - /// \return The #BufferSizeId value. | |
| 138 | + /// \return The ::BufferSizeId value. | |
| 139 | 139 | unsigned char BulkSetTriggerAndSamplerate::getBufferSize() { |
| 140 | 140 | return ((Tsr1Bits *) &(this->array[2]))->bufferSize; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /// \brief Set the bufferSize in Tsr1Bits to the given value. |
| 144 | - /// \param value The new #BufferSizeId value. | |
| 144 | + /// \param value The new ::BufferSizeId value. | |
| 145 | 145 | void BulkSetTriggerAndSamplerate::setBufferSize(unsigned char value) { |
| 146 | 146 | ((Tsr1Bits *) &(this->array[2]))->bufferSize = value; |
| 147 | 147 | } |
| ... | ... | @@ -623,7 +623,7 @@ namespace Hantek { |
| 623 | 623 | /// \param triggerPositionPost The TriggerPositionPost value. |
| 624 | 624 | /// \param usedPre The TriggerPositionUsedPre value. |
| 625 | 625 | /// \param usedPost The TriggerPositionUsedPost value. |
| 626 | - /// \param bufferSize The #BufferSizeId value. | |
| 626 | + /// \param bufferSize The ::BufferSizeId value. | |
| 627 | 627 | BulkSetBuffer5200::BulkSetBuffer5200(unsigned short int triggerPositionPre, unsigned short int triggerPositionPost, unsigned char usedPre, unsigned char usedPost, unsigned char bufferSize) : Helper::DataArray<unsigned char>(10) { |
| 628 | 628 | this->init(); |
| 629 | 629 | |
| ... | ... | @@ -661,37 +661,37 @@ namespace Hantek { |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /// \brief Get the TriggerPositionUsedPre value. |
| 664 | - /// \return The #DTriggerPositionUsed value for the pre position. | |
| 664 | + /// \return The ::DTriggerPositionUsed value for the pre position. | |
| 665 | 665 | unsigned char BulkSetBuffer5200::getUsedPre() { |
| 666 | 666 | return this->array[4]; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /// \brief Set the TriggerPositionUsedPre to the given value. |
| 670 | - /// \param value The new #DTriggerPositionUsed value for the pre position. | |
| 670 | + /// \param value The new ::DTriggerPositionUsed value for the pre position. | |
| 671 | 671 | void BulkSetBuffer5200::setUsedPre(unsigned char value) { |
| 672 | 672 | this->array[4] = value; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /// \brief Get the TriggerPositionUsedPost value. |
| 676 | - /// \return The #DTriggerPositionUsed value for the post position. | |
| 676 | + /// \return The ::DTriggerPositionUsed value for the post position. | |
| 677 | 677 | unsigned char BulkSetBuffer5200::getUsedPost() { |
| 678 | 678 | return ((DBufferBits *) &(this->array[8]))->triggerPositionUsed; |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /// \brief Set the TriggerPositionUsedPost to the given value. |
| 682 | - /// \param value The new #DTriggerPositionUsed value for the post position. | |
| 682 | + /// \param value The new ::DTriggerPositionUsed value for the post position. | |
| 683 | 683 | void BulkSetBuffer5200::setUsedPost(unsigned char value) { |
| 684 | 684 | ((DBufferBits *) &(this->array[8]))->triggerPositionUsed = value; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /// \brief Get the bufferSize value in DBufferBits. |
| 688 | - /// \return The #BufferSizeId value. | |
| 688 | + /// \return The ::BufferSizeId value. | |
| 689 | 689 | unsigned char BulkSetBuffer5200::getBufferSize() { |
| 690 | 690 | return ((DBufferBits *) &(this->array[8]))->bufferSize; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /// \brief Set the bufferSize in DBufferBits to the given value. |
| 694 | - /// \param value The new #BufferSizeId value. | |
| 694 | + /// \param value The new ::BufferSizeId value. | |
| 695 | 695 | void BulkSetBuffer5200::setBufferSize(unsigned char value) { |
| 696 | 696 | ((DBufferBits *) &(this->array[8]))->bufferSize = value; |
| 697 | 697 | } |
| ... | ... | @@ -728,25 +728,25 @@ namespace Hantek { |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | /// \brief Get the triggerSource value in ETsrBits. |
| 731 | - /// \return The #TriggerSource value. | |
| 731 | + /// \return The ::TriggerSource value. | |
| 732 | 732 | unsigned char BulkSetTrigger5200::getTriggerSource() { |
| 733 | 733 | return ((ETsrBits *) &(this->array[2]))->triggerSource; |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | /// \brief Set the triggerSource in ETsrBits to the given value. |
| 737 | - /// \param value The new #TriggerSource value. | |
| 737 | + /// \param value The new ::TriggerSource value. | |
| 738 | 738 | void BulkSetTrigger5200::setTriggerSource(unsigned char value) { |
| 739 | 739 | ((ETsrBits *) &(this->array[2]))->triggerSource = value; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | /// \brief Get the usedChannels value in ETsrBits. |
| 743 | - /// \return The #UsedChannels value. | |
| 743 | + /// \return The ::UsedChannels value. | |
| 744 | 744 | unsigned char BulkSetTrigger5200::getUsedChannels() { |
| 745 | 745 | return ((ETsrBits *) &(this->array[2]))->usedChannels; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /// \brief Set the usedChannels in ETsrBits to the given value. |
| 749 | - /// \param value The new #UsedChannels value. | |
| 749 | + /// \param value The new ::UsedChannels value. | |
| 750 | 750 | void BulkSetTrigger5200::setUsedChannels(unsigned char value) { |
| 751 | 751 | ((ETsrBits *) &(this->array[2]))->usedChannels = value; |
| 752 | 752 | } | ... | ... |
openhantek/src/hantek/types.h
| ... | ... | @@ -51,6 +51,7 @@ namespace Hantek { |
| 51 | 51 | /// \brief All supported bulk commands. |
| 52 | 52 | /// Indicies given in square brackets specify byte numbers in little endian format. |
| 53 | 53 | enum BulkCode { |
| 54 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 54 | 55 | /// <p> |
| 55 | 56 | /// This command sets channel and trigger filter: |
| 56 | 57 | /// <table> |
| ... | ... | @@ -66,8 +67,10 @@ namespace Hantek { |
| 66 | 67 | /// </tr> |
| 67 | 68 | /// </table> |
| 68 | 69 | /// </p> |
| 70 | + /// <p><br /></p> | |
| 69 | 71 | BULK_SETFILTER, |
| 70 | 72 | |
| 73 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150]</em> | |
| 71 | 74 | /// <p> |
| 72 | 75 | /// This command sets trigger and timebase: |
| 73 | 76 | /// <table> |
| ... | ... | @@ -101,8 +104,10 @@ namespace Hantek { |
| 101 | 104 | /// <p> |
| 102 | 105 | /// The TriggerPosition sets the position of the pretrigger in samples. The left side (0 %) is 0x77660 when using the small buffer and 0x78000 when using the large buffer. |
| 103 | 106 | /// </p> |
| 107 | + /// <p><br /></p> | |
| 104 | 108 | BULK_SETTRIGGERANDSAMPLERATE, |
| 105 | 109 | |
| 110 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 106 | 111 | /// <p> |
| 107 | 112 | /// This command forces triggering: |
| 108 | 113 | /// <table> |
| ... | ... | @@ -112,8 +117,10 @@ namespace Hantek { |
| 112 | 117 | /// </tr> |
| 113 | 118 | /// </table> |
| 114 | 119 | /// </p> |
| 120 | + /// <p><br /></p> | |
| 115 | 121 | BULK_FORCETRIGGER, |
| 116 | 122 | |
| 123 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 117 | 124 | /// <p> |
| 118 | 125 | /// This command starts to capture data: |
| 119 | 126 | /// <table> |
| ... | ... | @@ -123,8 +130,10 @@ namespace Hantek { |
| 123 | 130 | /// </tr> |
| 124 | 131 | /// </table> |
| 125 | 132 | /// </p> |
| 133 | + /// <p><br /></p> | |
| 126 | 134 | BULK_STARTSAMPLING, |
| 127 | 135 | |
| 136 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 128 | 137 | /// <p> |
| 129 | 138 | /// This command sets the trigger: |
| 130 | 139 | /// <table> |
| ... | ... | @@ -134,8 +143,10 @@ namespace Hantek { |
| 134 | 143 | /// </tr> |
| 135 | 144 | /// </table> |
| 136 | 145 | /// </p> |
| 146 | + /// <p><br /></p> | |
| 137 | 147 | BULK_ENABLETRIGGER, |
| 138 | 148 | |
| 149 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 139 | 150 | /// <p> |
| 140 | 151 | /// This command reads data from the hardware: |
| 141 | 152 | /// <table> |
| ... | ... | @@ -180,8 +191,10 @@ namespace Hantek { |
| 180 | 191 | /// </tr> |
| 181 | 192 | /// </table> |
| 182 | 193 | /// </p> |
| 194 | + /// <p><br /></p> | |
| 183 | 195 | BULK_GETDATA, |
| 184 | 196 | |
| 197 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 185 | 198 | /// <p> |
| 186 | 199 | /// This command checks the capture state: |
| 187 | 200 | /// <table> |
| ... | ... | @@ -195,7 +208,7 @@ namespace Hantek { |
| 195 | 208 | /// The oscilloscope returns it's capture state and the trigger point. Not sure about this, looks like 248 16-bit words with nearly constant values. These can be converted to the start address of the data in the buffer (See Hantek::Control::calculateTriggerPoint): |
| 196 | 209 | /// <table> |
| 197 | 210 | /// <tr> |
| 198 | - /// <td>#CaptureState</td> | |
| 211 | + /// <td>::CaptureState</td> | |
| 199 | 212 | /// <td>0x00</td> |
| 200 | 213 | /// <td>TriggerPoint[0]</td> |
| 201 | 214 | /// <td>TriggerPoint[1]</td> |
| ... | ... | @@ -203,8 +216,10 @@ namespace Hantek { |
| 203 | 216 | /// </tr> |
| 204 | 217 | /// </table> |
| 205 | 218 | /// </p> |
| 219 | + /// <p><br /></p> | |
| 206 | 220 | BULK_GETCAPTURESTATE, |
| 207 | 221 | |
| 222 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 208 | 223 | /// <p> |
| 209 | 224 | /// This command sets the gain: |
| 210 | 225 | /// <table> |
| ... | ... | @@ -219,10 +234,12 @@ namespace Hantek { |
| 219 | 234 | /// <td>0x00</td> |
| 220 | 235 | /// </tr> |
| 221 | 236 | /// </table> |
| 222 | - /// It is usually used in combination with #CONTROL_SETRELAYS. | |
| 237 | + /// It is usually used in combination with ::CONTROL_SETRELAYS. | |
| 223 | 238 | /// </p> |
| 239 | + /// <p><br /></p> | |
| 224 | 240 | BULK_SETGAIN, |
| 225 | 241 | |
| 242 | + /// <em>[]</em> | |
| 226 | 243 | /// <p> |
| 227 | 244 | /// This command sets the logical data (Not used in official Hantek software): |
| 228 | 245 | /// <table> |
| ... | ... | @@ -238,8 +255,10 @@ namespace Hantek { |
| 238 | 255 | /// </tr> |
| 239 | 256 | /// </table> |
| 240 | 257 | /// </p> |
| 258 | + /// <p><br /></p> | |
| 241 | 259 | BULK_SETLOGICALDATA, |
| 242 | 260 | |
| 261 | + /// <em>[::MODEL_DSO2250]</em> | |
| 243 | 262 | /// <p> |
| 244 | 263 | /// This command reads the logical data (Not used in official Hantek software): |
| 245 | 264 | /// <table> |
| ... | ... | @@ -258,10 +277,12 @@ namespace Hantek { |
| 258 | 277 | /// </tr> |
| 259 | 278 | /// </table> |
| 260 | 279 | /// </p> |
| 280 | + /// <p><br /></p> | |
| 261 | 281 | BULK_GETLOGICALDATA, |
| 262 | 282 | |
| 283 | + /// <em>[]</em> | |
| 263 | 284 | /// <p> |
| 264 | - /// This command isn't used for the DSO-2090 and DSO-5200: | |
| 285 | + /// This command isn't used for any supported model: | |
| 265 | 286 | /// <table> |
| 266 | 287 | /// <tr> |
| 267 | 288 | /// <td>0x0a</td> |
| ... | ... | @@ -269,19 +290,25 @@ namespace Hantek { |
| 269 | 290 | /// </tr> |
| 270 | 291 | /// </table> |
| 271 | 292 | /// </p> |
| 293 | + /// <p><br /></p> | |
| 272 | 294 | BULK_UNKNOWN_0A, |
| 273 | - | |
| 295 | + | |
| 296 | + /// <em>[::MODEL_DSO2250]</em> | |
| 274 | 297 | /// <p> |
| 275 | - /// This command isn't used for the DSO-2090 and DSO-5200: | |
| 298 | + /// This command is used for the DSO-2250: | |
| 276 | 299 | /// <table> |
| 277 | 300 | /// <tr> |
| 278 | 301 | /// <td>0x0b</td> |
| 279 | - /// <td>...</td> | |
| 302 | + /// <td>0x00</td> | |
| 303 | + /// <td>(unknown)</td> | |
| 304 | + /// <td>0x00</td> | |
| 280 | 305 | /// </tr> |
| 281 | 306 | /// </table> |
| 282 | 307 | /// </p> |
| 308 | + /// <p><br /></p> | |
| 283 | 309 | BULK_UNKNOWN_0B, |
| 284 | - | |
| 310 | + | |
| 311 | + /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 285 | 312 | /// <p> |
| 286 | 313 | /// This command sets the sampling rate for the DSO-5200: |
| 287 | 314 | /// <table> |
| ... | ... | @@ -296,12 +323,14 @@ namespace Hantek { |
| 296 | 323 | /// </table> |
| 297 | 324 | /// </p> |
| 298 | 325 | /// <p> |
| 299 | - /// The values are similar to the ones used on the DSO-2090. The formula is a bit different here:<br /> | |
| 326 | + /// The values are similar to the ones used with ::BULK_SETTRIGGERANDSAMPLERATE. The formula is a bit different here:<br /> | |
| 300 | 327 | /// <i>Samplerate = SamplerateMax / (2comp(SamplerateSlow) * 2 + 4 - SamplerateFast)</i><br /> |
| 301 | 328 | /// SamplerateMax is 100 MS/s for the DSO-5200 in default configuration and 250 MS/s in fast rate mode though, the modifications regarding buffer size are the the same that apply for the DSO-2090. |
| 302 | 329 | /// </p> |
| 330 | + /// <p><br /></p> | |
| 303 | 331 | BULK_SETSAMPLERATE5200, |
| 304 | 332 | |
| 333 | + /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 305 | 334 | /// <p> |
| 306 | 335 | /// This command sets the trigger position and buffer size for the DSO-5200: |
| 307 | 336 | /// <table> |
| ... | ... | @@ -310,7 +339,7 @@ namespace Hantek { |
| 310 | 339 | /// <td>0x00</td> |
| 311 | 340 | /// <td>TriggerPositionPre[0]</td> |
| 312 | 341 | /// <td>TriggerPositionPre[1]</td> |
| 313 | - /// <td>#DTriggerPositionUsed</td> | |
| 342 | + /// <td>::DTriggerPositionUsed</td> | |
| 314 | 343 | /// </tr> |
| 315 | 344 | /// </table> |
| 316 | 345 | /// <table> |
| ... | ... | @@ -326,8 +355,10 @@ namespace Hantek { |
| 326 | 355 | /// <p> |
| 327 | 356 | /// The TriggerPositionPre and TriggerPositionPost values set the pretrigger position. Both values have a range from 0xd7ff (0xc7ff for 14 kiS buffer) to 0xfffe. On the left side (0 %) the TriggerPositionPre value is minimal, on the right side (100 %) it is maximal. The TriggerPositionPost value is maximal for 0 % and minimal for 100%. |
| 328 | 357 | /// </p> |
| 358 | + /// <p><br /></p> | |
| 329 | 359 | BULK_SETBUFFER5200, |
| 330 | 360 | |
| 361 | + /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 331 | 362 | /// <p> |
| 332 | 363 | /// This command sets the channel and trigger settings for the DSO-5200: |
| 333 | 364 | /// <table> |
| ... | ... | @@ -343,25 +374,56 @@ namespace Hantek { |
| 343 | 374 | /// </tr> |
| 344 | 375 | /// </table> |
| 345 | 376 | /// </p> |
| 377 | + /// <p><br /></p> | |
| 346 | 378 | BULK_SETTRIGGER5200, |
| 347 | - | |
| 348 | - BULK_COUNT ///< Total number of commands | |
| 379 | + | |
| 380 | + /// <em>[::MODEL_DSO2250]</em> | |
| 381 | + /// <p> | |
| 382 | + /// This command is used for the DSO-2250: | |
| 383 | + /// <table> | |
| 384 | + /// <tr> | |
| 385 | + /// <td>0x0f</td> | |
| 386 | + /// <td>0x00</td> | |
| 387 | + /// <td>(unknown)</td> | |
| 388 | + /// <td>(unknown)</td> | |
| 389 | + /// <td>(unknown)</td> | |
| 390 | + /// <td>(unknown)</td> | |
| 391 | + /// </tr> | |
| 392 | + /// </table> | |
| 393 | + /// <table> | |
| 394 | + /// <tr> | |
| 395 | + /// <td>(unknown)</td> | |
| 396 | + /// <td>(unknown)</td> | |
| 397 | + /// <td>(unknown)</td> | |
| 398 | + /// <td>(unknown)</td> | |
| 399 | + /// <td>(unknown)</td> | |
| 400 | + /// <td>(unknown)</td> | |
| 401 | + /// </tr> | |
| 402 | + /// </table> | |
| 403 | + /// </p> | |
| 404 | + /// <p><br /></p> | |
| 405 | + BULK_UNKNOWN_0F, | |
| 406 | + | |
| 407 | + BULK_COUNT | |
| 349 | 408 | }; |
| 350 | 409 | |
| 351 | 410 | ////////////////////////////////////////////////////////////////////////////// |
| 352 | 411 | /// \enum ControlCode hantek/types.h |
| 353 | 412 | /// \brief All supported control commands. |
| 354 | 413 | enum ControlCode { |
| 414 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 355 | 415 | /// <p> |
| 356 | - /// The 0xa2 control read/write command gives access to a #ControlValue. | |
| 416 | + /// The 0xa2 control read/write command gives access to a ::ControlValue. | |
| 357 | 417 | /// </p> |
| 418 | + /// <p><br /></p> | |
| 358 | 419 | CONTROL_VALUE = 0xa2, |
| 359 | 420 | |
| 421 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 360 | 422 | /// <p> |
| 361 | 423 | /// The 0xb2 control read command gets the speed level of the USB connection: |
| 362 | 424 | /// <table> |
| 363 | 425 | /// <tr> |
| 364 | - /// <td>#ConnectionSpeed</td> | |
| 426 | + /// <td>::ConnectionSpeed</td> | |
| 365 | 427 | /// <td>0x00</td> |
| 366 | 428 | /// <td>0x00</td> |
| 367 | 429 | /// <td>0x00</td> |
| ... | ... | @@ -374,16 +436,18 @@ namespace Hantek { |
| 374 | 436 | /// </tr> |
| 375 | 437 | /// </table> |
| 376 | 438 | /// </p> |
| 439 | + /// <p><br /></p> | |
| 377 | 440 | CONTROL_GETSPEED = 0xb2, |
| 378 | 441 | |
| 442 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 379 | 443 | /// <p> |
| 380 | 444 | /// The 0xb3 control write command is sent before any bulk command: |
| 381 | 445 | /// <table> |
| 382 | 446 | /// <tr> |
| 383 | 447 | /// <td>0x0f</td> |
| 384 | - /// <td>#CommandIndex</td> | |
| 385 | - /// <td>#CommandIndex</td> | |
| 386 | - /// <td>#CommandIndex</td> | |
| 448 | + /// <td>::BulkIndex</td> | |
| 449 | + /// <td>::BulkIndex</td> | |
| 450 | + /// <td>::BulkIndex</td> | |
| 387 | 451 | /// <td>0x00</td> |
| 388 | 452 | /// <td>0x00</td> |
| 389 | 453 | /// <td>0x00</td> |
| ... | ... | @@ -393,8 +457,10 @@ namespace Hantek { |
| 393 | 457 | /// </tr> |
| 394 | 458 | /// </table> |
| 395 | 459 | /// </p> |
| 460 | + /// <p><br /></p> | |
| 396 | 461 | CONTROL_BEGINCOMMAND = 0xb3, |
| 397 | 462 | |
| 463 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 398 | 464 | /// <p> |
| 399 | 465 | /// The 0xb4 control write command sets the channel offsets: |
| 400 | 466 | /// <table> |
| ... | ... | @@ -423,8 +489,10 @@ namespace Hantek { |
| 423 | 489 | /// </tr> |
| 424 | 490 | /// </table> |
| 425 | 491 | /// </p> |
| 492 | + /// <p><br /></p> | |
| 426 | 493 | CONTROL_SETOFFSET = 0xb4, |
| 427 | 494 | |
| 495 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 428 | 496 | /// <p> |
| 429 | 497 | /// The 0xb5 control write command sets the internal relays: |
| 430 | 498 | /// <table> |
| ... | ... | @@ -460,6 +528,7 @@ namespace Hantek { |
| 460 | 528 | /// <p> |
| 461 | 529 | /// The limits are <= instead of < for the 10 bit models, since those support voltages up to 10 V. |
| 462 | 530 | /// </p> |
| 531 | + /// <p><br /></p> | |
| 463 | 532 | CONTROL_SETRELAYS = 0xb5 |
| 464 | 533 | }; |
| 465 | 534 | |
| ... | ... | @@ -467,17 +536,33 @@ namespace Hantek { |
| 467 | 536 | /// \enum ControlValue hantek/types.h |
| 468 | 537 | /// \brief All supported values for control commands. |
| 469 | 538 | enum ControlValue { |
| 539 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 540 | + /// <p> | |
| 470 | 541 | /// Value 0x08 is the calibration data for the channels offsets. It holds the offset value for the top and bottom of the scope screen for every gain step on every channel. The data is stored as a three-dimensional array:<br /> |
| 471 | - /// <i>channelLevels[channel][#Gain][#LevelOffset]</i> | |
| 542 | + /// <i>channelLevels[channel][GainId][::LevelOffset]</i> | |
| 543 | + /// </p> | |
| 544 | + /// <p><br /></p> | |
| 472 | 545 | VALUE_OFFSETLIMITS = 0x08, |
| 473 | 546 | |
| 547 | + /// <em>[::MODEL_DSO2090, ::MODEL_DSO2150, ::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 548 | + /// <p> | |
| 474 | 549 | /// Value 0x0a is the address of the device. It has a length of one byte. |
| 550 | + /// </p> | |
| 551 | + /// <p><br /></p> | |
| 475 | 552 | VALUE_DEVICEADDRESS = 0x0a, |
| 476 | 553 | |
| 477 | - /// Value 0x60 is the calibration data for the fast rate mode on the DSO-5200. It's used to correct the level differences between the two merged channels to avoid . | |
| 554 | + /// <em>[::MODEL_DSO2250, ::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 555 | + /// <p> | |
| 556 | + /// Value 0x60 is the calibration data for the fast rate mode on the DSO-2250, DSO-5200 and DSO-5200A. It's used to correct the level differences between the two merged channels to avoid deterministic noise. | |
| 557 | + /// </p> | |
| 558 | + /// <p><br /></p> | |
| 478 | 559 | VALUE_CALIBRATIONDATA = 0x60, |
| 479 | 560 | |
| 480 | - /// Value 0x70 contains correction values for the ETS functionality of the DSO-5200. | |
| 561 | + /// <em>[::MODEL_DSO5200, ::MODEL_DSO5200A]</em> | |
| 562 | + /// <p> | |
| 563 | + /// Value 0x70 contains correction values for the ETS functionality of the DSO-5200 and DSO-5200A. | |
| 564 | + /// </p> | |
| 565 | + /// <p><br /></p> | |
| 481 | 566 | VALUE_VOLTAGELIMITS = 0x70 |
| 482 | 567 | }; |
| 483 | 568 | |
| ... | ... | @@ -485,9 +570,12 @@ namespace Hantek { |
| 485 | 570 | /// \enum Model hantek/types.h |
| 486 | 571 | /// \brief All supported Hantek DSO models. |
| 487 | 572 | enum Model { |
| 488 | - MODEL_UNKNOWN = -1, | |
| 489 | - MODEL_DSO2090, MODEL_DSO2100, MODEL_DSO2150, MODEL_DSO2250, | |
| 490 | - MODEL_DSO5200, MODEL_DSO5200A, | |
| 573 | + MODEL_UNKNOWN = -1, ///< Unknown model | |
| 574 | + MODEL_DSO2090, ///< %Hantek DSO-2090 USB | |
| 575 | + MODEL_DSO2150, ///< %Hantek DSO-2150 USB | |
| 576 | + MODEL_DSO2250, ///< %Hantek DSO-2250 USB | |
| 577 | + MODEL_DSO5200, ///< %Hantek DSO-5200 USB | |
| 578 | + MODEL_DSO5200A, ///< %Hantek DSO-5200A USB | |
| 491 | 579 | MODEL_COUNT |
| 492 | 580 | }; |
| 493 | 581 | |
| ... | ... | @@ -551,7 +639,7 @@ namespace Hantek { |
| 551 | 639 | COMMANDINDEX_0 = 0x03, ///< Used most of the time |
| 552 | 640 | COMMANDINDEX_1 = 0x0a, |
| 553 | 641 | COMMANDINDEX_2 = 0x09, |
| 554 | - COMMANDINDEX_3 = 0x01, ///< Used for #BULK_SETTRIGGERANDSAMPLERATE sometimes | |
| 642 | + COMMANDINDEX_3 = 0x01, ///< Used for ::BULK_SETTRIGGERANDSAMPLERATE sometimes | |
| 555 | 643 | COMMANDINDEX_4 = 0x02, |
| 556 | 644 | COMMANDINDEX_5 = 0x08 |
| 557 | 645 | }; |
| ... | ... | @@ -597,7 +685,7 @@ namespace Hantek { |
| 597 | 685 | /// \brief Trigger and samplerate bits (Byte 1). |
| 598 | 686 | struct Tsr1Bits { |
| 599 | 687 | unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource |
| 600 | - unsigned char bufferSize:3; ///< See #BufferSizeId | |
| 688 | + unsigned char bufferSize:3; ///< See ::BufferSizeId | |
| 601 | 689 | unsigned char samplerateFast:3; ///< samplerate value for fast sampling rates |
| 602 | 690 | }; |
| 603 | 691 | |
| ... | ... | @@ -615,8 +703,8 @@ namespace Hantek { |
| 615 | 703 | /// \struct DBufferBits hantek/types.h |
| 616 | 704 | /// \brief Buffer mode bits for 0x0d command. |
| 617 | 705 | struct DBufferBits { |
| 618 | - unsigned char triggerPositionUsed:3; ///< See #DTriggerPositionUsed | |
| 619 | - unsigned char bufferSize:3; ///< See #BufferSizeId | |
| 706 | + unsigned char triggerPositionUsed:3; ///< See ::DTriggerPositionUsed | |
| 707 | + unsigned char bufferSize:3; ///< See ::BufferSizeId | |
| 620 | 708 | unsigned char reserved:2; ///< Unused bits |
| 621 | 709 | }; |
| 622 | 710 | ... | ... |
openhantek/src/levelslider.cpp
| ... | ... | @@ -329,9 +329,9 @@ void LevelSlider::mouseMoveEvent(QMouseEvent *event) { |
| 329 | 329 | // Get new value |
| 330 | 330 | double value; |
| 331 | 331 | if(this->_direction == Qt::RightArrow || this->_direction == Qt::LeftArrow) |
| 332 | - value = this->slider[pressedSlider]->maximum - (this->slider[pressedSlider]->maximum - this->slider[pressedSlider]->minimum) * (event->y() - this->_preMargin) / (this->height() - this->_preMargin - this->_postMargin - 1); | |
| 332 | + value = this->slider[pressedSlider]->maximum - (this->slider[pressedSlider]->maximum - this->slider[pressedSlider]->minimum) * ((double) event->y() - this->_preMargin + 0.5) / (this->height() - this->_preMargin - this->_postMargin - 1); | |
| 333 | 333 | else |
| 334 | - value = this->slider[pressedSlider]->minimum + (this->slider[pressedSlider]->maximum - this->slider[pressedSlider]->minimum) * (event->x() - this->_preMargin) / (this->width() - this->_preMargin - this->_postMargin - 1); | |
| 334 | + value = this->slider[pressedSlider]->minimum + (this->slider[pressedSlider]->maximum - this->slider[pressedSlider]->minimum) * ((double) event->x() - this->_preMargin + 0.5) / (this->width() - this->_preMargin - this->_postMargin - 1); | |
| 335 | 335 | |
| 336 | 336 | // Move the slider |
| 337 | 337 | if(event->modifiers() & Qt::AltModifier) |
| ... | ... | @@ -491,18 +491,18 @@ QRect LevelSlider::calculateRect(int sliderId) { |
| 491 | 491 | if(this->slider[sliderId]->text.isEmpty()) { |
| 492 | 492 | this->slider[sliderId]->rect = QRect( |
| 493 | 493 | 0, // Start at the left side |
| 494 | - // The needle should be center-aligned | |
| 495 | - (long) (this->height() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->maximum - this->slider[sliderId]->value) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + this->_preMargin - 3, | |
| 494 | + // The needle should be center-aligned, 0.5 pixel offset for exact pixelization | |
| 495 | + (long) ((double) (this->height() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->maximum - this->slider[sliderId]->value) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + 0.5f) + this->_preMargin - 3, | |
| 496 | 496 | this->sliderWidth, // Fill the whole width |
| 497 | - 7 // The needle is 5 px wide | |
| 497 | + 7 // The needle is 7 px wide | |
| 498 | 498 | ); |
| 499 | 499 | } |
| 500 | 500 | // Or a thin needle with text? |
| 501 | 501 | else { |
| 502 | 502 | this->slider[sliderId]->rect = QRect( |
| 503 | 503 | 0, // Start at the left side |
| 504 | - // The needle is at the bottom, the text above it | |
| 505 | - (long) (this->height() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->maximum - this->slider[sliderId]->value) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum), | |
| 504 | + // The needle is at the bottom, the text above it, 0.5 pixel offset for exact pixelization | |
| 505 | + (long) ((double) (this->height() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->maximum - this->slider[sliderId]->value) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + 0.5f), | |
| 506 | 506 | this->sliderWidth, // Fill the whole width |
| 507 | 507 | this->preMargin() + 1 // Use the full margin |
| 508 | 508 | ); |
| ... | ... | @@ -513,10 +513,10 @@ QRect LevelSlider::calculateRect(int sliderId) { |
| 513 | 513 | // Is it a triangular needle? |
| 514 | 514 | if(this->slider[sliderId]->text.isEmpty()) { |
| 515 | 515 | this->slider[sliderId]->rect = QRect( |
| 516 | - // The needle should be center-aligned | |
| 517 | - (long) (this->width() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->value - this->slider[sliderId]->minimum) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + this->_preMargin - 3, | |
| 516 | + // The needle should be center-aligned, 0.5 pixel offset for exact pixelization | |
| 517 | + (long) ((double) (this->width() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->value - this->slider[sliderId]->minimum) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + 0.5f) + this->_preMargin - 3, | |
| 518 | 518 | 0, // Start at the top |
| 519 | - 7, // The needle is 5 px wide | |
| 519 | + 7, // The needle is 7 px wide | |
| 520 | 520 | this->sliderWidth // Fill the whole height |
| 521 | 521 | ); |
| 522 | 522 | } |
| ... | ... | @@ -524,8 +524,8 @@ QRect LevelSlider::calculateRect(int sliderId) { |
| 524 | 524 | else { |
| 525 | 525 | int sliderLength = this->fontMetrics().size(0, this->slider[sliderId]->text).width() + 2; |
| 526 | 526 | this->slider[sliderId]->rect = QRect( |
| 527 | - // The needle is at the right side, the text before it | |
| 528 | - (long) (this->width() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->value - this->slider[sliderId]->minimum) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + this->_preMargin - sliderLength + 1, | |
| 527 | + // The needle is at the right side, the text before it, 0.5 pixel offset for exact pixelization | |
| 528 | + (long) ((double) (this->width() - this->_preMargin - this->_postMargin - 1) * (this->slider[sliderId]->value - this->slider[sliderId]->minimum) / (this->slider[sliderId]->maximum - this->slider[sliderId]->minimum) + 0.5f) + this->_preMargin - sliderLength + 1, | |
| 529 | 529 | 0, // Start at the top |
| 530 | 530 | sliderLength, // The width depends on the text |
| 531 | 531 | this->sliderWidth // Fill the whole height | ... | ... |