viktor.views
ViewError
- exception viktor.views.ViewError¶
Bases:
Exception
Exception applicable for incorrect usage of a view.
SummaryError
- exception viktor.views.SummaryError¶
Bases:
Exception
Exception applicable for incorrect usage of the summary.
DataStatus
- class viktor.views.DataStatus(value)¶
Bases:
enum.Enum
Enumeration of statuses to annotate a DataItem.
- INFO: viktor.views.DataStatus = 'info'¶
- SUCCESS: viktor.views.DataStatus = 'success'¶
- WARNING: viktor.views.DataStatus = 'warning'¶
- ERROR: viktor.views.DataStatus = 'error'¶
DataItem
- class viktor.views.DataItem(label, value, subgroup=None, *, prefix='', suffix='', number_of_decimals=None, status=DataStatus.INFO, status_message='', explanation_label='')¶
-
Constructs an entry that can be used as input of a DataGroup, to fill the data view with results.
The data view is dynamic, which means that a DataItem itself can consist of another DataGroup as subgroup. Both examples are demonstrated below.
Example single entry:
result = "I am a great result" item = DataItem('output 1', result)
Example subgroup:
result = "I am a great result" item = DataItem('output 1', result, subgroup=DataGroup( output11=DataItem('output 1.1', "I can also be a numeric result"), output12=DataItem('output 1.2', 123) ))
The prefix / suffix can potentially change with every call. However, when the result is used in the Summary, the prefix / suffix of the DataItem should be equal to the prefix / suffix of the SummaryItem to maintain a consistent database.
- Parameters
label (
str
) – Description of the value which is shown. e.g: ‘Uc bending’value (
Union
[str
,float
,None
]) – Value of the data. e.g: 0.9subgroup (
Optional
[DataGroup
]) – Optional DataItems grouped together in a DataGroup underneath this DataItem. Maximum depth = 3prefix (
str
) – E.g: €. Should be equal to the prefix of the SummaryItem if linked.suffix (
str
) – E.g: N. Should be equal to the suffix of the SummaryItem if linked.number_of_decimals (
Optional
[int
]) – Number of decimals with which the value is rounded for display.status (
DataStatus
) –Status of value. This controls the formatting of the status_message:
status=DataStatus.INFO: black text
status=DataStatus.SUCCESS: green text
status=DataStatus.WARNING: orange text
status=DataStatus.ERROR: red text
status_message (
str
) – Message which will be shown underneath the value. Color can be formatted with status.explanation_label (
str
) – Optional text which is placed between the label and the value. Could for instance be used for a calculation.
- Raises
TypeError – if number_of_decimals is used on a non-numeric value.
- property subgroup: viktor.views.DataGroup¶
- Return type
DataGroup
- class viktor.views.DataGroup(*args, **kwargs)¶
Bases:
collections.OrderedDict
Container for DataItems, maximum number = 100. They can be added with or without a keyword argument, but they should be equal for all DataItems in the same DataGroup. Keywords are necessary when you want to use a DataItem in the summary (for lookup).
The following two use cases are valid:
d1 = DataGroup( DataItem('item1',0), DataItem('item2',1), ) d2 = DataGroup( a=DataItem('item1',0), b=DataItem('item2',1), )
- Parameters
- Raises
TypeError when positional- and keyword arguments are used together
AttributeError when more than 100 DataItems are used
- classmethod from_data_groups(groups)¶
Constructs a combined DataGroup object from a list of individual DataGroup entries.
Note that is not possible to have multiple DataGroups that share a specific key for a DataItem, e.g. the following will result in an error:
d1 = DataGroup(output_a=DataItem(...)) d2 = DataGroup(output_a=DataItem(...)) d3 = DataGroup.from_data_groups([d1, d2])
- Return type
MapEntityLink
- class viktor.views.MapEntityLink(label, entity_id)¶
-
Represents a link between a feature in a MapView and a specific entity.
Example usage:
gef_link = MapEntityLink('GEF x', gef_entity_id) gef_marker = MapPoint(51.99311570849245, 4.385752379894256, entity_links=[gef_link])
- Parameters
label (
str
) – The text which is shown to the user.entity_id (
int
) – The identifier of the linked object.
MapFeature
- class viktor.views.MapFeature(*, title=None, description=None, color=Color(39, 45, 51), entity_links=None)¶
Bases:
abc.ABC
Warning
Do not use this class directly in an application.
Base class for features that can be shown in a MapView. See the documentation of the subclasses for example implementations.
- Parameters
title (
Optional
[str
]) – Title of a clickable map feature.description (
Optional
[str
]) – Description of a clickable map feature.color (
Color
) – Specifies the color of the map feature.entity_links (
Optional
[List
[MapEntityLink
]]) – When clicking on the map feature, links towards multiple entities can be shown.
MapPoint
- class viktor.views.MapPoint(lat, lon, alt=0, *, icon=None, **kwargs)¶
Bases:
viktor.views.MapFeature
Represents a point on the Earth’s surface described by a latitude/longitude coordinate pair.
Example usage:
marker = MapPoint(51.99311570849245, 4.385752379894256)
- Parameters
lat (
float
) – Latitude.lon (
float
) – Longitude.alt (
float
) – Altitude.icon (
Optional
[str
]) – icon to be shown (default: “pin”). See below for all possible icons.kwargs (
Any
) – SeeMapFeature
for possible kwargs.
List of icons:
- classmethod from_geo_point(point, *, icon=None, **kwargs)¶
Instantiates a MapPoint from the provided GeoPoint.
- Parameters
point (
GeoPoint
) – GeoPoint.icon (
Optional
[str
]) – icon to be shown (default: “pin”). For a complete list of all available markers, see__init__()
kwargs (
Any
) – SeeMapFeature
for possible kwargs.
- Return type
- property lat: float¶
- Return type
float
- property lon: float¶
- Return type
float
- property alt: float¶
- Return type
float
MapPolyline
- class viktor.views.MapPolyline(*points, **kwargs)¶
Bases:
viktor.views.MapFeature
Represents a polyline on the earth’s surface between several latitude/longitude pairs.
Example usage:
line = MapPolyline( MapPoint(51.99311570849245, 4.385752379894256), MapPoint(52.40912125231122, 5.031738281255681), ... )
- Parameters
points (
MapPoint
) – MapPoints with latitude and longitude pair.kwargs (
Any
) – SeeMapFeature
for possible kwargs.
- classmethod from_geo_polyline(polyline, **kwargs)¶
Instantiates a MapPolyline from the provided GeoPolyline.
- Parameters
polyline (
GeoPolyline
) – GeoPolyline.kwargs (
Any
) – SeeMapFeature
for possible kwargs.
- Return type
- property points: List[viktor.views.MapPoint]¶
- Return type
List
[MapPoint
]
MapLine
- class viktor.views.MapLine(start_point, end_point, **kwargs)¶
Bases:
viktor.views.MapPolyline
Represents a line on the earth’s surface between two latitude/longitude pairs.
In case multiple line segments are to be created, a
MapPolyline
may be preferred.Example usage:
line = MapLine( MapPoint(51.99311570849245, 4.385752379894256), MapPoint(52.40912125231122, 5.031738281255681) )
- Parameters
start_point (
MapPoint
) – Map point with latitude and longitude pair.end_point (
MapPoint
) – Map point with latitude and longitude pair.kwargs (
Any
) – SeeMapFeature
for possible kwargs.
- property start_point: viktor.views.MapPoint¶
- Return type
- property end_point: viktor.views.MapPoint¶
- Return type
MapPolygon
- class viktor.views.MapPolygon(points, *, holes=None, **kwargs)¶
Bases:
viktor.views.MapFeature
Represents a polygon on the earth’s surface formed by a set of latitude/longitude pairs.
Example usage:
polygon = MapPolygon([ MapPoint(52.373922404495474, 5.2459716796875), MapPoint(52.10313118589299, 5.3997802734375), MapPoint(52.373922404495474, 5.57281494140625), ])
- Parameters
points (
List
[MapPoint
]) – Map points with latitude and longitude pair. The profile is automatically closed, so it is not necessary to add the start point at the end.holes (
Optional
[List
[MapPolygon
]]) – List of interior polygons which form holes in the exterior polygon.kwargs (
Any
) – SeeMapFeature
for possible kwargs.
- property points: List[viktor.views.MapPoint]¶
- Return type
List
[MapPoint
]
- property holes: List[viktor.views.MapPolygon]¶
- Return type
List
[MapPolygon
]
- classmethod from_geo_polygon(polygon, **kwargs)¶
Instantiates a MapPolygon from the provided GeoPolygon.
- Parameters
polygon (
GeoPolygon
) – GeoPolygon.kwargs (
Any
) – SeeMapFeature
for possible kwargs.
- Return type
MapLegend
- class viktor.views.MapLegend(entries)¶
-
A legend which is placed as an overlay on a map view.
Example usage:
legend = MapLegend([ (Color.from_hex('#0016FF'), "I'm blue"), (Color.from_hex('#FF0000'), "I'm red"), ... ])
- Parameters
entries (
List
[Tuple
[Color
,str
]]) – Items in the legend, defined by color and label.
MapLabel
- class viktor.views.MapLabel(lat, lon, text, scale, *, fixed_size=False)¶
-
Text which is placed as an overlay on the map.
Scale 0-5 is approximately the scale for countries:
Scale 6-10 is approximately the scale for cities:
Scale 11-15 is approximately the scale for neighborhoods and streets
Scale 16-18 is approximately for individual houses.
- Parameters
lat (
float
) – Latitude of text in degrees.lon (
float
) – Longitude of text in degrees.text (
str
) – Text with is displayed on the map.scale (
float
) – Size of the text on an exponential scale. See example in class docstring for estimate.fixed_size (
bool
) – When True, the size of the text is fixed regardless of zoom level (default: False).
Label
- class viktor.views.Label(point, *text, size_factor=1, color=Color(0, 0, 0))¶
-
Text label
- Parameters
- property point: viktor.geometry.Point¶
- Return type
- property text: Union[str, Tuple[str, ...]]¶
- Return type
Union
[str
,Tuple
[str
, …]]
- serialize()¶
- Return type
dict
GeometryResult
- class viktor.views.GeometryResult(geometry, labels=None)¶
-
Container with the results that should be visualized in a GeometryView. This consists of three-dimensional geometry object(s) and optional text labels.
Example viktor.geometry TransformableObject(s):
geometry = Sphere(Point(0, 0), 10) GeometryResult(geometry) # or [obj1, obj2, ...] in case of multiple objects
Example glTF/GLB file:
geometry = File.from_path(Path(__file__).parent / "my_model.gltf") # or .glb GeometryResult(geometry)
Example glTF/GLB file from the internet:
geometry = File.from_url("https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/CesiumMilkTruck/glTF-Binary/CesiumMilkTruck.glb") GeometryResult(geometry)
Example trimesh package:
sphere = trimesh.creation.uv_sphere(10) scene = trimesh.Scene(geometry={'sphere': sphere}) geometry = File() with geometry.open_binary() as w: w.write(trimesh.exchange.gltf.export_glb(scene)) GeometryResult(geometry)
- Parameters
geometry (
Union
[TransformableObject
,Sequence
[TransformableObject
],File
]) – TransformableObject(s) that contain the geometric objects, or a glTF/GLB (v2.0) file (https://en.wikipedia.org/wiki/GlTF).labels (
Optional
[List
[Label
]]) – Text labels that can be used to provide additional information.
GeometryAndDataResult
- class viktor.views.GeometryAndDataResult(geometry, data, labels=None)¶
-
Container with the results that should be visualized in a GeometryAndDataView. This consists of three-dimensional geometry object(s) with optional text labels and data.
Please have a look at GeometryResult for examples.
- Parameters
geometry (
Union
[TransformableObject
,Sequence
[TransformableObject
],File
]) – TransformableObject(s) that contain the geometric objects, or a glTF/GLB (v2.0) file (https://en.wikipedia.org/wiki/GlTF).data (
DataGroup
) – Result data.labels (
Optional
[List
[Label
]]) – Text labels that can be used to provide additional information.
DataResult
PNGResult
- class viktor.views.PNGResult(image)¶
-
Container with the PNG data that should be visualized in a PNGView.
- Parameters
image (
BytesIO
) – BytesIO representation of the PNG content.
PNGAndDataResult
JPGResult
- class viktor.views.JPGResult(image)¶
-
Container with the JPG data that should be visualized in a JPGView.
- Parameters
image (
BytesIO
) – BytesIO representation of the JPG content.
JPGAndDataResult
SVGResult
- class viktor.views.SVGResult(image)¶
-
Container with the SVG data that should be visualized in a SVGView.
- Parameters
image (
StringIO
) – SVG image.
SVGAndDataResult
GeoJSONResult
- class viktor.views.GeoJSONResult(geojson, labels=None, legend=None)¶
-
Container with the GeoJSON data that should be visualized in a GeoJSONView. Optionally a legend and map labels can be included.
The following geojson attributes are supported that can be used for styling of the map elements:
- icon (geometry type ‘Point’ only): icon to be shown (default: “pin”). For a complete list of all available
markers, see
MapPoint
marker-color: the color of a marker *
description: text to show when this item is clicked
stroke: the color of a line as part of a polygon, polyline, or multigeometry *
fill: the color of the interior of a polygon *
- *
color rules: Colors can be in short form “#ace” or long form “#aaccee”, and should contain the # prefix. Colors are interpreted the same as in CSS, in #RRGGBB and #RGB order.
GeoJSONAndDataResult
- class viktor.views.GeoJSONAndDataResult(geojson, data, labels=None, legend=None)¶
-
Container with the GeoJSON data and result data that should be visualized in a GeoJSONAndDataView. Optionally a legend and map labels can be included.
MapResult
- class viktor.views.MapResult(features, labels=None, legend=None)¶
Bases:
viktor.views.GeoJSONResult
Container with the Map data that should be visualized in a MapView. Optionally a legend and map labels can be included.
- Parameters
features (
List
[MapFeature
]) – List that contains the map objects.labels (
Optional
[List
[MapLabel
]]) – Labels that should be placed on the map.legend (
Optional
[MapLegend
]) – Map legend.
MapAndDataResult
- class viktor.views.MapAndDataResult(features, data, labels=None, legend=None)¶
Bases:
viktor.views.GeoJSONAndDataResult
Container with the Map data and result data that should be visualized in a MapAndDataView. Optionally a legend and map labels can be included.
- Parameters
features (
List
[MapFeature
]) – List that contains the map objects.data (
DataGroup
) – Result data.labels (
Optional
[List
[MapLabel
]]) – Labels that should be placed on the map.legend (
Optional
[MapLegend
]) – Map legend.
WebResult
- class viktor.views.WebResult(*, html=None, url=None)¶
-
Container with the data that should be visualized in a WebView. There are two options, which should not be used together:
url: to serve a URL (takes precedence if both are defined)
html: for serving a single html page
- Parameters
html (
Optional
[StringIO
]) – HTML formatted content.url (
Optional
[str
]) – Direct URL.
WebAndDataResult
- class viktor.views.WebAndDataResult(*, html=None, url=None, data=None)¶
-
Container with the web data and result data that should be visualized in a WebAndDataView.
The Web part can be constructed in two ways, which should not be used together:
url: to serve a URL (takes precedence if both are defined)
html: for serving a single html page
- Parameters
html (
Optional
[StringIO
]) – HTML formatted content.url (
Optional
[str
]) – Direct URL.data (
Optional
[DataGroup
]) – Result data.
PlotlyResult
- class viktor.views.PlotlyResult(figure)¶
-
Plotly figure to be visualized in a PlotlyView. The figure can be provided in json-string or dict format.
Example usages:
@PlotlyView("Plotly view", duration_guess=1) def get_plotly_view(self, params, **kwargs): fig = go.Figure( data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])], layout=go.Layout(title=go.layout.Title(text="A Figure Specified By A Graph Object")) ) return PlotlyResult(fig.to_json())
@PlotlyView("Plotly view", duration_guess=1) def get_plotly_view(self, params, **kwargs): fig = { "data": [{"type": "bar", "x": [1, 2, 3], "y": [1, 3, 2]}], "layout": {"title": {"text": "A Figure Specified By Python Dictionary"}} } return PlotlyResult(fig)
- Parameters
figure (
Union
[str
,dict
]) – Plotly figure in str (json) or dict format
PlotlyAndDataResult
- class viktor.views.PlotlyAndDataResult(figure, data)¶
-
Plotly figure to be visualized in a PlotlyAndDataView. The figure can be provided in json-string or dict format.
Example usage:
@PlotlyAndDataView("Plotly and data view", duration_guess=1) def get_plotly_and_data_view(self, params, **kwargs): data_group = ... fig = go.Figure( data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])], layout=go.Layout(title=go.layout.Title(text="A Figure Specified By A Graph Object")) ) return PlotlyAndDataResult(fig.to_json(), data_group)
- Parameters
figure (
Union
[str
,dict
]) – Plotly figure in json-str or dict formatdata (
DataGroup
) – result data
PDFResult
- class viktor.views.PDFResult(*, file=None, url=None)¶
-
PDF document to be visualized in a PDFView. Can be defined from a File object or from a URL (direct-sharing). If both file and url are defined, url takes precedence.
In case of URL: the hosting website must allow for direct accessing for the document to be shown. If this is forbidden (undefined CORS-headers), the document can alternatively be shown via the file argument with a File.from_url(…), in which it is downloaded first and viewed subsequently (indirect-sharing).
Example usages:
From URL (direct-sharing):
PDFResult(url="https://www...")
From URL (indirect-sharing):
f = File.from_url("https://www...") PDFResult(file=f)
From path:
file_path = Path(__file__).parent / 'sample.pdf' PDFResult.from_path(file_path)
- Parameters
file (
Optional
[File
]) – PDF document to viewurl (
Optional
[str
]) – URL of PDF document to view. If accessing the PDF directly from the URL is not allowed by the host website (undefined CORS-headers), this will result in the document not showing up in the view (as an alternative one can use File.from_url).
SummaryItem
- class viktor.views.SummaryItem(label, item_type, source, value_path, *, suffix='', prefix='')¶
-
A summary consists of SummaryItem objects, that define which input / result values should be displayed.
Suppose we have a data view with a controller method ‘data_view’, which returns a DataItem with key ‘output_item_1’. The following summary item can be constructed to refer to this result:
item_1 = SummaryItem('Label', float, 'data_view', 'output_item_1', suffix='N')
Suppose we have a parametrization with a certain parameter defined as geometry.input.length, this can be converted to a summary item by doing:
item_2 = SummaryItem('Length', float, 'parametrization', 'geometry.input.length', suffix='m')
- Parameters
label (
str
) – Text label of the item.item_type (
Type
[Union
[str
,float
]]) – Type of value, options are ‘str’ | ‘float’.source (
str
) – Source from which the input / output should be extracted.value_path (
str
) – Dotted path of value in parametrization / data structure of view. e.g: level1.level2.valuesuffix (
str
) – A prefix will be put behind the value to provide additional information such as units.prefix (
str
) – A prefix will be put in front of the value to provide info such as a dollar sign.
Summary
- class viktor.views.Summary(**items)¶
Bases:
collections.OrderedDict
Summary of resulting data items, which can be used in the summary view of an entity.
Example usage:
class Controller: ... summary = Summary( item_1=SummaryItem(...), item_2=SummaryItem(...), item_3=SummaryItem(...) )
- Parameters
items (
SummaryItem
) – Items that are shown in the summary, with a maximum of 6 items per summary.
View
- class viktor.views.View(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
abc.ABC
Warning
Do not use this class directly in an application.
Base-class of a function decorator that can be used to specify the desired view to be returned. See the subclasses for specific examples of each type of view.
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- abstract property result_type: Type[viktor.views._ViewResult]¶
- Return type
Type
[_ViewResult
]
GeometryView
- class viktor.views.GeometryView(label, duration_guess, *, description=None, update_label=None, view_mode='3D', default_shadow=False, up_axis='Z')¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a geometry view (2D / 3D).
Example usage:
@GeometryView("3D model", duration_guess=2) def get_geometry_view(self, params, **kwargs): # create 3d model ... return GeometryResult(geometry, labels) @GeometryView("2D model", duration_guess=2, view_mode='2D') def get_geometry_view_2d(self, params, **kwargs): # create 2d model ... return GeometryResult(geometry, labels)
- Parameters
label (
str
) – SeeView
.duration_guess (
int
) – SeeView
.description (
Optional
[str
]) – SeeView
.update_label (
Optional
[str
]) – SeeView
.view_mode (
str
) –Sets the view mode:
’3D’: Camera is free to move and user can choose between orthographic and perspective view.
’2D’: Camera is fixed on the xy-plane and view is orthographic.
default_shadow (
bool
) – Show shadow when editor is opened. User can still switch it off.up_axis (
str
) – Upwards pointing axis. Possible options: ‘Y’, ‘Z’ (default: ‘Z’)
- result_type¶
alias of
viktor.views.GeometryResult
DataView
- class viktor.views.DataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a data view that contains calculation result.
Example usage:
@DataView("Cost breakdown", duration_guess=2) def get_data_view(self, params, **kwargs): # calculate data ... return DataResult(data_group)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.DataResult
GeometryAndDataView
- class viktor.views.GeometryAndDataView(label, duration_guess, *, description=None, update_label=None, view_mode='3D', default_shadow=False, up_axis='Z')¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of geometries and data.
Example usage:
@GeometryAndDataView("Model / Cost", duration_guess=2) def get_geometry_data_view(self, params, **kwargs): # create 3d model ... # calculate data ... return GeometryAndDataResult(geometry, data_group, labels=labels)
- Parameters
label (
str
) – SeeView
.duration_guess (
int
) – SeeView
.description (
Optional
[str
]) – SeeView
.update_label (
Optional
[str
]) – SeeView
.view_mode (
str
) –Sets the view mode:
’3D’: Camera is free to move and user can choose between orthographic and perspective view.
’2D’: Camera is fixed on the xy-plane and view is orthographic.
default_shadow (
bool
) – Show shadow when editor is opened. User can still switch it off.up_axis (
str
) – Upwards pointing axis. Possible options: ‘Y’, ‘Z’ (default: ‘Z’)
- result_type¶
alias of
viktor.views.GeometryAndDataResult
SVGView
- class viktor.views.SVGView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return an SVG view.
Example usage:
@SVGView("SVG plot", duration_guess=2) def get_svg_view(self, params, **kwargs): # create svg image ... return SVGResult(svg_image)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.SVGResult
SVGAndDataView
- class viktor.views.SVGAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of an SVG and data.
Example usage:
@SVGAndDataView("Plot / Cost", duration_guess=2) def get_svg_data_view(self, params, **kwargs): # create svg image ... # calculate data ... return SVGAndDataResult(svg_image, data_group)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.SVGAndDataResult
GeoJSONView
- class viktor.views.GeoJSONView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a GeoJSON (geographic data) view.
Example usage:
@GeoJSONView("Map", duration_guess=2) def get_geojson_view(self, params, **kwargs): # create geojson data ... return GeoJSONResult(geojson, labels, legend)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.GeoJSONResult
GeoJSONAndDataView
- class viktor.views.GeoJSONAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of a GeoJSON and data.
Example usage:
@SVGAndDataView("Map / Data", duration_guess=2) def get_geojson_data_view(self, params, **kwargs): # create geojson data ... # calculate data ... return GeoJSONAndDataResult(geojson, data_group, labels, legend)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.GeoJSONAndDataResult
MapView
- class viktor.views.MapView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a Map (geographic data) view.
Example usage:
@MapView("Map", duration_guess=2) def get_map_view(self, params, **kwargs): # create map geometry objects ... return MapResult(features, labels, legend)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.MapResult
MapAndDataView
- class viktor.views.MapAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of a Map and data.
Example usage:
@MapAndDataView("Map / Data", duration_guess=2) def get_map_data_view(self, params, **kwargs): # create map data ... # calculate data ... return MapAndDataResult(features, data_group, labels, legend)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.MapAndDataResult
PNGView
- class viktor.views.PNGView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a PNG view.
Example usage:
@PNGView("PNG image", duration_guess=1) def get_png_view(self, params, **kwargs): # get png image ... return PNGResult(image)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.PNGResult
PNGAndDataView
- class viktor.views.PNGAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of a PNG and data.
Example usage:
@PNGAndDataView("PNG / Data", duration_guess=1) def get_png_data_view(self, params, **kwargs): # get png image ... # calculate data ... return PNGAndDataResult(image, data_group)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.PNGAndDataResult
JPGView
- class viktor.views.JPGView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a JPG view.
Example usage:
@JPGView("JPG image", duration_guess=1) def get_jpg_view(self, params, **kwargs): # get jpg image ... return JPGResult(image)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.JPGResult
JPGAndDataView
- class viktor.views.JPGAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of a JPG and data.
Example usage:
@JPGAndDataView("JPG / Data", duration_guess=1) def get_jpg_data_view(self, params, **kwargs): # get jpg image ... # calculate data ... return JPGAndDataResult(image, data_group)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.JPGAndDataResult
WebView
- class viktor.views.WebView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a web-content view.
Example usage:
@WebView("Hello world", duration_guess=1) def get_web_view(self, params, **kwargs): html = StringIO("<html>Hello world</html>") return WebResult(html=html)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.WebResult
WebAndDataView
- class viktor.views.WebAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of web-content and data.
Example usage:
@WebAndDataView("Web / Data", duration_guess=1) def get_web_data_view(self, params, **kwargs): # get html html = StringIO("<html>Hello world</html>") # calculate data ... return WebAndDataResult(html=html, data=data_group)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.WebAndDataResult
PlotlyView
- class viktor.views.PlotlyView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a PlotlyView.
Example usage:
@PlotlyView("Plotly view", duration_guess=1) def get_plotly_view(self, params, **kwargs): ... return PlotlyResult(figure)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.PlotlyResult
PlotlyAndDataView
- class viktor.views.PlotlyAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a combined view consisting of a PlotlyView and a DataView.
Example usage:
@PlotlyAndDataView("Plotly and data view", duration_guess=1) def get_plotly_and_data_view(self, params, **kwargs): ... return PlotlyAndDataResult(figure, data_group)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.PlotlyAndDataResult
PDFView
- class viktor.views.PDFView(label, duration_guess, *, description=None, update_label=None, **kwargs)¶
Bases:
viktor.views.View
Function decorator to instruct the controller method to return a PDFView.
Example usage:
@PDFView("PDF View", duration_guess=1) def get_pdf_view(self, params, **kwargs): file_path = Path(__file__).parent / 'sample.pdf' return PDFResult.from_path(file_path)
- Parameters
label (
str
) – Name which is shown on tab in interface. e.g: ‘3D Representation’duration_guess (
int
) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.description (
Optional
[str
]) – Show more information to the user through a tooltip on hover (max. 200 characters).update_label (
Optional
[str
]) – Name which is shown on the update button in case of a slow view (max. 30 characters).
- result_type¶
alias of
viktor.views.PDFResult