2121from typing import Optional
2222import webbrowser
2323
24- from ansys .dynamicreporting .core .adr_utils import in_ipynb
24+ from ansys .dynamicreporting .core .adr_utils import build_query_url , in_ipynb
2525from ansys .dynamicreporting .core .utils import report_objects
2626
2727try :
@@ -75,7 +75,7 @@ def __find_report_obj__(self) -> bool:
7575 success = True
7676 return success
7777
78- def visualize (self , new_tab : bool = False ) -> None :
78+ def visualize (self , new_tab : bool = False , filter : str = "" ) -> None :
7979 """
8080 Render the report.
8181
@@ -86,6 +86,10 @@ def visualize(self, new_tab: bool = False) -> None:
8686 is a Jupyter notebook. The default is ``False``, in which case the
8787 report is rendered in the current location. If the environment is
8888 not a Jupyter notebook, the report is always rendered in a new tab.
89+ filter : str, optional
90+ Query string for filtering. The default is ``""``. The syntax corresponds
91+ to the syntax for Ansys Dynamic Reporting. For more information, see
92+ _Query Expressions in the documentation for Ansys Dynamic Reporting.
8993
9094 Returns
9195 -------
@@ -110,16 +114,23 @@ def visualize(self, new_tab: bool = False) -> None:
110114 else :
111115 display (iframe )
112116 else :
113- url = self .get_url ()
117+ url = self .get_url (filter = filter )
114118 if url == "" : # pragma: no cover
115119 self .service .logger .error ("Error: could not obtain url for report" )
116120 else :
117121 webbrowser .open_new (url )
118122
119- def get_url (self ) -> str :
123+ def get_url (self , filter : str = "" ) -> str :
120124 """
121125 Get the URL corresponding to the report.
122126
127+ Parameters
128+ ----------
129+ filter : str, optional
130+ Query string for filtering. The default is ``""``. The syntax corresponds
131+ to the syntax for Ansys Dynamic Reporting. For more information, see
132+ _Query Expressions in the documentation for Ansys Dynamic Reporting.
133+
123134 Returns
124135 -------
125136 str
@@ -157,9 +168,10 @@ def get_url(self) -> str:
157168 )
158169 return ""
159170 url += "usemenus=off"
171+ url += build_query_url (self .service .logger , filter )
160172 return url
161173
162- def get_iframe (self , width : int = 1000 , height : int = 800 ):
174+ def get_iframe (self , width : int = 1000 , height : int = 800 , filter : str = "" ):
163175 """
164176 Get the iframe object corresponding to the report.
165177
@@ -169,6 +181,10 @@ def get_iframe(self, width: int = 1000, height: int = 800):
169181 Width of the iframe object. The default is ``1000``.
170182 height : int, optional
171183 Height of the iframe object. The default is ``800``.
184+ filter : str, optional
185+ Query string for filtering. The default is ``""``. The syntax corresponds
186+ to the syntax for Ansys Dynamic Reporting. For more information, see
187+ _Query Expressions in the documentation for Ansys Dynamic Reporting.
172188
173189 Returns
174190 -------
@@ -187,7 +203,7 @@ def get_iframe(self, width: int = 1000, height: int = 800):
187203 report_iframe = my_report.get_iframe()
188204 """
189205 if "IPython.display" in sys .modules :
190- url = self .get_url ()
206+ url = self .get_url (filter = filter )
191207 iframe = IFrame (src = url , width = width , height = height )
192208 else :
193209 iframe = None
0 commit comments