Toon posts:

[c++] Documenten niet geopend en weergegeven

Pagina: 1
Acties:
  • 42 views sinds 30-01-2008

Verwijderd

Topicstarter
Hoi,

Ik heb een programma waarmee je uit een database *.vtk bestanden moet kunnen selecteren en openen, of gewoon met 'open file' 1 uitzoeken en dan openen. Als een *.vtk open met de optie 'file open' is er niks aan de hand, maar zodra ik een database open en uit een tabel 1 selecteer opent hij hem niet.

code van selecteren uit tabel (in TableDialog.cpp):


void CTableDialog::OnOpen()
{
int ret = IDYES;
if (m_list1.GetSelectedCount() > 20)
{
ret = AfxMessageBox("Are you sure you wish to open that many VTK-files?",MB_YESNO|MB_ICONEXCLAMATION);
}
if (ret == IDYES)
{
CString str1;
POSITION pos, eerste;
eerste = m_list1.GetFirstSelectedItemPosition();
pos = m_list1.GetFirstSelectedItemPosition();
//str1.Format(TEXT("%d"),pos);
//AfxMessageBox(str1,NULL,MB_OK);
tempCol.mask = LVCF_TEXT;
tempCol.pszText="";
tempCol.cchTextMax=32;
m_list1.GetColumn(1,&tempCol);
CString str;
str.Format(TEXT("%s"),tempCol.pszText);
//AfxMessageBox(str,NULL,MB_OK);

if (str == "nupaskey")
{
/* bepaal vtk-bestand */
CString fileName="";
CString str2 = tblc.rowList[(int)(pos)-1][1];
fileName.Format(TEXT("log%s.vtk"),str2);

//MessageBox((LPCTSTR)fileName,(CString)("File to Open"),MB_OK);

/* open vtk-bestand */

char *tmpstr = new char[fileName.GetLength()+1];
strcpy(tmpstr,fileName);
strcpy(doc_array[b],tmpstr);
a = b;
b++;
}

/* pak volgende documenten (vanaf de 2e) */
m_list1.GetNextSelectedItem(pos);
while (pos != NULL)
{
tempCol.mask = LVCF_TEXT;
tempCol.pszText="";
tempCol.cchTextMax=32;
m_list1.GetColumn(1,&tempCol);
str.Format(TEXT("%s"),tempCol.pszText);
//AfxMessageBox(str,NULL,MB_OK);
if (str == "nupaskey")
{
/* bepaal vtk-bestand */
CString fileName="";
CString str2 = tblc.rowList[(int)(pos)-1][1];
fileName.Format(TEXT("log%s.vtk"),str2);
//MessageBox((LPCTSTR)fileName,(CString)("File to Open"),MB_OK);

/* open vtk-bestand */
char *tmpstr = new char[fileName.GetLength()+1];
strcpy(tmpstr,fileName);
strcpy(doc_array[b],tmpstr);
a = b;
b++;
}
m_list1.GetNextSelectedItem(pos); //3e en volgende
}

CSampleDoc().ToonVTK(doc_array);

}// end if (ret == IDYES)
}


code van open file + ToonVTK(in SampleDoc.cpp):


BOOL CSampleDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!vtkMFCDocument::OnOpenDocument(lpszPathName))
{
return FALSE;
}

tmp = const_cast < char* > ( lpszPathName );
strcpy(doc_array[a],tmp);
ToonVTK(doc_array);
a++;
return TRUE;
}

BOOL CSampleDoc::ToonVTK(char doc_array[10][96])
{

for(int i = 0; i <= a; i++)
{
this->reader[i] = vtkPolyDataReader::New();
this->reader[i]->SetFileName(doc_array[i]);

this->filter[i] = vtkTriangleFilter::New();
this->filter[i]->SetInput(this->reader[i]->GetOutput());

this->mapper[i] = vtkPolyDataMapper::New();
this->mapper[i]->SetInput(this->filter[i]->GetOutput());

this->actor[i] = vtkActor::New();
this->actor[i]->SetMapper(this->mapper[i]);
this->actor[i]->VisibilityOn();

this->Props->AddItem(this->actor[i]);
}


for(int j = 0; j <= a; j++)
{
this->reader[j]->Delete();
this->filter[j]->Delete();
this->mapper[j]->Delete();
this->actor[j]->Delete();
}

return TRUE;
}


Ik begrijp niet waarom het met 'open file' wel lukt, maar met selecteren niet. Als ik de 'for lus' van ToonVTK in OnOpenDocument zet en in TableDialog daar naar verwijs, lukt het selecteren en dan openen wel.

Iemand een idee waar ik de fout in ga?

BVD

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

De vorige 20 keer hebben we je al richting FAQ gewezen over hoe je een net topic opent. En weer verneuk je het, dus op slot. Als je al eens zou beginnen met OS en framework te vermelden en [code] tags te gebruiken zou je topic grotere overlevingskans hebben... :/

Professionele website nodig?


  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

Voor de volledigheid wederom de link naar de quickstart... :Z

Professionele website nodig?


Dit topic is gesloten.