This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
ParaViewVizService.java
216 lines (193 loc) · 5.59 KB
/
ParaViewVizService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*******************************************************************************
* Copyright (c) 2015- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jordan Deyton
*******************************************************************************/
package org.eclipse.ice.viz.service.paraview;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import org.eclipse.ice.client.widgets.viz.service.IPlot;
import org.eclipse.ice.viz.service.AbstractVizService;
import org.eclipse.ice.viz.service.connections.ConnectionManager;
import org.eclipse.ice.viz.service.connections.ConnectionTable;
import org.eclipse.ice.viz.service.connections.IConnectionAdapter;
import org.eclipse.ice.viz.service.connections.paraview.ParaViewConnectionAdapter;
import org.eclipse.ice.viz.service.preferences.CustomScopedPreferenceStore;
import com.kitware.vtk.web.VtkWebClient;
/**
* This class is responsible for providing a service to connect to (or launch)
* either local or remote instances of ParaView. Additionally, it can be used to
* create {@link ParaViewPlot}s that can render files supported by ParaView
* within an SWT-based application.
*
* @see ParaViewPlot
* @see #createPlot(URI)
*
* @author Jordan Deyton
*
*/
public class ParaViewVizService extends AbstractVizService {
/**
* The current instance of the viz service. This instance was created when
* the OSGi viz service was instantiated.
*/
private static ParaViewVizService instance;
/**
* The manager for all of the ParaView connections.
*/
private final ConnectionManager<VtkWebClient> connections;
/**
* The default constructor.
* <p>
* <b>Note:</b> Only OSGi should call this method!
* </p>
*/
public ParaViewVizService() {
// Update the instance to point to this viz service (there should be
// only one).
instance = this;
// Set up the connection manager.
connections = new ConnectionManager<VtkWebClient>() {
@Override
protected CustomScopedPreferenceStore getPreferenceStore() {
return (CustomScopedPreferenceStore) ParaViewVizService.this
.getPreferenceStore();
}
@Override
protected ConnectionTable createConnectionTable() {
return new ConnectionTable();
}
@Override
protected IConnectionAdapter<VtkWebClient> createConnectionAdapter() {
return new ParaViewConnectionAdapter();
}
};
return;
}
/**
* Gets the current instance of the viz service. This instance was created
* by OSGi.
* <p>
* <b>Note:</b> This method is only intended to be used by the preference
* page to notify the service when the preferences have changed.
* </p>
*
* @return The current instance of the viz service.
*/
protected static ParaViewVizService getInstance() {
return instance;
}
/**
* This method notifies the service that the preferences have changed. Any
* connections that have changed should be reset.
*/
protected void preferencesChanged(Map<String, String> changedKeys,
Set<String> addedKeys, Set<String> removedKeys) {
connections.preferencesChanged(changedKeys, addedKeys, removedKeys);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#getName()
*/
@Override
public String getName() {
return "ParaView";
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#getVersion()
*/
@Override
public String getVersion() {
return "0.0";
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#
* hasConnectionProperties()
*/
@Override
public boolean hasConnectionProperties() {
// Do nothing yet.
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#
* getConnectionProperties()
*/
@Override
public Map<String, String> getConnectionProperties() {
// Do nothing yet.
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#
* setConnectionProperties(java.util.Map)
*/
@Override
public void setConnectionProperties(Map<String, String> props) {
// Do nothing yet.
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#connect()
*/
@Override
public boolean connect() {
return connections.connect();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.client.widgets.viz.service.IVizService#disconnect()
*/
@Override
public boolean disconnect() {
return connections.disconnect();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ice.client.widgets.viz.service.IVizService#createPlot(java
* .net.URI)
*/
@Override
public IPlot createPlot(URI file) throws Exception {
ParaViewPlot plot = null;
if (canOpenFile(file)) {
plot = new ParaViewPlot(this, file);
connections.addClient(plot);
}
return plot;
}
/**
* Determines whether or not the file can be opened in ParaView.
*
* @param file
* The file to test. May be {@code null}.
* @return True if the file can be opened in VisIt, false otherwise.
*/
private boolean canOpenFile(URI file) {
boolean canOpen = false;
if (file != null) {
// TODO
}
return canOpen;
}
}