bool Calibrator::finish(int width, int height)
{
    if (get_numclicks() != NUM_POINTS) {
        return false;
    }

    // new axis origin and scaling
    // based on old_axys: inversion/swapping is relative to the old axis
    XYinfo new_axis(old_axys);


    // calculate average of clicks
    float x_min = (clicked.x[UL] + clicked.x[LL])/2.0;
    float x_max = (clicked.x[UR] + clicked.x[LR])/2.0;
    float y_min = (clicked.y[UL] + clicked.y[UR])/2.0;
    float y_max = (clicked.y[LL] + clicked.y[LR])/2.0;

    // Should x and y be swapped?
    if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
        new_axis.swap_xy = !new_axis.swap_xy;
        std::swap(x_min, y_min);
        std::swap(x_max, y_max);
    }

    // the screen was divided in num_blocks blocks, and the touch points were at
    // one block away from the true edges of the screen.
    const float block_x = width/(float)num_blocks;
    const float block_y = height/(float)num_blocks;
    // rescale these blocks from the range of the drawn touchpoints to the range of the 
    // actually clicked coordinates, and substract/add from the clicked coordinates
    // to obtain the coordinates corresponding to the edges of the screen.
    float scale_x = (x_max - x_min)/(width - 2*block_x);
    x_min -= block_x * scale_x;
    x_max += block_x * scale_x;
    float scale_y = (y_max - y_min)/(height - 2*block_y);
    y_min -= block_y * scale_y;
    y_max += block_y * scale_y;
    
    // now, undo the transformations done by the X server, to obtain the true 'raw' value in X.
    // The raw value was scaled from old_axis to the device min/max, and from the device min/max
    // to the screen min/max
    // hence, the reverse transformation is from screen to old_axis
    x_min = scaleAxis(x_min, old_axys.x.max, old_axys.x.min, width, 0);
    x_max = scaleAxis(x_max, old_axys.x.max, old_axys.x.min, width, 0);
    y_min = scaleAxis(y_min, old_axys.y.max, old_axys.y.min, height, 0);
    y_max = scaleAxis(y_max, old_axys.y.max, old_axys.y.min, height, 0);


    // round and put in new_axis struct
    new_axis.x.min = round(x_min); new_axis.x.max = round(x_max);
    new_axis.y.min = round(y_min); new_axis.y.max = round(y_max);

    if (output_type == OUTYPE_CALIBRATOR) {
        output_restore_file(width, height);
    }

    // finish the data, driver/calibrator specific
    return finish_data(new_axis);
}
Exemple #2
0
void Renderer::drawMirrorPass(){
	glVectord mirrorNormal = coverPos.getMirrorNormal();
	glVectord mirrorCenter = coverPos.getMirrorCenter();

	double mirrorDist; // distance from origin
	mirrorDist = mirrorCenter * mirrorNormal;
	glVectord mirrorPos = mirrorDist * mirrorNormal;

	glVectord scaleAxis(1, 0, 0);
	glVectord rotAxis = scaleAxis.cross(mirrorNormal);
	double rotAngle = rad2deg(scaleAxis.intersectAng(mirrorNormal));
	rotAngle = -2*rotAngle;

	if (glFogCoordf){
		GLfloat	fogColor[4] = {GetRValue(cfgPanelBg)/255.0f, GetGValue(cfgPanelBg)/255.0f, GetBValue(cfgPanelBg)/255.0f, 1.0f};
		glFogfv(GL_FOG_COLOR, fogColor);
		glEnable(GL_FOG);
	}

	glPushMatrix();
		glTranslated(2 * mirrorPos.x, 2 * mirrorPos.y, 2 * mirrorPos.z);
		glScalef(-1.0f, 1.0f, 1.0f);
		glRotated(rotAngle, rotAxis.x, rotAxis.y, rotAxis.z);

		drawCovers();
	glPopMatrix();
	
	if (glFogCoordf)
		glDisable(GL_FOG);
}
void SingleCellViewGraphPanelPlotWidget::scaleAxes(const QPoint &pPoint,
                                                   const double &pScalingFactorX,
                                                   const double &pScalingFactorY)
{
    // Rescale our X axis, but only if zooming in/out is possible on that axis

    QPointF originPoint = canvasPoint(pPoint);

    double newMinX = minX();
    double newMaxX = maxX();
    double newMinY = minY();
    double newMaxY = maxY();
    bool scaledAxisX = scaleAxis(pScalingFactorX, mCanZoomInX, mCanZoomOutX,
                                 originPoint.x(), newMinX, newMaxX);
    bool scaledAxisY = scaleAxis(pScalingFactorY, mCanZoomInY, mCanZoomOutY,
                                 originPoint.y(), newMinY, newMaxY);
    // Note: we want to make both calls to scaleAxis(), hence they are not part
    //       of the if() statement below...

    if (scaledAxisX || scaledAxisY)
        setAxes(newMinX, newMaxX, newMinY, newMaxY);
}
Exemple #4
0
	void QMSMFormMemory::setupCurves() {
		uint32_t ticks			= mpDataHandler->getSettings().mNumberOfTicks-1;
		
		double *x				= mpDataHandler->getMeasurement().mpX->getDataPtr();
		double *y_memory_cpu	= mpDataHandler->getMeasurement().mpYMemoryCpu->getDataPtr();
		double *y_swap_cpu		= mpDataHandler->getMeasurement().mpYSwapCpu->getDataPtr();
		double *y_memory_gpu	= mpDataHandler->getMeasurement().mpYMemoryGpu->getDataPtr();
		double *y_memory_mic	= mpDataHandler->getMeasurement().mpYMemoryMic->getDataPtr();
				
		mpCurveMemoryCpu->setRawData(x, y_memory_cpu, ticks);
		mpCurveSwapCpu->setRawData(x, y_swap_cpu, ticks);
		mpCurveMemoryGpu->setRawData(x, y_memory_gpu, ticks);
		mpCurveMemoryMic->setRawData(x, y_memory_mic, ticks);
				
		scaleAxis(x[ticks-1], mpDataHandler->getSettings().mYAxisMemoryMin, mpDataHandler->getSettings().mYAxisMemoryMax);
	}
Exemple #5
0
	void QMSMFormPower::setupCurves() {
		uint32_t ticks			= mpDataHandler->getSettings().mNumberOfTicks-1;
		
		double *x				= mpDataHandler->getMeasurement().mpX->getDataPtr();
		double *y_power_cpu_0	= mpDataHandler->getMeasurement().mpYPowerCpu0->getDataPtr();
		double *y_power_cpu_1	= mpDataHandler->getMeasurement().mpYPowerCpu1->getDataPtr();
		double *y_power_gpu		= mpDataHandler->getMeasurement().mpYPowerGpu->getDataPtr();
		double *y_power_fpga	= mpDataHandler->getMeasurement().mpYPowerFpga->getDataPtr();
		double *y_power_mic		= mpDataHandler->getMeasurement().mpYPowerMic->getDataPtr();
		double *y_power_system	= mpDataHandler->getMeasurement().mpYPowerSystem->getDataPtr();
		
		mpCurvePowerCpu0->setRawData(x, y_power_cpu_0, ticks);
		mpCurvePowerCpu1->setRawData(x, y_power_cpu_1, ticks);
		mpCurvePowerGpu->setRawData(x, y_power_gpu, ticks);
		mpCurvePowerFpga->setRawData(x, y_power_fpga, ticks);
		mpCurvePowerMic->setRawData(x, y_power_mic, ticks);
		mpCurvePowerSystem->setRawData(x, y_power_system, ticks);
		
		scaleAxis(x[ticks-1], mpDataHandler->getSettings().mYAxisPowerMin, mpDataHandler->getSettings().mYAxisPowerMax);
	}
Exemple #6
0
	void QMSMFormClock::setupCurves() {
		uint32_t ticks				= mpDataHandler->getSettings().mNumberOfTicks-1;
		
		double *x					= mpDataHandler->getMeasurement().mpX->getDataPtr();
		double *y_clock_cpu_0		= mpDataHandler->getMeasurement().mpYClockCpu0->getDataPtr();
		double *y_clock_cpu_1		= mpDataHandler->getMeasurement().mpYClockCpu1->getDataPtr();
		double *y_clock_gpu_core	= mpDataHandler->getMeasurement().mpYClockGpuCore->getDataPtr();
		double *y_clock_gpu_mem		= mpDataHandler->getMeasurement().mpYClockGpuMem->getDataPtr();
		double *y_clock_mic_core	= mpDataHandler->getMeasurement().mpYClockMicCore->getDataPtr();
		double *y_clock_mic_mem		= mpDataHandler->getMeasurement().mpYClockMicMem->getDataPtr();
		
		mpCurveClockCpu0->setRawData(x, y_clock_cpu_0, ticks);
		mpCurveClockCpu1->setRawData(x, y_clock_cpu_1, ticks);
		mpCurveClockGpuCore->setRawData(x, y_clock_gpu_core, ticks);
		mpCurveClockGpuMemory->setRawData(x, y_clock_gpu_mem, ticks);
		mpCurveClockMicCore->setRawData(x, y_clock_mic_core, ticks);
		mpCurveClockMicMemory->setRawData(x, y_clock_mic_mem, ticks);
		
		scaleAxis(x[ticks-1], mpDataHandler->getSettings().mYAxisClockMin, mpDataHandler->getSettings().mYAxisClockMax);
	}
	void QMSMFormTemperature::setupCurves() {
		uint32_t ticks			= mpDataHandler->getSettings().mNumberOfTicks-1;
		
		double *x				= mpDataHandler->getMeasurement().mpX->getDataPtr();
		double *y_temp_cpu_0	= mpDataHandler->getMeasurement().mpYTempCpu0->getDataPtr();
		double *y_temp_cpu_1	= mpDataHandler->getMeasurement().mpYTempCpu1->getDataPtr();
		double *y_temp_gpu		= mpDataHandler->getMeasurement().mpYTempGpu->getDataPtr();
		double *y_temp_fpga_m	= mpDataHandler->getMeasurement().mpYTempFpgaM->getDataPtr();
		double *y_temp_fpga_i	= mpDataHandler->getMeasurement().mpYTempFpgaI->getDataPtr();
		double *y_temp_mic		= mpDataHandler->getMeasurement().mpYTempMicDie->getDataPtr();
		double *y_temp_system	= mpDataHandler->getMeasurement().mpYTempSystem->getDataPtr();
		
		mpCurveTempCpu0->setRawData(x, y_temp_cpu_0, ticks);
		mpCurveTempCpu1->setRawData(x, y_temp_cpu_1, ticks);
		mpCurveTempGpu->setRawData(x, y_temp_gpu, ticks);
		mpCurveTempFpgaM->setRawData(x, y_temp_fpga_m, ticks);
		mpCurveTempFpgaI->setRawData(x, y_temp_fpga_i, ticks);
		mpCurveTempMic->setRawData(x, y_temp_mic, ticks);
		mpCurveTempSystem->setRawData(x, y_temp_system, ticks);
		
		scaleAxis(x[ticks-1], mpDataHandler->getSettings().mYAxisTempMin, mpDataHandler->getSettings().mYAxisTempMax);
	}
Exemple #8
0
// From Calibrator but with evdev specific invertion option
// KEEP IN SYNC with Calibrator::finish() !!
bool CalibratorEvdev::finish(int width, int height)
{
    if (get_numclicks() != NUM_POINTS) {
        return false;
    }

    // new axis origin and scaling
    // based on old_axys: inversion/swapping is relative to the old axis
    XYinfo new_axis(old_axys);


    // calculate average of clicks
    float x_min = (clicked.x[UL] + clicked.x[LL])/2.0;
    float x_max = (clicked.x[UR] + clicked.x[LR])/2.0;
    float y_min = (clicked.y[UL] + clicked.y[UR])/2.0;
    float y_max = (clicked.y[LL] + clicked.y[LR])/2.0;


    // When evdev detects an invert_X/Y option,
    // it performs the following *crazy* code just before returning
    // val = (pEvdev->absinfo[i].maximum - val + pEvdev->absinfo[i].minimum);
    // undo this crazy step before doing the regular calibration routine
    if (old_axys.x.invert) {
        x_min = width - x_min;
        x_max = width - x_max;
        // avoid invert_x property from here on,
        // the calibration code can handle this dynamically!
        new_axis.x.invert = false;
    }
    if (old_axys.y.invert) {
        y_min = height - y_min;
        y_max = height - y_max;
        // avoid invert_y property from here on,
        // the calibration code can handle this dynamically!
        new_axis.y.invert = false;
    }
    // end of evdev inversion crazyness


    // Should x and y be swapped?
    if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
        new_axis.swap_xy = !new_axis.swap_xy;
        std::swap(x_min, y_min);
        std::swap(x_max, y_max);
    }

    // the screen was divided in num_blocks blocks, and the touch points were at
    // one block away from the true edges of the screen.
    const float block_x = width/(float)num_blocks;
    const float block_y = height/(float)num_blocks;
    // rescale these blocks from the range of the drawn touchpoints to the range of the 
    // actually clicked coordinates, and substract/add from the clicked coordinates
    // to obtain the coordinates corresponding to the edges of the screen.
    float scale_x = (x_max - x_min)/(width - 2*block_x);
    x_min -= block_x * scale_x;
    x_max += block_x * scale_x;
    float scale_y = (y_max - y_min)/(height - 2*block_y);
    y_min -= block_y * scale_y;
    y_max += block_y * scale_y;
    
    // now, undo the transformations done by the X server, to obtain the true 'raw' value in X.
    // The raw value was scaled from old_axis to the device min/max, and from the device min/max
    // to the screen min/max
    // hence, the reverse transformation is from screen to old_axis
    x_min = scaleAxis(x_min, old_axys.x.max, old_axys.x.min, width, 0);
    x_max = scaleAxis(x_max, old_axys.x.max, old_axys.x.min, width, 0);
    y_min = scaleAxis(y_min, old_axys.y.max, old_axys.y.min, height, 0);
    y_max = scaleAxis(y_max, old_axys.y.max, old_axys.y.min, height, 0);


    // round and put in new_axis struct
    new_axis.x.min = round(x_min); new_axis.x.max = round(x_max);
    new_axis.y.min = round(y_min); new_axis.y.max = round(y_max);

    // finish the data, driver/calibrator specific
    return finish_data(new_axis);
}