Marble

DgmlTextureTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "DgmlTextureTagHandler.h"
8 
9 #include <limits>
10 
11 #include "MarbleDebug.h"
12 
13 #include "DgmlElementDictionary.h"
14 #include "DgmlAttributeDictionary.h"
15 #include "DgmlAuxillaryDictionary.h"
16 #include "GeoParser.h"
17 #include "GeoSceneLayer.h"
18 #include "GeoSceneTextureTileDataset.h"
19 
20 namespace Marble
21 {
22 namespace dgml
23 {
24 DGML_DEFINE_TAG_HANDLER(Texture)
25 
26 GeoNode* DgmlTextureTagHandler::parse(GeoParser& parser) const
27 {
28  // Check whether the tag is valid
29  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Texture)));
30 
31  const QString name = parser.attribute(dgmlAttr_name).trimmed();
32 
33  const QString expireStr = parser.attribute(dgmlAttr_expire).trimmed();
34  int expire = std::numeric_limits<int>::max();
35  if ( !expireStr.isEmpty() )
36  expire = expireStr.toInt();
37 
38  GeoSceneTileDataset *texture = nullptr;
39 
40  // Checking for parent item
41  GeoStackItem parentItem = parser.parentElement();
42 
43  // Check parent type and make sure that the dataSet type
44  // matches the backend of the parent layer
45  if ( parentItem.represents(dgmlTag_Layer)
46  && parentItem.nodeAs<GeoSceneLayer>()->backend() == dgmlValue_texture ) {
47 
48  texture = new GeoSceneTextureTileDataset( name );
49  texture->setExpire( expire );
50  parentItem.nodeAs<GeoSceneLayer>()->addDataset( texture );
51  }
52 
53  return texture;
54 }
55 
56 }
57 }
QString trimmed() const const
bool isEmpty() const const
int toInt(bool *ok, int base) const const
Binds a QML item to a specific geodetic location in screen coordinates.
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.