void ProcessingThread::setROI(QRect roi) { QMutexLocker locker(&processingMutex); currentROI.x = roi.x(); currentROI.y = roi.y(); currentROI.width = roi.width(); currentROI.height = roi.height(); processingBuffer.clear(); magnificator.clearBuffer(); int levels = magnificator.calculateMaxLevels(roi); locker.unlock(); emit maxLevels(levels); }
//Star operator overloading, providing a random crossing of the current //unit and the one provided in parameter. Unit Unit::operator*(const Unit& unit)const { std::vector<int> maxLevels(7); for(int i = 0; i < 7; ++i) { maxLevels[i] = std::max(capacities_[i]->getLevel(), unit.getCapacity(i)->getLevel()); } int gA = this->getLevel(); int gB = unit.getLevel(); int global = gA; if(gA!=gB) global = std::min(gA, gB)+std::rand()%std::abs(gA-gB); std::vector<int> levels(7,0); while(global) { int index = std::rand()%7; if(levels[index]<maxLevels[index]) { levels[index]++; global--; } } std::string ia; std::string ia2 = tree->getCode(); if (std::rand() % 2) { ia = std::string(iaCode_); std::string oldIaPart = getRandomIATreeSonCode(); size_t start_pos = ia.find(oldIaPart); if (start_pos != std::string::npos) { ia.replace(start_pos, oldIaPart.size(), unit.getRandomIATreeSonCode()); } } else { ia = std::string(unit.getIACode()); std::string oldIaPart = unit.getRandomIATreeSonCode(); size_t start_pos = ia.find(oldIaPart); if (start_pos != std::string::npos) { ia.replace(start_pos, oldIaPart.size(), getRandomIATreeSonCode()); } } return Unit(ia,levels); }