void HeaderCtrl::LeftDouble(Point p, dword keyflags) { int q = GetSplit(p.x); if(q >= 0 || IsNull(q)) return; col[-1 - q].WhenLeftDouble(); }
void HeaderCtrl::LeftDown(Point p, dword keyflags) { #ifdef _DEBUG if(keyflags & K_CTRL) { String text; for(int i = 0; i < col.GetCount(); i++) text += Format(i ? " %d" : "%d", GetTabWidth(i)); WriteClipboardText(".ColumnWidths(\"" + text + "\");"); BeepExclamation(); } #endif split = GetSplit(p.x); if(IsNull(split)) return; SetCapture(); if(split >= 0) { colRect = GetTabRect(split); return; } li = pushi = -1 - split; col[pushi].WhenLeftClick(); #ifdef _DEBUG if((keyflags & K_ALT) && pushi >= 0) WriteClipboardText(AsString(GetTabWidth(pushi))); #endif if(pushi >= 0) { if(!col[pushi].WhenAction) { pushi = -1; return; } colRect = GetTabRect(pushi); push = true; } Refresh(); }
void HeaderCtrl::RightDown(Point p, dword) { int q = GetSplit(p.x); if(q >= 0 || IsNull(q)) return; q = -1 - q; if(col[q].WhenBar) MenuBar::Execute(col[q].WhenBar); }
Image HeaderCtrl::CursorImage(Point p, dword) { if(mode == FIXED) return Image::Arrow(); if(HasCapture()) return split >= 0 ? CtrlsImg::HorzPos() : Image::Arrow(); int q = GetSplit(p.x); return q < 0 ? Image::Arrow() : GetTabWidth(q) < 4 ? CtrlsImg::HorzSplit() : CtrlsImg::HorzPos(); }
void HeaderCtrl::MouseMove(Point p, dword keyflags) { if(isdrag) { ti = GetLastVisibleTab() + 1; for(int i = 0; i < GetCount(); i++) if(col[i].visible) { Rect r = GetTabRect(i).OffsetedHorz(-sb); if(p.x < r.left + r.Width() / 2) { ti = i; break; } } dragx = p.x; Refresh(); return; } int q = GetSplit(p.x); int cx = ~q; if(cx >= 0 && cx < col.GetCount() && !IsNull(col[cx].tip)) Tip(col[cx].tip); if(mode == FIXED) return; q = IsNull(q) || q >= 0 ? -1 : -1 - q; if(q != light) Refresh(); if(!HasCapture()) return; Size sz = GetSize(); int x = mode == SCROLL ? p.x + sb : min(sz.cx, p.x); if(split >= 0) { int w = x - colRect.left; if(w < 0) w = 0; if(w != GetTabWidth(split)) { SetTabWidth0(split, w); Refresh(); if(track) { Sync(); Action(); WhenLayout(); } } } }
void KDTree::ConstructKDTree(int leafNodeSize, KDNode* parent,int num, int* index, unsigned int *face, float* vertice, AABB& aabb,int floor, bool isLeft) { if(root ==0) { root = new KDNode(); root->numObject = num;//face num root->object = index;//int[] 1,2,3,4... root->floor = floor;//0 //assign mesh aabb to the root node root->aabb.maxPoint.x = aabb.maxPoint.x; root->aabb.maxPoint.y = aabb.maxPoint.y; root->aabb.maxPoint.z = aabb.maxPoint.z; root->aabb.minPoint.x = aabb.minPoint.x; root->aabb.minPoint.y = aabb.minPoint.y; root->aabb.minPoint.z = aabb.minPoint.z; AABB leftAABB, rightAABB; int* leftIndex = new int[num]; int* rightIndex =new int[num]; root->splitAxis = GetSplit(aabb,leftAABB,rightAABB, root->splitValue); int numLeft, numRight; Split(index,face,vertice,num,leftIndex,rightIndex,numLeft,numRight,root->splitValue,root->splitAxis); //Split_New(index,face,vertice,num,leftIndex,numLeft,root->splitValue,root->splitAxis,true); #ifdef MEDIAN switch(root->splitAxis) { case Axis_X: leftAABB.maxPoint.x = root->splitValue; rightAABB.minPoint.x = root->splitValue; break; case Axis_Y: leftAABB.maxPoint.y = root->splitValue; rightAABB.minPoint.y = root->splitValue; break; case Axis_Z: leftAABB.maxPoint.z = root->splitValue; rightAABB.minPoint.z = root->splitValue; break; } #endif m_floor++; ConstructKDTree(leafNodeSize, root,numLeft, leftIndex, face,vertice, leftAABB,floor+1,true); delete [] leftIndex; //free(leftIndex) ; //int* rightIndex = (int*)malloc(sizeof(int)*num); //Split_New(index,face,vertice,num,rightIndex,numRight,root->splitValue,root->splitAxis,false); ConstructKDTree(leafNodeSize, root,numRight, rightIndex,face, vertice, rightAABB,floor+1,false); numInsideNode++; //free(rightIndex) ; delete [] rightIndex; } else { if(num<=leafNodeSize) {//the node is small enough to do ray tracing if(num == 0) { if(isLeft) parent->left =0; else parent->right =0; return; } else { KDNode* node = new KDNode(); if(isLeft) parent->left = node; else parent->right = node; node->aabb.maxPoint.x = aabb.maxPoint.x; node->aabb.maxPoint.y = aabb.maxPoint.y; node->aabb.maxPoint.z = aabb.maxPoint.z; node->aabb.minPoint.x = aabb.minPoint.x; node->aabb.minPoint.y = aabb.minPoint.y; node->aabb.minPoint.z = aabb.minPoint.z; node->splitAxis = LEAF; node->numObject = num; node->floor = floor; node->parent = parent; //parent->left = parent->right = NULL; node->object = index; numLeafNode++; SizeofLeafNode +=num; node->left =0; node->right=0; return; } } else {//the need still need to be splited KDNode* node = new KDNode(); if(isLeft) parent->left = node; else parent->right = node; node->numObject = num; node->object = index; node->floor = floor; node->parent = parent; node->aabb.maxPoint.x = aabb.maxPoint.x; node->aabb.maxPoint.y = aabb.maxPoint.y; node->aabb.maxPoint.z = aabb.maxPoint.z; node->aabb.minPoint.x = aabb.minPoint.x; node->aabb.minPoint.y = aabb.minPoint.y; node->aabb.minPoint.z = aabb.minPoint.z; AABB leftAABB, rightAABB; //int* leftIndex = (int*)malloc(sizeof(int)*num); int* leftIndex = new int[num]; int* rightIndex =new int[num]; node->splitAxis = GetSplit(aabb,leftAABB,rightAABB, node->splitValue); int numLeft, numRight; //Split_New(index,face,vertice,num,leftIndex,numLeft,node->splitValue,node->splitAxis, true); Split(index,face,vertice,num,leftIndex,rightIndex,numLeft,numRight,node->splitValue,node->splitAxis); #ifdef MEDIAN switch(node->splitAxis) { case Axis_X: leftAABB.maxPoint.x = node->splitValue; rightAABB.minPoint.x = node->splitValue; break; case Axis_Y: leftAABB.maxPoint.y = node->splitValue; rightAABB.minPoint.y = node->splitValue; break; case Axis_Z: leftAABB.maxPoint.z = node->splitValue; rightAABB.minPoint.z = node->splitValue; break; } #endif if(m_floor < floor+1) m_floor = floor+1; ConstructKDTree(leafNodeSize, node,numLeft, leftIndex,face, vertice, leftAABB,floor+1,true); if(numLeft>leafNodeSize) // free(leftIndex) ; delete [] leftIndex ; //int* rightIndex = (int*)malloc(sizeof(int)*num); //Split_New(index,face,vertice,num,rightIndex,numRight,node->splitValue,node->splitAxis, false); ConstructKDTree(leafNodeSize, node,numRight, rightIndex,face, vertice, rightAABB,floor+1,false); numInsideNode++; if(numRight>leafNodeSize) // free(rightIndex); delete [] rightIndex ; } } }