There is error in project configuration in previous commits. This commit is fixed it. Dict caching and one-time drawing of letters now working
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
typedef std::map<wxString,wxString> DictType;
|
||||
typedef std::vector< std::vector<wxChar> > GridType;
|
||||
typedef std::vector< std::vector<wxChar> > CurGridType;
|
||||
// Первый индекс -- длина слова
|
||||
// Fisrt index is a word length
|
||||
typedef std::vector< std::vector<wxString> > AllWordsType;
|
||||
typedef std::set< size_t > UsedWords;
|
||||
|
||||
@@ -181,10 +181,10 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid,
|
||||
|
||||
void generateCross(GridType &grid, DictType &dict, std::vector<wxString> &words_out){
|
||||
AllWordsType words;
|
||||
for (DictType::iterator i = dict.begin(); i != dict.end(); ++i){
|
||||
if (words.size() <= i->first.size())
|
||||
words.resize(i->first.size() + 2);
|
||||
words.at(i->first.size()).push_back(i->first);
|
||||
for (DictType::iterator it = dict.begin(); it != dict.end(); ++it){
|
||||
if (words.size() <= it->first.size())
|
||||
words.resize(it->first.size() + 2);
|
||||
words.at(it->first.size()).push_back(it->first);
|
||||
}
|
||||
for (size_t i = 2; i < words.size(); ++i){
|
||||
wxLogDebug(wxT("Number of words with length %d is %d"), i, words.at(i).size());
|
||||
|
||||
@@ -130,26 +130,25 @@ void MainFrame::SetGridImage(GridType &grid, size_t w) {
|
||||
for (size_t i = 0; i < winfos.size(); ++i){
|
||||
if (winfos.at(i).direct == true){
|
||||
for (size_t j = 0; j < winfos.at(i).len; ++j)
|
||||
if ( !usedCells.at(i).at(j) ){
|
||||
if ( !usedCells.at(winfos.at(i).x+j).at(winfos.at(i).y) ) {
|
||||
dc.DrawText(
|
||||
_words.at(i).at(j),
|
||||
sq_w*(winfos.at(i).x+j) + sq_w*0.24,
|
||||
sq_h*winfos.at(i).y
|
||||
);
|
||||
usedCells.at(i).at(j) = true;
|
||||
usedCells.at(winfos.at(i).x+j).at(winfos.at(i).y) = true;
|
||||
}
|
||||
} else {
|
||||
for (size_t j = 0; j < winfos.at(i).len; ++j)
|
||||
if ( !usedCells.at(i).at(j) ){
|
||||
if ( !usedCells.at(winfos.at(i).x).at(winfos.at(i).y+j) ) {
|
||||
dc.DrawText(
|
||||
_words.at(i).at(j),
|
||||
sq_w*winfos.at(i).x + sq_w*0.24,
|
||||
sq_h*(winfos.at(i).y+j)
|
||||
);
|
||||
usedCells.at(i).at(j) = true;
|
||||
usedCells.at(winfos.at(i).x).at(winfos.at(i).y+j) = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,11 +205,11 @@ void MainFrame::OnbtnGenerateClick(wxCommandEvent &event) {
|
||||
SetGridImage(grid);
|
||||
_words.clear();
|
||||
}
|
||||
catch (...){
|
||||
catch ( ... ){
|
||||
tOutput->Clear();
|
||||
this->Refresh();
|
||||
wxMessageBox( wxT("Не могу создать кроссворд"), wxT("Ошибка"), wxICON_ERROR );
|
||||
}
|
||||
this->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<Compiler Options="-g;-O0;-Wall;$(shell wx-config --cxxflags --unicode=yes --debug=yes)" C_Options="-g;-O0;-Wall;$(shell wx-config --cxxflags --unicode=yes --debug=yes)" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0"/>
|
||||
<Linker Options="$(shell wx-config --debug=yes --libs --unicode=yes)" Required="yes"/>
|
||||
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="no"/>
|
||||
<General OutputFile="$(IntermediateDirectory)/$(ProjectName).out" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
||||
<General OutputFile="$(IntermediateDirectory)/$(ProjectName).out" IntermediateDirectory="./Debug" Command="./$(ProjectName).out" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
||||
<![CDATA[]]>
|
||||
</Environment>
|
||||
@@ -85,7 +85,7 @@
|
||||
</Compiler>
|
||||
<Linker Options="-s;$(shell wx-config --debug=no --libs --unicode=yes)" Required="yes"/>
|
||||
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="no"/>
|
||||
<General OutputFile="$(IntermediateDirectory)/$(ProjectName).out" IntermediateDirectory="../Release" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="yes" IsEnabled="yes"/>
|
||||
<General OutputFile="$(IntermediateDirectory)/$(ProjectName).out" IntermediateDirectory="../Release" Command="./$(ProjectName).out" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="yes" IsEnabled="yes"/>
|
||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
||||
<![CDATA[]]>
|
||||
</Environment>
|
||||
|
||||
Reference in New Issue
Block a user