void Clear() { Rectangle(0, 0, GetWidth(), GetHeight()); }
uint32 DiTexture::GetHeightInBlocks(void) const { return DiPixelBox::GetFormatNumBlocks(GetHeight(), GetFormat()); }
Vector2 ScenePanel::ConvertToPanelSpace(const Point2D& point) const { return Vector2(point.X, GetHeight() - point.Y); }
void VideoContext::SetVideo(const wxString &filename) { Reset(); if (filename.empty()) { VideoOpen(); return; } bool commit_subs = false; try { provider.reset(new ThreadedFrameSource(filename, this)); videoProvider = provider->GetVideoProvider(); videoFile = filename; // Check that the script resolution matches the video resolution int sx = context->ass->GetScriptInfoAsInt("PlayResX"); int sy = context->ass->GetScriptInfoAsInt("PlayResY"); int vx = GetWidth(); int vy = GetHeight(); // If the script resolution hasn't been set at all just force it to the // video resolution if (sx == 0 && sy == 0) { context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx)); context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy)); commit_subs = true; } // If it has been set to something other than a multiple of the video // resolution, ask the user if they want it to be fixed else if (sx % vx != 0 || sy % vy != 0) { switch (OPT_GET("Video/Check Script Res")->GetInt()) { case 1: // Ask to change on mismatch if (wxYES != wxMessageBox( wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vx, vy, sx, sy), _("Resolution mismatch"), wxYES_NO | wxCENTER, context->parent)) break; // Fallthrough to case 2 case 2: // Always change script res context->ass->SetScriptInfo("PlayResX", wxString::Format("%d", vx)); context->ass->SetScriptInfo("PlayResY", wxString::Format("%d", vy)); commit_subs = true; break; default: // Never change break; } } keyFrames = videoProvider->GetKeyFrames(); // Set frame rate videoFPS = videoProvider->GetFPS(); if (ovrFPS.IsLoaded()) { int ovr = wxMessageBox(_("You already have timecodes loaded. Would you like to replace them with timecodes from the video file?"), _("Replace timecodes?"), wxYES_NO | wxICON_QUESTION); if (ovr == wxYES) { ovrFPS = agi::vfr::Framerate(); ovrTimecodeFile.clear(); } } // Set aspect ratio double dar = videoProvider->GetDAR(); if (dar > 0) SetAspectRatio(4, dar); // Set filename config::mru->Add("Video", STD_STR(filename)); StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath()); // Show warning wxString warning = videoProvider->GetWarning(); if (!warning.empty()) wxMessageBox(warning, "Warning", wxICON_WARNING | wxOK); hasSubtitles = false; if (filename.Right(4).Lower() == ".mkv") { hasSubtitles = MatroskaWrapper::HasSubtitles(filename); } provider->LoadSubtitles(context->ass); VideoOpen(); KeyframesOpen(keyFrames); TimecodesOpen(FPS()); } catch (agi::UserCancelException const&) { } catch (agi::FileNotAccessibleError const& err) { config::mru->Remove("Video", STD_STR(filename)); wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER); } catch (VideoProviderError const& err) { wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER); } if (commit_subs) context->ass->Commit(_("change script resolution"), AssFile::COMMIT_SCRIPTINFO); else JumpToFrame(0); }
void PLWEMFDecoder::GetImage (PLBmpBase & Bmp) { HPALETTE hpal = NULL; LPLOGPALETTE plogpal (0); if (GetBitsPerPixel() == 8) { plogpal = (LPLOGPALETTE)new PLBYTE[sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 256)]; memset(plogpal,0x0,sizeof(LOGPALETTE) + sizeof(PALETTEENTRY)*256); plogpal->palVersion = 0x300; plogpal->palNumEntries = 256; if (plogpal == NULL) { PLASSERT(false); raiseError (PL_ERRNO_MEMORY,"Cannot allocate palette."); } UINT pe = GetEnhMetaFilePaletteEntries(m_hemf, 0, NULL); GetEnhMetaFilePaletteEntries(m_hemf, pe, plogpal->palPalEntry); } // Setup a logical palette for our memory dc and also a // paintlib compatible palette for the paintlib bitmap PLPixel32 pPal[256]; if (plogpal) { for (UINT i = 0; i < 256; i++) { pPal[i] = *(PLPixel32*)&plogpal->palPalEntry[i]; } if ( 0 != (hpal = CreatePalette((LPLOGPALETTE)plogpal)) ) { m_holdpal = SelectPalette(m_memdc, hpal, false); RealizePalette(m_memdc); } Bmp.SetPalette(pPal); delete [] plogpal; } // Play the metafile into the device context // First, setup a bounding rectangle and fill // the memory dc with white (some metafiles only // use a black pen to draw and have no actual fill // color set, This would cause a black on black // painting which is rather useless RECT rc; rc.left = rc.top = 0; rc.bottom = GetHeight(); rc.right = GetWidth(); FillRect(m_memdc,&rc,(HBRUSH)GetStockObject(WHITE_BRUSH)); // Heeere we go.... /*BOOL bres =*/ PlayEnhMetaFile(m_memdc,m_hemf,&rc); // Finally, convert the Windows bitmap into a paintlib bitmap PLWinBmp& winbmp = dynamic_cast<PLWinBmp&>(Bmp); BITMAPINFO* pBMI = (BITMAPINFO*)winbmp.GetBMI(); //PLBYTE* pBits = (PLBYTE*)winbmp.GetBits(); if (GetBitsPerPixel() == 8) { GetDIBits(m_dc, m_bm, 0, GetHeight(), winbmp.GetBits(), pBMI, DIB_RGB_COLORS); } else { GetDIBits(m_dc, m_bm, 0, GetHeight(), winbmp.GetBits(), pBMI, DIB_PAL_COLORS); } }
wxRealPoint ExplainShape::GetStartPoint() { wxRealPoint rp(GetX() + GetBitmap().GetWidth() / 2.0 + ARROWMARGIN, GetY() - (GetHeight() - GetBitmap().GetHeight()) / 2.); return rp; }
void CPowerupRapidFire::Render(void) { CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance(); pTM->Draw(GetImageID(),GetCollisionRect().left,GetCollisionRect().top,1.5f,1.5f,&rPowerupRect,GetWidth() / 2, GetHeight() /2,0,D3DCOLOR_XRGB(255,255,255)); }
unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture) { CSFML_CALL_RETURN(renderTexture, GetHeight(), 0); }
bool HierarchyTreePlatformNode::Save(YamlNode* node, bool saveAll) { YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP); platform->Set(WIDTH_NODE, GetWidth()); platform->Set(HEIGHT_NODE, GetHeight()); MultiMap<String, YamlNode*> &platformsMap = node->AsMap(); platformsMap.erase(GetName().toStdString()); platformsMap.insert(std::pair<String, YamlNode*>(GetName().toStdString(), platform)); ActivatePlatform(); MultiMap<String, YamlNode*> &platformMap = platform->AsMap(); YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY); platformMap.erase(SCREENS_NODE); platformMap.insert(std::pair<String, YamlNode*>(SCREENS_NODE, screens)); YamlNode* aggregators = new YamlNode(YamlNode::TYPE_MAP); platformMap.erase(AGGREGATORS_NODE); platformMap.insert(std::pair<String, YamlNode*>(AGGREGATORS_NODE, aggregators)); // Add the Localization info - specific for each Platform. SaveLocalization(platform); QString platformFolder = GetPlatformFolder(); QDir dir; dir.mkpath(platformFolder); bool result = true; //save aggregators node before save screens for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin(); iter != GetChildNodes().end(); ++iter) { HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter); if (!node) continue; QString path = QString(SCREEN_PATH).arg(platformFolder).arg(node->GetName()); MultiMap<String, YamlNode*> &aggregatorsMap = aggregators->AsMap(); YamlNode* aggregator = new YamlNode(YamlNode::TYPE_MAP); result &= node->Save(aggregator, path, saveAll); aggregatorsMap.erase(node->GetName().toStdString()); aggregatorsMap.insert(std::pair<String, YamlNode*>(node->GetName().toStdString(), aggregator)); } for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin(); iter != GetChildNodes().end(); ++iter) { HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter); if (node) continue; //skip aggregators HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter); if (!screenNode) continue; QString screenPath = QString(SCREEN_PATH).arg(platformFolder).arg(screenNode->GetName()); result &= screenNode->Save(screenPath, saveAll); screens->AddValueToArray(screenNode->GetName().toStdString()); } return result; }
// ---------------------------------------------------------------------------- // Name : ResetPosition() // Desc : // ---------------------------------------------------------------------------- void CUISelectResource::ResetPosition( PIX pixMinI, PIX pixMinJ, PIX pixMaxI, PIX pixMaxJ ) { SetPos( ( pixMaxI + pixMinI - GetWidth() ) / 2, ( pixMaxJ + pixMinJ - GetHeight() ) / 2 ); }
// ---------------------------------------------------------------------------- // Name : AdjustPosition() // Desc : // ---------------------------------------------------------------------------- void CUISelectResource::AdjustPosition( PIX pixMinI, PIX pixMinJ, PIX pixMaxI, PIX pixMaxJ ) { if( m_nPosX < pixMinI || m_nPosX + GetWidth() > pixMaxI || m_nPosY < pixMinJ || m_nPosY + GetHeight() > pixMaxJ ) ResetPosition( pixMinI, pixMinJ, pixMaxI, pixMaxJ ); }
/** * Render text, clip it within the bounds of this Canvas. */ void TextAutoClipped(int x, int y, const TCHAR *t) { if (x < (int)GetWidth() && y < (int)GetHeight()) DrawClippedText(x, y, GetWidth() - x, GetHeight() - y, t); }
void Clear(const Brush &brush) { DrawFilledRectangle(0, 0, GetWidth(), GetHeight(), brush); }
void Clear(const Color color) { DrawFilledRectangle(0, 0, GetWidth(), GetHeight(), color); }
wxSize wxStatusBarUniv::DoGetBestSize() const { return wxSize(100, GetHeight()); }
bool CxImage::Load(const char * filename, DWORD imagetype) #endif //bool CxImage::Load(const char * filename, DWORD imagetype) { /*FILE* hFile; //file handle to read the image if ((hFile=fopen(filename,"rb"))==NULL) return false; bool bOK = Decode(hFile,imagetype); fclose(hFile);*/ #ifdef XBMC int iWidthSave = iWidth; int iHeightSave = iHeight; #endif /* automatic file type recognition */ bool bOK = false; if ( GetTypeIndexFromId(imagetype) ){ FILE* hFile; //file handle to read the image #ifdef WIN32 if ((hFile=_tfopen(filename,_T("rb")))==NULL) return false; // For UNICODE support #else if ((hFile=fopen(filename,"rb"))==NULL) return false; #endif #ifdef XBMC bOK = Decode(hFile,imagetype,iWidth,iHeight); if (imagetype != CXIMAGE_FORMAT_JPG) { iWidth = GetWidth(); iHeight = GetHeight(); } #else bOK = Decode(hFile,imagetype); #endif fclose(hFile); if (bOK) return bOK; } char szError[256]; strcpy(szError,info.szLastError); //save the first error // if failed, try automatic recognition of the file... FILE* hFile; #ifdef WIN32 if ((hFile=_tfopen(filename,_T("rb")))==NULL) return false; // For UNICODE support #else if ((hFile=fopen(filename,"rb"))==NULL) return false; #endif #ifdef XBMC bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN,iWidth,iHeight); if (imagetype != CXIMAGE_FORMAT_JPG) { iWidth = GetWidth(); iHeight = GetHeight(); } #else bOK = Decode(hFile,CXIMAGE_FORMAT_UNKNOWN); #endif fclose(hFile); if (!bOK && imagetype > 0) strcpy(info.szLastError,szError); //restore the first error return bOK; }
void wxStatusBarUniv::DoSetSize(int x, int y, int width, int WXUNUSED(height), int sizeFlags) { wxStatusBarBase::DoSetSize(x, y, width, GetHeight(), sizeFlags); }
//////////////////////////////////////////////////////////////////////////////// // // FUNCTION: GetSize // // DESCRIPTION: Returns Width and Height object // // RETURNS: // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // N T ALMOND 29012002 1.0 Origin // //////////////////////////////////////////////////////////////////////////////// SIZE ImageEx::GetSize() { SIZE size={GetWidth(), GetHeight()}; return size; }
wxRealPoint ExplainShape::GetEndPoint(int kidNo) { wxRealPoint rp(GetX() - GetBitmap().GetWidth() / 2.0 - ARROWMARGIN, GetY() - (GetHeight() - GetBitmap().GetHeight()) / 2. + (kidCount > 1 ? GetBitmap().GetHeight() * 2. / 3. * kidNo / (2 * kidCount - 2) : 0 )); return rp; }
Dialog::Dialog(UIWindow *parent, float width, float height, bool modal) : UIWindow(/*modal ? new Substrate(parent) :*/ parent) , _mouseX(0) , _mouseY(0) , _easyMove(false) { SetTexture("ui/window", false); Resize(width, height); Move(std::floor((parent->GetWidth() - GetWidth()) / 2), std::floor((parent->GetHeight() - GetHeight()) / 2)); SetDrawBorder(true); SetDrawBackground(true); GetManager().SetFocusWnd(this); }
static void OrderedDitherBitmap(CSBitmap* pBitmap, int ditherAmount) { const int DITHERSIZE = 16; // A sixteen by sixteen dither table holds 256 values, // which is enough to give us dither values from zero to 255. int DitherArray[DITHERSIZE][DITHERSIZE] = { { 0, 128, 32, 160, 8, 136, 40, 168, 2, 130, 34, 162, 10, 138, 42, 170, }, {192, 64, 224, 96, 200, 72, 232, 104, 194, 66, 226, 98, 202, 74, 234, 106, }, {48, 176, 16, 144, 56, 184, 24, 152, 50, 178, 18, 146, 58, 186, 26, 154, }, {240, 112, 208, 80, 248, 120, 216, 88, 242, 114, 210, 82, 250, 122, 218, 90, }, {12, 140, 44, 172, 4, 132, 36, 164, 14, 142, 46, 174, 6, 134, 38, 166, }, {204, 76, 236, 108, 196, 68, 228, 100, 206, 78, 238, 110, 198, 70, 230, 102, }, {60, 188, 28, 156, 52, 180, 20, 148, 62, 190, 30, 158, 54, 182, 22, 150, }, {252, 124, 220, 92, 244, 116, 212, 84, 254, 126, 222, 94, 246, 118, 214, 86, }, { 3, 131, 35, 163, 11, 139, 43, 171, 1, 129, 33, 161, 9, 137, 41, 169, }, {195, 67, 227, 99, 203, 75, 235, 107, 193, 65, 225, 97, 201, 73, 233, 105, }, {51, 179, 19, 147, 59, 187, 27, 155, 49, 177, 17, 145, 57, 185, 25, 153, }, {243, 115, 211, 83, 251, 123, 219, 91, 241, 113, 209, 81, 249, 121, 217, 89, }, {15, 143, 47, 175, 7, 135, 39, 167, 13, 141, 45, 173, 5, 133, 37, 165, }, {207, 79, 239, 111, 199, 71, 231, 103, 205, 77, 237, 109, 197, 69, 229, 101, }, {63, 191, 31, 159, 55, 183, 23, 151, 61, 189, 29, 157, 53, 181, 21, 149, }, {255, 127, 223, 95, 247, 119, 215, 87, 253, 125, 221, 93, 245, 117, 213, 85, }, }; assert(GetChannels(pBitmap) >= 3); assert(ditherAmount > 0); if (ditherAmount == 1) return; // There's nothing to do. // ditherAmount is the number of distinct values we want to be adding // to our bitmap. We want these values to range between zero and // ditherAmount - 1, so we subtract one here. ditherAmount -= 1; int NumChannels = GetChannels(pBitmap); // Before we do the dithering we have to get the values into the right // range. We then have to subtract off ditherAmount / 2 which is half of // the maximum value so that the values are centered about zero. for (int y = 0; y < DITHERSIZE; y++) { for (int x = 0; x < DITHERSIZE; x++) { int Temp = (DitherArray[y][x] * ditherAmount + 127) / 255; assert(Temp >= 0 && Temp <= ditherAmount); DitherArray[y][x] = Temp - ditherAmount / 2; } } // Now we can dither our image. for (int y = 0; y < GetHeight(pBitmap); y++) { unsigned char* pLine = GetLinePtr(pBitmap, y); int* pDitherLine = DitherArray[y & (DITHERSIZE - 1)]; for (int x = 0; x < GetWidth(pBitmap); x++) { int DitherAmount = pDitherLine[x & (DITHERSIZE - 1)]; for (int channels = 0; channels < NumChannels; channels++) { int DitheredPixel = (int)pLine[channels] + DitherAmount; if (DitheredPixel < 0) DitheredPixel = 0; if (DitheredPixel > 255) DitheredPixel = 255; pLine[channels] = DitheredPixel; } pLine += NumChannels; } } }
/** * Draws the emulated screens to the emulator window. */ void RendererOpenGL::DrawScreens() { auto viewport_extent = GetViewportExtent(); glViewport(viewport_extent.left, viewport_extent.top, viewport_extent.GetWidth(), viewport_extent.GetHeight()); // TODO: Or bottom? glClear(GL_COLOR_BUFFER_BIT); glUseProgram(program_id); // Set projection matrix std::array<GLfloat, 3*2> ortho_matrix = MakeOrthographicMatrix((float)resolution_width, (float)resolution_height); glUniformMatrix3x2fv(uniform_modelview_matrix, 1, GL_FALSE, ortho_matrix.data()); // Bind texture in Texture Unit 0 glActiveTexture(GL_TEXTURE0); glUniform1i(uniform_color_texture, 0); const float max_width = std::max((float)VideoCore::kScreenTopWidth, (float)VideoCore::kScreenBottomWidth); const float top_x = 0.5f * (max_width - VideoCore::kScreenTopWidth); const float bottom_x = 0.5f * (max_width - VideoCore::kScreenBottomWidth); DrawSingleScreenRotated(textures[0], top_x, 0, (float)VideoCore::kScreenTopWidth, (float)VideoCore::kScreenTopHeight); DrawSingleScreenRotated(textures[1], bottom_x, (float)VideoCore::kScreenTopHeight, (float)VideoCore::kScreenBottomWidth, (float)VideoCore::kScreenBottomHeight); m_current_frame++; }
void CBackBuffer::Clear() { HBRUSH hOldBrush = static_cast<HBRUSH>(SelectObject(GetBFDC(), GetStockObject(WHITE_BRUSH))); Rectangle(GetBFDC(), 0, 0, GetWidth(), GetHeight()); SelectObject(GetBFDC(), hOldBrush); }
void CChatRoomDlg::AddChatMsg_ZList( const char* pszMsg, DWORD dwColor ) { CWinCtrl* pCtrl = FindChildInPane( IID_PANE_BOTTOM, IID_CHAT_LIST ); if( pCtrl && pCtrl->GetControlType() == CTRL_ZLISTBOX) { CZListBox* pListBox = (CZListBox*)pCtrl; int iItemCount = pListBox->GetSize(); int iWidth = pListBox->GetWidth(); //06.07.27 - 김주현 //pszMsg가 2라인 이상일 경우에 리스트박스에 한줄씩 뜯어 넣기 위해서 테스트용으로 스트링을 세팅한다. CJStringParser m_jString; m_jString.SetSplitType( CJStringParser::SPLIT_WORD ); m_jString.SetDefaultColor( dwColor ); m_jString.SetString( CStr::Printf( "%s", pszMsg), iWidth - 10 ); CTScrollBar* pScrollBar; if(m_jString.GetStringCount() > 1) { for(int i = 0; i < m_jString.GetStringCount(); i++) { m_szStirng = m_jString.GetJString(i); CZLBAppendText* pAppText = new CZLBAppendText(m_szStirng, iWidth); pListBox->Add( pAppText ); //GetExtent 주의.. pListBox->SetExtent( pListBox->GetExtent() ); pListBox->SetValue( 0 ); pListBox->SetHeight( pListBox->GetHeight() + pAppText->GetHeight()); pListBox->SetWidth( iWidth ); SetHeight( GetHeight() + pAppText->GetHeight() ); pCtrl = FindChildInPane( IID_PANE_BOTTOM, IID_CHAT_SCROLLBAR ); if( pCtrl && pCtrl->GetControlType() == CTRL_SCROLLBAR ) { pScrollBar = (CTScrollBar*)pCtrl; pScrollBar->SetValue( pListBox->GetMaximum() ); } } } else { CZLBAppendText* pAppText = new CZLBAppendText( pszMsg, iWidth); pListBox->Add( pAppText ); pListBox->SetExtent( pListBox->GetExtent() ); pListBox->SetValue( 0 ); pListBox->SetHeight( pListBox->GetHeight() + pAppText->GetHeight()); pListBox->SetWidth( iWidth ); SetHeight( GetHeight() + pAppText->GetHeight() ); pCtrl = FindChildInPane( IID_PANE_BOTTOM, IID_CHAT_SCROLLBAR ); if( pCtrl && pCtrl->GetControlType() == CTRL_SCROLLBAR ) { CTScrollBar* pScrollBar = (CTScrollBar*)pCtrl; pScrollBar->SetValue( pListBox->GetMaximum() ); } } } }
void Map::Update(double delta) { static double timeScale = 1; m_deltaTime = delta; m_prevTotalTime = m_totalTime; m_totalTime += (delta * timeScale); #if 0 for(int x = 0; x < GetWidth(); x++) { for(int y = 0; y < GetHeight(); y++) { if(GetMapTileAtPos(Point(x,y))->IsPassable() == false) { m_context->GetRenderer()->RenderDebugLine(Line(x,y,x+1,y+1,Color(255,0,0))); m_context->GetRenderer()->RenderDebugLine(Line(x+1,y,x,y+1,Color(255,0,0))); } } } #endif m_context->GetRenderer()->RenderDebugText(Text(0,0,"Project FieldGlass")); // Time setup: { int prevSecond = static_cast<int>(m_prevTotalTime); int curSecond = static_cast<int>(m_totalTime); if(prevSecond != curSecond) { m_second += (curSecond - prevSecond); while (m_second > 60) { m_min++; m_second -= 60; } while(m_min > 60) { m_hour++; m_min -= 60; } while(m_hour > 24) { m_day++; m_hour -=24; } while(m_day > 30) { m_month++; m_day -=30; } } std::stringstream stream; stream << "Time: " << m_hour << ":" << m_min << ":" << m_second << " Day " << m_day << " of Month" << m_month; m_context->GetRenderer()->RenderDebugText(Text(500,0,stream.str())); } const size_t entityCount = m_Entities.size(); for(unsigned int i = 0; i < entityCount; i++) { Entity * entity = m_Entities[i]; if(entity) entity->Update(); } // CleanUp any entities marked For destruction for(unsigned int i = 0; i < entityCount; i++) { Entity * entity = m_Entities[i]; if(entity && entity->ShouldDestroy()) { m_Entities[i] = NULL; entity->CleanUp(); delete entity; } } }
int vtkLimitedInverseDistanceHeightFilter::RequestData ( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector ) { // get the info objects vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); vtkInformation *inInfoForH = inputVector[1]->GetInformationObject(0); vtkInformation *outInfo = outputVector->GetInformationObject(0); // get the input and ouptut vtkPolyData *input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData *inputForH = vtkPolyData::SafeDownCast(inInfoForH->Get(vtkDataObject::DATA_OBJECT())); vtkPolyData *output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); // set kDtree and build m_kDTree->SetDataSet(input); m_kDTree->BuildLocator(); // set safe number of points if (m_LimitNum > input->GetNumberOfPoints()) m_LimitNum = input->GetNumberOfPoints(); // new id list to get points vtkIdList *ids = vtkIdList::New(); vtkPoints *outpoints = vtkPoints::New(); vtkDoubleArray *outScalars = vtkDoubleArray::New(); vtkDoubleArray *inScalars = (vtkDoubleArray *) (input->GetPointData()->GetScalars()); double *raw_points = (double *) malloc(sizeof(double) * 4 * input->GetNumberOfPoints()), *save_pos = raw_points; for (vtkIdType i = 0; i < input->GetNumberOfPoints(); i++, save_pos += 4) { input->GetPoint(i, save_pos); save_pos[3] = inScalars->GetValue(i); #ifdef _DEBUG std::cout << "Point " << i << " : (" << save_pos[0] << " " << save_pos[1] << " " << save_pos[2] << ")" << std::endl; #endif // _DEBUG } save_pos = raw_points; doubles vals; doubles weights; doubles heighttable; double dim[3]; int hindex; int nx = (m_Bounds.xmax - m_Bounds.xmin) / m_Interval[0] + 1; int ny = (m_Bounds.ymax - m_Bounds.ymin) / m_Interval[1] + 1; int nz = (m_Bounds.zmax - m_Bounds.zmin) / m_Interval[2] + 1; int ox = 0, oy = 0, oz = 0; doubles tres; tres.resize(nx * ny * nz); heighttable.clear(); for (dim[0] = m_Bounds.xmin; dim[0] <= m_Bounds.xmax; dim[0] += m_Interval[0]) { for (dim[2] = m_Bounds.zmin; dim[2] <= m_Bounds.zmax; dim[2] += m_Interval[2]) { heighttable.push_back(GetHeight(inputForH, dim[0], dim[2])); } } int k = 0; for (dim[1] = m_Bounds.ymin; dim[1] <= m_Bounds.ymax; dim[1] += m_Interval[1], oy++) { //BuildPlaneSample(input, inScalars, dim[1]); hindex = 0; ox = 0; for (dim[0] = m_Bounds.xmin; dim[0] <= m_Bounds.xmax; dim[0] += m_Interval[0], ox++) { oz = 0; for (dim[2] = m_Bounds.zmin; dim[2] <= m_Bounds.zmax; dim[2] += m_Interval[2], hindex++, oz++) { k++; if (m_IgrSeaLinePoint) { if ( GetError(heighttable[hindex], m_SeaLineHeight, 0, 0) < 1 || heighttable[hindex] < dim[1] ) //the point's height is close sea line { if (!m_IgrNullValuePoint) { tres[ox * ny * nz + oy * nz + oz] = m_NullValue; } continue; } } int zero_pos_index = -1; save_pos = raw_points; if (LIMIT_NUMBER == m_limitMethod) m_kDTree->FindClosestNPoints(m_LimitNum, dim, ids); else if (LIMIT_RADIUS == m_limitMethod) m_kDTree->FindPointsWithinRadius(m_Radius, dim, ids); vals.clear(); weights.clear(); for (vtkIdType i = 0; i < ids->GetNumberOfIds(); i++) { const vtkIdType index = ids->GetId(i); const double dis = sqrt(vtkMath::Distance2BetweenPoints(save_pos + index * 4, dim)); assert(dis >= 0); // don't have error if (dis == 0.0) { zero_pos_index = index; break; } weights.push_back(dis); vals.push_back(inScalars->GetValue(index)); } if (zero_pos_index != -1) { tres[ox * ny * nz + oy * nz + oz] = m_NullValue; } else { std::transform ( weights.begin(), weights.end(), weights.begin(), std::bind2nd(power<double> (), -2 * m_PowerValue) ); double sum = accumulate ( weights.begin(), weights.end(), 0.0, std::plus<double> () ); double multi_num; if (sum > 0) { multi_num = 1.0 / sum; // each weight multiplies multi_num, let sum = 1 std::transform ( weights.begin(), weights.end(), weights.begin(), std::bind2nd(std::multiplies<double> (), multi_num) ); // get average use (weight1 * value1) + (weight2 * value2) + ... double val = std::inner_product ( weights.begin(), weights.end(), vals.begin(), 0.0, std::plus<double> (), std::multiplies<double> () ); tres[ox * ny * nz + oy * nz + oz] = val; } else { if (!m_IgrNullValuePoint) { tres[ox * ny * nz + oy * nz + oz] = m_NullValue; } } } } } } std::cout << k; // delete id list ids->Delete(); // set out points ox = oy = oz = 0; for (dim[2] = m_Bounds.zmin; dim[2] <= m_Bounds.zmax; dim[2] += m_Interval[2], oz++) { oy = 0; for (dim[1] = m_Bounds.ymin; dim[1] <= m_Bounds.ymax; dim[1] += m_Interval[1], oy++) { ox = 0; for (dim[0] = m_Bounds.xmin; dim[0] <= m_Bounds.xmax; dim[0] += m_Interval[0], ox++) { outpoints->InsertNextPoint(dim); outScalars->InsertNextTuple1(tres[ox * ny * nz + oy * nz + oz]); } } } output->SetPoints(outpoints); output->GetPointData()->SetScalars(outScalars); return 1; }
bool TerrainInfo::CheckPathAccurate(float srcX, float srcY, float srcZ, float& dstX, float& dstY, float& dstZ, Unit* mover ) const { float tstX = dstX; float tstY = dstY; float tstZ = dstZ; // check by standart way. may be not need path checking? if (!mover && CheckPath(srcX, srcY, srcZ, tstX, tstY, tstZ) && IsNextZcoordOK(tstX, tstY, tstZ, 5.0f)) { DEBUG_LOG("TerrainInfo::CheckPathAccurate vmaps hit! delta is %f %f %f",dstX - tstX,dstY - tstY,dstZ - tstZ); dstX = tstX; dstY = tstY; dstZ = tstZ + 0.1f; return true; } const float distance = sqrt((dstY - srcY)*(dstY - srcY) + (dstX - srcX)*(dstX - srcX)); const float DELTA = 0.5f; const uint8 numChecks = ceil(fabs(distance/DELTA)); const float DELTA_X = (dstX-srcX)/numChecks; const float DELTA_Y = (dstY-srcY)/numChecks; float lastGoodX = srcX; float lastGoodY = srcY; float lastGoodZ = srcZ; uint32 errorsCount = 0; uint32 goodCount = 0; uint32 vmaperrorsCount = 0; //Going foward until max distance for (uint8 i = 1; i < numChecks; ++i) { float prevX = srcX + (float(i-1)*DELTA_X); float prevY = srcY + (float(i-1)*DELTA_Y); float prevZ = GetHeight(prevX, prevY, srcZ+5.0f); tstX = srcX + (float(i)*DELTA_X); tstY = srcY + (float(i)*DELTA_Y); tstZ = GetHeight(tstX, tstY, srcZ+5.0f); MaNGOS::NormalizeMapCoord(tstX); MaNGOS::NormalizeMapCoord(tstY); if (tstZ <= INVALID_HEIGHT) break; tstZ += 0.5f; if (!CheckPath(prevX, prevY, prevZ, tstX, tstY, tstZ)) { ++vmaperrorsCount; ++errorsCount; goodCount = 0; } else if (!IsNextZcoordOK(tstX, tstY, tstZ, 5.0f)) { ++errorsCount; goodCount = 0; } else if (mover) { std::list<GameObject*> tempTargetGOList; MaNGOS::GameObjectInRangeCheck check(mover, tstX, tstY, tstZ, 2*mover->GetObjectBoundingRadius()); MaNGOS::GameObjectListSearcher<MaNGOS::GameObjectInRangeCheck> searcher(tempTargetGOList, check); Cell::VisitAllObjects(mover, searcher, 2*mover->GetObjectBoundingRadius()); if (!tempTargetGOList.empty()) { for(std::list<GameObject*>::iterator iter = tempTargetGOList.begin(); iter != tempTargetGOList.end(); ++iter) { if (((*iter)->GetGoType() == GAMEOBJECT_TYPE_DOOR && (*iter)->GetGoState() == GO_STATE_READY) || (*iter)->GetGoType() != GAMEOBJECT_TYPE_DOOR) { ++errorsCount; goodCount = 0; } } } else ++goodCount; } else { ++goodCount; } if (!errorsCount) { lastGoodX = prevX; lastGoodY = prevY; lastGoodZ = prevZ; } // DEBUG_LOG("TerrainInfo::CheckPathAccurate test data %f %f %f good=%u, errors=%u vmap=%u",tstX,tstY,tstZ, goodCount, errorsCount, vmaperrorsCount); if (errorsCount && goodCount > 10) { --errorsCount; goodCount -= 10; } } if (errorsCount) { dstX = lastGoodX; dstY = lastGoodY; dstZ = GetHeight(lastGoodX, lastGoodY, lastGoodZ+2.0f) + 0.5f; } else { dstX = tstX; dstY = tstY; dstZ = GetHeight(tstX, tstY, tstZ+2.0f) + 0.5f; } return (errorsCount == 0); }
wxImage wxDIB::ConvertToImage() const { wxCHECK_MSG( IsOk(), wxNullImage, wxT("can't convert invalid DIB to wxImage") ); // create the wxImage object const int w = GetWidth(); const int h = GetHeight(); wxImage image(w, h, false /* don't bother clearing memory */); if ( !image.IsOk() ) { wxFAIL_MSG( wxT("could not allocate data for image") ); return wxNullImage; } const int bpp = GetDepth(); // Remember if we have any "real" transparency, i.e. either any partially // transparent pixels or not all pixels are fully opaque or fully // transparent. bool hasAlpha = false; bool hasOpaque = false; bool hasTransparent = false; if ( bpp == 32 ) { // 32 bit bitmaps may be either 0RGB or ARGB and we don't know in // advance which one do we have so suppose we have alpha of them and // get rid of it later if it turns out we didn't. image.SetAlpha(); } // this is the same loop as in Create() just above but with copy direction // reversed const int dstBytesPerLine = w * 3; const int srcBytesPerLine = GetLineSize(w, bpp); unsigned char *dst = image.GetData() + ((h - 1) * dstBytesPerLine); unsigned char *alpha = image.HasAlpha() ? image.GetAlpha() + (h - 1)*w : NULL; const unsigned char *srcLineStart = (unsigned char *)GetData(); for ( int y = 0; y < h; y++ ) { // copy one DIB line const unsigned char *src = srcLineStart; for ( int x = 0; x < w; x++ ) { dst[2] = *src++; dst[1] = *src++; dst[0] = *src++; if ( bpp == 32 ) { // wxImage uses non premultiplied alpha so undo // premultiplication done in Create() above const unsigned char a = *src; *alpha++ = a; // Check what kind of alpha do we have. switch ( a ) { case 0: hasTransparent = true; break; default: // Anything in between means we have real transparency // and must use alpha channel. hasAlpha = true; break; case 255: hasOpaque = true; break; } if ( a > 0 ) { dst[0] = (dst[0] * 255) / a; dst[1] = (dst[1] * 255) / a; dst[2] = (dst[2] * 255) / a; } src++; } dst += 3; } // pass to the previous line in the image dst -= 2*dstBytesPerLine; if ( alpha ) alpha -= 2*w; // and to the next one in the DIB srcLineStart += srcBytesPerLine; } if ( hasOpaque && hasTransparent ) hasAlpha = true; if ( !hasAlpha && image.HasAlpha() ) image.ClearAlpha(); return image; }
void emTreeDumpRecPanel::Paint(const emPainter & painter, emColor canvasColor) { double xy[6*2]; double x,y,w,h,t,r; if (!Rec) return; t=0.02; x=t*0.5; y=t*0.5; w=1.0-t; h=GetHeight()-t; switch (Rec->Frame.Get()) { case emTreeDumpRec::FRAME_RECTANGLE: painter.PaintRect(x,y,w,h,BgColor,canvasColor); painter.PaintRectOutline(x,y,w,h,t,Rec->FgColor); break; case emTreeDumpRec::FRAME_ROUND_RECT: r=emMin(w,h)*0.2; painter.PaintRoundRect(x,y,w,h,r,r,BgColor,canvasColor); painter.PaintRoundRectOutline(x,y,w,h,r,r,t,Rec->FgColor); break; case emTreeDumpRec::FRAME_ELLIPSE: painter.PaintEllipse(x,y,w,h,BgColor,canvasColor); painter.PaintEllipseOutline(x,y,w,h,t,Rec->FgColor); break; case emTreeDumpRec::FRAME_HEXAGON: r=w*0.2; xy[ 0]=x+r; xy[ 1]=y; xy[ 2]=x+w-r; xy[ 3]=y; xy[ 4]=x+w; xy[ 5]=y+h*0.5; xy[ 6]=x+w-r; xy[ 7]=y+h; xy[ 8]=x+r; xy[ 9]=y+h; xy[10]=x; xy[11]=y+h*0.5; painter.PaintPolygon(xy,6,BgColor,canvasColor); painter.PaintPolygonOutline(xy,6,t,Rec->FgColor); break; default: painter.Clear(BgColor,canvasColor); break; } canvasColor=BgColor; painter.PaintTextBoxed( 0.19,0.1,0.62,0.13, Rec->Title.Get(), 0.1, Rec->FgColor, canvasColor, EM_ALIGN_CENTER, EM_ALIGN_CENTER ); if (GetViewedHeight()>10.0) { painter.PaintTextBoxed( 0.19,0.26,0.15,0.3, Rec->Text.Get(), 0.01, Rec->FgColor, canvasColor, EM_ALIGN_TOP_LEFT, EM_ALIGN_LEFT, 0.8 ); } }
{ SetName("Hask"); } void MoleculesHaskell:: Init(const bool) throw (...) { struct ParallelScript::NamedFunctions_s funcs[] = { {"generateMolecules@16", (void **)&GenerateMolecules}, {0, 0} }; ScriptInit(L"MoleculesHaskell.dll", funcs); GenerateMolecules((float *)GetAtoms().GetData(), (int)GetCount(), GetHeight(), GetWidth()); CUmodule module = 0; TryCUDA(cuModuleLoad(&module, "MoleculesHaskell.ptx")); m_kernel = 0; TryCUDA(cuModuleGetFunction(&m_kernel, module, "DoAtoms")); } void MoleculesHaskell:: Execute() throw (...) { //printf("0"); size_t height = GetHeight(), width = GetWidth(),