功能实现: 通过代码新建场景,自动添加数据,添加选择集,视图缩放到图层,高亮显示选择集
存在问题:选择集在场景中不是高亮显示,测试在视图中是存在选择集的,没找到选择集不高亮显示的原因
private void addSelectedFeatureToNewScene(DatasetVector datasetVector, String filter, String sceneName) {
IFormScene formScene = (IFormScene) FormUtilities.fireNewWindowEvent(WindowType.SCENE, sceneName);
if (formScene == null){
return ;
}
formScene.openScene("");
Scene scene = formScene.getSceneControl().getScene();
//设置样式
Layer3DSettingVector layer3DSettingVector = new Layer3DSettingVector();
GeoStyle3D geoStyle3D = new GeoStyle3D();
geoStyle3D.setAltitudeMode(AltitudeMode.ABSOLUTE);
geoStyle3D.setFillMode(FillMode3D.FILL);
geoStyle3D.setLineWidth(1.0D);
scene.getLayers().add(datasetVector, layer3DSettingVector, true);
Recordset rt = datasetVector.query(filter, CursorType.STATIC);
int[] ids = new int[rt.getRecordCount()];
rt.moveFirst();
int num = 0;
while (!rt.isEOF()){
ids[num] = rt.getID();
rt.moveNext();
num++;
}
if (rt != null){
rt.close();
rt.dispose();
}
for (int i = 0; i < scene.getLayers().getCount(); i++) {
Layer3DDataset layer3DDataset = (Layer3DDataset)scene.getLayers().get(i);
Selection3D selection3D = layer3DDataset.getSelection();
selection3D.clear();
if(layer3DDataset.getDataset().getName().equals(datasetVector.getName())){
selection3D.addRange(ids);
}
selection3D.updateData();
}
Rectangle2D rectangle2D = datasetVector.getBounds();
double maxZ = datasetVector.getMaxZ();
scene.ensureVisible(rectangle2D, 2000, maxZ);
scene.refresh();
}