I am not sure if I came across a bug in the library or a bug in my program. I am hoping that it is a bug in my program but I am having a hard time seeing what code is wrong. I willl describe this the best that I can but please let me know if you need additional information
I have a button on my main program that will allow the user to load in a data file. If the user loads in a data file, the program will rebuild the data structure and, once finished, redraw elements on the canvas. The code that does this is below:
Code: Select all
void model::setParameters(gridPreferences &gridParam, geometryEditor2D &editorParam, std::vector<double> &otherParam)
{
_preferences = gridParam;
_editor = editorParam;
/*
* This is required and must be done after the program copies the editor data structure.
* If the data structure is rebuilt after it is loaded, then all of the addresses will
* become invalided. This is so because the editor data structure is now occupying a
* different block of memory.
*/
_editor.rebuildDataStructure();
_zoomX = otherParam.at(0);
_zoomY = otherParam.at(1);
_cameraX = otherParam.at(2);
_cameraY = otherParam.at(3);
this->Refresh();
}
This function calls the load function which calls the setParameters function and is executed on a button press:
Code: Select all
void MainFrame::onOpenFile(wxCommandEvent &event)
{
wxFileDialog openFileDialog(this, "Open File", "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
if(openFileDialog.ShowModal() != wxID_CANCEL)
{
if(_UIState != systemState::MODEL_DEFINING)
createModelDefiningClient();
wxString appendedTitle = "Omni-FEM - ";
wxString fileName;
std::string tempFileName = openFileDialog.GetFilename().ToStdString();
for(int i = 0; i < (tempFileName.length() - 8); i++)
fileName += wxString(tempFileName[i]);
appendedTitle.append(fileName.ToStdString());
this->SetTitle(appendedTitle);
_saveFilePath = openFileDialog.GetPath();
_problemDefinition.defintionClear();
load(openFileDialog.GetPath().ToStdString());
_model->Refresh(true);
}
}
Code: Select all
void MainFrame::load(string filePath)
{
std::ifstream loadFile(filePath);
if(loadFile.is_open())
{
//modelDefinition temp(this, wxPoint(6, 6), this->GetClientSize(), _problemDefinition, this->GetStatusBar());
//modelDefinition tempDefintion = (*_model);
boost::archive::text_iarchive ia(loadFile);
gridPreferences tempPreferences;
geometryEditor2D tempEditor;
std::vector<double> tempSomething;
ia >> _problemDefinition;
ia >> tempPreferences;
ia >> tempEditor;
ia >> tempSomething;
_model->setParameters(tempPreferences, tempEditor, tempSomething);
_model->Refresh();
}
}
When the draw function was called, it was able to "draw" the elements needed on the canvas. But, after the swap buffer function was executed, my canvas was still blank.
Until, I move my mouse over the canvas.(Each time the mouse moves, an event is generated which will cause the canvas to be refreshed) When this happens, everything is drawn normally.
I am wondering if there is anything in the above code that could interfere with the refresh function? Also, have there been additional bugs where the refresh function does not actually refresh the canvas?
Any help would be appreciated and please, let me know if additional information is needed!