Ticket #43: survexred2.patch

File survexred2.patch, 3.4 KB (added by Wookey, 11 years ago)

Hacky openGL surface visualisation (by Stuart Bennet and Wookey)

  • src/gfxcore.cc

    diff -ur survex-1.1.16//src/gfxcore.cc ../survex-1.1.16/src/gfxcore.cc
    old new  
    272272//  Recalculating methods
    273273//
    274274
     275void GfxCore::DoMyBidding(void)
     276{
     277        static LabelInfo *(*evil)[300];
     278        static double minz = 9999999, maxz=-9999999;
     279
     280        if (!evil) {
     281                evil = (LabelInfo *(*)[300])calloc(300 * 300, sizeof(LabelInfo *));
     282                if (!evil) {
     283                        fprintf(stderr, "ARRGH\n");
     284                        return;
     285                }
     286                list<LabelInfo*>::iterator pos = m_Parent->m_Labels.begin();
     287                while (pos != m_Parent->m_Labels.end()) {
     288                        LabelInfo* label = *pos++;
     289
     290                        const wchar_t *str = label->GetText().c_str();
     291                        int n, e, rv;
     292                        //rv = swscanf(str, L"srtm-7x9-m31-482-279-offset.n%de%d", &n, &e);
     293                        rv = swscanf(str, L"srtm.n%de%d", &n, &e);
     294                        if (rv < 2)
     295                                continue;
     296                        evil[n][e] = label;
     297                        if (label->GetZ() > -1000 && label->GetZ() < minz)
     298                                minz = label->GetZ();
     299                        if (label->GetZ() > maxz)
     300                                maxz = label->GetZ();
     301                }
     302        }
     303
     304        double zrange = maxz - minz;
     305        for (int n = 0; n < 299; n++)
     306                for (int e = 0; e < 299; e++)
     307                        if (evil[n][e] && evil[n][e + 1] && evil[n + 1][e] && evil[n + 1][e + 1]) {
     308                                if (evil[n][e]->GetZ() < -1000 || evil[n][e+1]->GetZ() < -1000 || evil[n+1][e]->GetZ() < -1000 || evil[n+1][e+1]->GetZ() < -1000)
     309                                        continue;
     310                                glBegin(GL_QUADS);
     311                                glColor4f(.01f + (evil[n][e]->GetZ() - minz) * .99f / zrange, 0.f, 0.f, 0.67f);
     312                                glVertex3d(evil[n][e]->GetX(), evil[n][e]->GetY(), evil[n][e]->GetZ());
     313                                glColor4f(.01f + (evil[n][e+1]->GetZ() - minz) * .99f / zrange, 0.f, 0.f, 0.67f);
     314                                glVertex3d(evil[n][e+1]->GetX(), evil[n][e+1]->GetY(), evil[n][e+1]->GetZ());
     315                                glColor4f(.01f + (evil[n+1][e+1]->GetZ() - minz) * .99f / zrange, 0.f, 0.f, 0.67f);
     316                                glVertex3d(evil[n+1][e+1]->GetX(), evil[n+1][e+1]->GetY(), evil[n+1][e+1]->GetZ());
     317                                glColor4f(.01f + (evil[n+1][e]->GetZ() - minz) * .99f / zrange, 0.f, 0.f, 0.67f);
     318                                glVertex3d(evil[n+1][e]->GetX(), evil[n+1][e]->GetY(), evil[n+1][e]->GetZ());
     319                                glEnd();
     320                        }
     321}
     322
    275323void GfxCore::SetScale(Double scale)
    276324{
    277325    // Fill the plot data arrays with screen coordinates, scaling the survey
     
    386434            DrawList(LIST_CROSSES);
    387435        }
    388436
     437        DoMyBidding();
     438
    389439        SetIndicatorTransform();
    390440
    391441        // Draw station names.
  • src/gfxcore.h

    diff -ur survex-1.1.16//src/gfxcore.h ../survex-1.1.16/src/gfxcore.h
    old new  
    264264    void Initialise(bool same_file);
    265265    void InitialiseTerrain();
    266266
     267    void DoMyBidding();
     268
    267269    void UpdateBlobs();
    268270    void ForceRefresh();
    269271
  • src/mainfrm.h

    diff -ur survex-1.1.16//src/mainfrm.h ../survex-1.1.16/src/mainfrm.h
    old new  
    210210    list<traverse> traverses;
    211211    list<traverse> surface_traverses;
    212212    list<vector<XSect> > tubes;
    213     list<LabelInfo*> m_Labels;
    214213    Vector3 m_Ext;
    215214    Double m_DepthMin, m_DepthExt;
    216215    int m_DateMin, m_DateExt;
     
    270269
    271270    void InitialiseAfterLoad(const wxString & file);
    272271
     272    list<LabelInfo*> m_Labels;
     273
    273274    void OnMRUFile(wxCommandEvent& event);
    274275    void OpenFile(const wxString& file, wxString survey = wxString());
    275276