void BifurcationPlot::OnMouseUp(wxMouseEvent& evt) {
    /**
    *   Event handler for the mouse up on a plot.
    *   This event sets the zoom level for a graph based on the zooming
    *   rectangle drawn by the user.  This function will only zoom if the
    *   rectangle is greater than min_delta and if zooming will not give
    *   a higher difference between the minimum and maximum values than
    *   MAX_ZOOM.  
    *
    *   Overrides the MouseUp function in ChaosPlot because the
    *   Bifurcation plots the largest X value on the left.
    */
    const int min_delta = 10;
    const int MAX_ZOOM = 50;
    if(mouse_dragging == true) {
        int x_position = evt.m_x;
        int y_position = evt.m_y;
        if(drag_start.x < x_position && x_position - drag_start.x > min_delta) {
            int tmp2 = xToValue(drag_start.x);
            int tmp1 = xToValue(x_position);
            if(tmp2 - tmp1 > MAX_ZOOM) {
                smallest_x_value = tmp1;
                largest_x_value = tmp2;
                ChaosSettings::BifRedraw = true;
            }
        } else if(drag_start.x > x_position && drag_start.x - x_position > min_delta) {
            int tmp2 = xToValue(x_position);
            int tmp1 = xToValue(drag_start.x);
            if(tmp2 - tmp1 > MAX_ZOOM) {
                smallest_x_value = tmp1;
                largest_x_value = tmp2;
                ChaosSettings::BifRedraw = true;
            }
        }
        
        if(drag_start.y < y_position && y_position - drag_start.y > min_delta) {
            int tmp1 = yToValue(drag_start.y);
            int tmp2 = yToValue(y_position);
            if(tmp1 - tmp2 > MAX_ZOOM) {
                largest_y_value = tmp1;
                smallest_y_value = tmp2;
                ChaosSettings::BifRedraw = true;
            }
        } else if(drag_start.y > y_position && drag_start.y - y_position > min_delta) {
            int tmp1 = yToValue(y_position);
            int tmp2 = yToValue(drag_start.y);
            if(tmp1 - tmp2 > MAX_ZOOM) {
                largest_y_value = tmp1;
                smallest_y_value = tmp2;
                ChaosSettings::BifRedraw = true;
            }
        }
        
        wxLogMessage(wxT("y_min: %d\ny_max: %d"), smallest_y_value, largest_y_value);
        wxLogMessage(wxT("x_min: %d\nx_max: %d"), smallest_x_value, largest_x_value);
    }
    mouse_dragging = false;
}
示例#2
0
void ChaosPlot::OnMouseUp(wxMouseEvent& evt) {
    /**
    *   Event handler for the mouse up on a plot.
    *   This event sets the zoom level for a graph based on the zooming
    *   rectangle drawn by the user.  This function will only zoom if the
    *   rectangle is greater than min_delta and if zooming will not give
    *   a higher difference between the minimum and maximum values than
    *   MAX_ZOOM.
    */
    const int min_delta = 10;
    const int MAX_ZOOM = 25;
    if(mouse_dragging == true) {
        int x_position = evt.m_x;
        int y_position = evt.m_y;
        
        // Initialize tmp1 and tmp2
        int tmp1 = smallest_x_value;
        int tmp2 = largest_x_value;

        // Calculate the new X boundaries based on if we dragged a box left or right
        if(drag_start.x < x_position && x_position - drag_start.x > min_delta) {
            tmp1 = xToValue(drag_start.x);
            tmp2 = xToValue(x_position);
        } else if(drag_start.x > x_position && drag_start.x - x_position > min_delta) {
            tmp1 = xToValue(x_position);
            tmp2 = xToValue(drag_start.x);
        }
        
        // Update the largest and smallest values
        if(tmp2 - tmp1 > MAX_ZOOM) {
            smallest_x_value = tmp1;
            largest_x_value = tmp2;
        }
        
        // Calculate the new Y boundaries based on if we dragged a box up or down
        if(drag_start.y < y_position && y_position - drag_start.y > min_delta) {
            tmp1 = yToValue(drag_start.y);
            tmp2 = yToValue(y_position);
        } else if(drag_start.y > y_position && drag_start.y - y_position > min_delta) {
            tmp1 = yToValue(y_position);
            tmp2 = yToValue(drag_start.y);
        }
        
        // Update the largest and smallest values
        if(tmp1 - tmp2 > MAX_ZOOM) {
            largest_y_value = tmp1;
            smallest_y_value = tmp2;
        }
        
        // Write zoom to log
        wxLogMessage(wxT("y_min: %d\ny_max: %d"), smallest_y_value, largest_y_value);
        wxLogMessage(wxT("x_min: %d\nx_max: %d"), smallest_x_value, largest_x_value);
    }
    
    // We aren't dragging the mouse anymore
    mouse_dragging = false;
}
示例#3
0
bool Slider::onMouseMove(int x, int y)
{
    if (dragging) {
        float val = xToValue(x - left - dragOffsetX);
        if (val != value) {
            value = val;
            draw();
        }
        return true;
    }

    bool in = isInRect(x, y, left, top, width, height);
    if (in) {
        int sliderX = valueToX(value);
        bool hl = isInRect(x, y, left + sliderX, top, height, height);
        if (hl != highlight) {
            highlight = hl;
            draw();
        }
    } else if (highlight) {
        highlight = false;
        draw();
    }
    return in;
}
void BifurcationPlot::UpdateStatusBar(int m_x, int m_y) {
    /**
    *   Updates the cursor information in the status bar
    */
    float x, y;
    if(statusBar) {
        x = xToValue(m_x);
        y = yToValue(m_y);
        
        if(ChaosSettings::YAxisLabels == ChaosSettings::Y_AXIS_VBIAS) {
            y = y*3.3/1024 - 1.2;
        } else if(ChaosSettings::YAxisLabels == ChaosSettings::Y_AXIS_VGND) {
            y = y*3.3/1024;
        }
        
        if(ChaosSettings::BifXAxis == ChaosSettings::RESISTANCE_VALUES) {
            x = libchaos_mdacToResistance((int)x)/1000;
            statusBar->SetStatusText(wxString::Format(wxT("(%.3fk,%.3f)"),
                                        x,
                                        y), 3);
        } else {
            statusBar->SetStatusText(wxString::Format(wxT("(%d,%.3f)"),
                                        (int)x,
                                        y), 3);
        }
    }
}
void BifurcationPlot::OnDblClick(wxMouseEvent& evt) {
    /**
    *   Event Handler for double clicking on the graph.
    *   Sets the MDAC value to the location click on the graph.
    */
    int value = xToValue(evt.m_x);
    libchaos_setMDACValue(value);
}
示例#6
0
void ChaosPlot::UpdateStatusBar(int m_x, int m_y) {
    /**
    *   Updates the cursor information in the status bar
    */
    float x, y;
    if(statusBar) {
        x = xToValue(m_x);
        y = yToValue(m_y);
        
        if(ChaosSettings::YAxisLabels == ChaosSettings::Y_AXIS_VBIAS) {
            y = y*3.3/1024 - 1.2;
        } else if(ChaosSettings::YAxisLabels == ChaosSettings::Y_AXIS_VGND) {
            y = y*3.3/1024;
        }
        
        statusBar->SetStatusText(wxString::Format(wxT("(%.3f,%.3f)"),
                                        x,
                                        y), 3);
    }
}