def test_widgets_with_arucos():
    from sandbox.sensor import Sensor
    from sandbox.markers import MarkerDetection
    from sandbox import _calibration_dir, _test_data
    sensor = Sensor(calibsensor=_calibration_dir + 'sensorcalib.json',
                    name='kinect_v2')
    aruco = MarkerDetection(sensor=sensor)
    color = np.load(_test_data['test'] + 'frame1.npz')['arr_1']
    geo_model = create_example_model(name='Anticline')
    module = GemPyModule(geo_model=geo_model,
                         extent=sensor.extent,
                         box=[1000, 800],
                         load_examples=True,
                         name_example=['Horizontal_layers'])
    module.setup(sensor.get_frame())
    pytest.sb_params['marker'] = aruco.update(frame=color)
    sb_params = module.update(pytest.sb_params)
    sb_params['fig'].show()
    module.set_section_dict((10, 10), (500, 500), "Section1")
    module.set_section_dict((100, 100), (500, 10), "Section2")

    module.set_borehole_dict((500, 500), "borehole3")
    module.set_borehole_dict((900, 500), "borehole4")
    module._get_polygon_data()
    aruco.plot_aruco(sb_params['ax'], sb_params['marker'])
    sb_params['fig'].show()
    widgets = module.show_widgets()
    widgets.show()
def test_borehole_widgets():
    geo_model = create_example_model('Horizontal_layers')
    module = GemPyModule(geo_model=geo_model,
                         extent=extent,
                         box=[1000, 800],
                         load_examples=False)
    module.setup(frame)
    module.set_borehole_dict((500, 500), "borehole3")
    module.set_borehole_dict((900, 500), "borehole4")
    module._get_polygon_data()
    widget = module.widget_boreholes()
    widget.show()
def test_polygon_data_boreholes():
    geo_model = create_example_model('Horizontal_layers')
    module = GemPyModule(geo_model=geo_model,
                         extent=extent,
                         box=[1000, 800],
                         load_examples=False)
    module.setup(frame)

    module.set_borehole_dict((10, 20), "borehole1")
    module.set_borehole_dict((500, 500), "borehole2")

    module._get_polygon_data()

    print(module.borehole_tube, module.colors_bh)
def test_widgets():
    module = GemPyModule(geo_model=None,
                         extent=extent,
                         box=[1000, 800],
                         load_examples=True)
    module.setup(frame)

    #fig, ax = plt.subplots()
    #depth, ax, size, cmap, norm, df = module.update(frame, ax, extent)
    module.setup(frame)

    module.set_section_dict((10, 10), (500, 500), "Section1")
    module.set_section_dict((100, 100), (500, 10), "Section2")

    module.set_borehole_dict((500, 500), "borehole3")
    module.set_borehole_dict((900, 500), "borehole4")

    widgets = module.show_widgets()

    widgets.show()
def test_update_borehole_panel():
    geo_model = create_example_model('Horizontal_layers')
    module = GemPyModule(geo_model=geo_model,
                         extent=extent,
                         box=[1000, 800],
                         load_examples=False)
    module.setup(frame)

    module.set_borehole_dict((10, 20), "borehole1")
    module.set_borehole_dict((200, 500), "borehole2")
    module.set_borehole_dict((500, 500), "borehole3")
    module.set_borehole_dict((900, 500), "borehole4")
    module.set_borehole_dict((100, 100), "borehole5")
    module.set_borehole_dict((600, 700), "borehole6")
    module.set_borehole_dict((200, 800), "borehole7")
    module.set_borehole_dict((800, 200), "borehole8")

    module._get_polygon_data()

    vtk = module.show_boreholes_panel()
    vtk.show()
def test_plot_boreholes():
    #geo_model = create_example_model('Fault')
    geo_model = create_example_model('Horizontal_layers')
    module = GemPyModule(geo_model=geo_model,
                         extent=extent,
                         box=[1000, 800],
                         load_examples=False)
    module.setup(frame)

    module.set_borehole_dict((10, 20), "borehole1")
    module.set_borehole_dict((200, 500), "borehole2")
    module.set_borehole_dict((500, 500), "borehole3")
    module.set_borehole_dict((900, 500), "borehole4")
    module.set_borehole_dict((100, 100), "borehole5")
    module.set_borehole_dict((600, 700), "borehole6")
    module.set_borehole_dict((200, 150), "borehole7")
    module.set_borehole_dict((150, 200), "borehole8")

    module._get_polygon_data()

    p = module.plot_boreholes(notebook=False, background=False)
    p.show()
def test_borehole_dict():
    geo_model = create_example_model('Horizontal_layers')
    module = GemPyModule(geo_model=geo_model,
                         extent=extent,
                         box=[1000, 800],
                         load_examples=False)
    module.setup(frame)

    module.set_borehole_dict((10, 20), "borehole1")
    module.set_borehole_dict((500, 500), "borehole2")

    print(module.borehole_dict)

    assert module.borehole_dict == {
        'borehole1': ([10, 20], [11, 20], [5, 5]),
        'borehole2': ([500, 500], [501, 500], [5, 5])
    }

    module.remove_borehole_dict("borehole2")

    print(module.borehole_dict)

    assert module.borehole_dict == {'borehole1': ([10, 20], [11, 20], [5, 5])}