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
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