bool KML::isHandled(std::string const& elem) const { if( isLeaf(elem) || isFeature(elem) || isFeatureContainer(elem) || isContainer(elem) || isRest(elem) ) { return true; } return false; }
void Starsphere::keyboardPressEvent(const AbstractGraphicsEngine::KeyBoardKey keyPressed) { switch(keyPressed) { case KeyS: setFeature(STARS, isFeature(STARS) ? false : true); break; case KeyC: setFeature(CONSTELLATIONS, isFeature(CONSTELLATIONS) ? false : true); break; case KeyO: setFeature(OBSERVATORIES, isFeature(OBSERVATORIES) ? false : true); break; case KeyX: setFeature(XRAYS, isFeature(XRAYS) ? false : true); break; case KeyP: setFeature(PULSARS, isFeature(PULSARS) ? false : true); break; case KeyR: setFeature(SNRS, isFeature(SNRS) ? false : true); break; case KeyG: setFeature(GLOBE, isFeature(GLOBE) ? false : true); break; case KeyA: setFeature(AXES, isFeature(AXES) ? false : true); break; case KeyI: setFeature(SEARCHINFO, isFeature(SEARCHINFO) ? false : true); break; case KeyL: setFeature(LOGO, isFeature(LOGO) ? false : true); break; case KeyM: setFeature(MARKER, isFeature(MARKER) ? false : true); break; default: break; } }
/** * Rendering routine: this is what does the drawing: */ void Starsphere::render(const double timeOfDay) { GLfloat xvp, yvp, zvp, vp_theta, vp_phi, vp_rad; GLfloat Zrot = 0.0, Zobs=0.0; double revs, t, dt = 0; static double start_time=-1.0, last_time=-1.0; // Calculate the real time t since we started (or reset) and the // time dt since the last render() call. Both may be useful // for timing animations. Note that time_of_day is dtime(). if (start_time < 0.0) start_time = timeOfDay; t = timeOfDay - start_time; if (last_time < 0.0) last_time = timeOfDay - 0.01; dt = timeOfDay - last_time; last_time = timeOfDay; // remember for next time // Now determine the rotation angle based on the time since start // It is negative to get the rotation direction correct (the sun // rises in the East, so the sky sphere rotates E to W). Zrot = t*rotation_speed/60.0; revs = Zrot/360.0; Zrot = -360.0 * (revs - (int)revs); // and start drawing... glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // now draw the scene... glLoadIdentity(); // Vary the viewpoint with both a long period wobble of the elevation // of the view and a longer period zoom in/out that might even penetrate // The starsphere for a brief time. Increase the power in pow(,) to // make the visit inside briefer. vp_theta = 90.0 - viewpt_elev + wobble_amp*sin(PI2*t/(wobble_period*60.0)); vp_phi = viewpt_azimuth; vp_rad = viewpt_radius - zoom_amp*sin(PI2*t/(zoom_period*60.0)); if(vp_rad <0.0) vp_rad = 0.0; // cannot pass origin (confusing) // TRIED THIS TOO: -zoom_amp*pow(fabs(sin(PI2*t/(zoom_period*60.0))),3); xvp = vp_rad * SIN(vp_theta) * SIN(vp_phi); zvp = vp_rad * SIN(vp_theta) * COS(vp_phi); yvp = vp_rad * COS(vp_theta); gluLookAt(xvp, yvp, zvp, // eyes position 0.0, 0.0, 0.0, // looking toward here 0.0, 1.0, 0.0); // which way is up? y axis! // draw axes before any rotation so they stay put if (isFeature(AXES)) glCallList(Axes); // draw the sky sphere, with rotation: glPushMatrix(); glRotatef(Zrot - rotation_offset, 0.0, 1.0, 0.0); // stars, pulsars, supernovae, grid if (isFeature(STARS)) glCallList(Stars); if (isFeature(PULSARS)) glCallList(Pulsars); if (isFeature(SNRS)) glCallList(SNRs); if (isFeature(CONSTELLATIONS)) glCallList(Constellations); if (isFeature(GLOBE)) glCallList(sphGrid); // observatories move an extra 15 degrees/hr since they were drawn if (isFeature(OBSERVATORIES)) { glPushMatrix(); Zobs = (timeOfDay - m_ObservatoryDrawTimeLocal) * 15.0/3600.0; glRotatef(Zobs, 0.0, 1.0, 0.0); glCallList(LLOmarker); glCallList(LHOmarker); glCallList(GEOmarker); glCallList(VIRGOmarker); renderAdditionalObservatories(); glPopMatrix(); } // draw the search marker (gunsight) if (isFeature(MARKER)) { if(m_RefreshSearchMarker) { make_search_marker(m_CurrentRightAscension, m_CurrentDeclination, 0.5); m_RefreshSearchMarker = false; } else { glCallList(SearchMarker); } } glPopMatrix(); // draw 2D vectorized HUD if(isFeature(LOGO) || isFeature(SEARCHINFO)) { // disable depth testing since we're in 2D mode glDisable(GL_DEPTH_TEST); // enable textured fonts glEnable(GL_TEXTURE_2D); // save current state glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, m_CurrentWidth, 0, m_CurrentHeight, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); if (isFeature(LOGO)) renderLogo(); if (isFeature(SEARCHINFO)) renderSearchInformation(); // restore original state glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); // disable font textures glDisable(GL_TEXTURE_2D); // enable depth testing since we're leaving 2D mode glEnable(GL_DEPTH_TEST); } SDL_GL_SwapBuffers(); }
void KMLVector::findLayers(KMLNode* poNode, int bKeepEmptyContainers) { bool bEmpty = true; // Start with the trunk if( nullptr == poNode ) { nNumLayers_ = 0; poNode = poTrunk_; } if( isFeature(poNode->getName()) || isFeatureContainer(poNode->getName()) || ( isRest(poNode->getName()) && poNode->getName().compare("kml") != 0 ) ) { return; } else if( isContainer(poNode->getName()) ) { for( int z = 0; z < (int) poNode->countChildren(); z++ ) { if( isContainer(poNode->getChild(z)->getName()) ) { findLayers(poNode->getChild(z), bKeepEmptyContainers); } else if( isFeatureContainer(poNode->getChild(z)->getName()) ) { bEmpty = false; } } if( bKeepEmptyContainers && poNode->getName() == "Folder" ) { if (!bEmpty) poNode->eliminateEmpty(this); } else if(bEmpty) { return; } Nodetype nodeType = poNode->getType(); if( bKeepEmptyContainers || isFeature(Nodetype2String(nodeType)) || nodeType == Mixed || nodeType == MultiGeometry || nodeType == MultiPoint || nodeType == MultiLineString || nodeType == MultiPolygon) { poNode->setLayerNumber(nNumLayers_++); papoLayers_ = static_cast<KMLNode**>( CPLRealloc(papoLayers_, nNumLayers_ * sizeof(KMLNode*)) ); papoLayers_[nNumLayers_ - 1] = poNode; } else { CPLDebug( "KML", "We have a strange type here for node %s: %s", poNode->getName().c_str(), Nodetype2String(poNode->getType()).c_str() ); } } else { CPLDebug( "KML", "There is something wrong! Define KML_DEBUG to see details"); if( CPLGetConfigOption("KML_DEBUG", nullptr) != nullptr ) print(); } }