ZPoint MessageButtonPane::GetSize() { long num = mButtons.size(); if ( num == 0 ) return ZPoint( 0, 0 ); return ZPoint( 100, num * mButtons.front()->GetSize().v ); }
ZSwcTree* ZSwcGenerator::createBoxSwc(const ZIntCuboid &box, double radius) { ZCuboid cuboid; cuboid.setFirstCorner(ZPoint(box.getFirstCorner().toPoint())); cuboid.setSize(box.getWidth(), box.getHeight(), box.getDepth()); return createBoxSwc(cuboid, radius); }
bool BMDisplayWindow::GetPaneLocation(ZSubPane* inPane, ZPoint& outLocation) { if ( mDisplay == inPane ){ outLocation = ZPoint( 10, 10 ); return true; } return ZPaneLocator::GetPaneLocation( inPane, outLocation ); }
bool ZEllipsoid::containsPoint(double x, double y, double z) const { if (m_rX <= 0 || m_rY <= 0 || m_rZ <= 0) { return false; } ZPoint pt(x, y, z); pt -= m_center; pt /= ZPoint(m_rX, m_rY, m_rZ); return pt.length() <= 1.0; }
ZSwcTree* ZSwcGenerator::createSwc(const ZIntCuboidFace &face, double radius) { if (!face.isValid()) { return NULL; } ZPointArray ptArray; for (int i = 0; i < 4; ++i) { ZIntPoint pt = face.getCornerCoordinates(i); ptArray.append(ZPoint(pt.getX(), pt.getY(), pt.getZ())); } ptArray.append(ptArray[0]); return createSwc(ptArray, radius, true); }
ZPoint ZMouseEvent::getPosition(NeuTube::ECoordinateSystem cs) const { switch (cs) { case NeuTube::COORD_WIDGET: return m_position.toPoint(); case NeuTube::COORD_STACK: return m_stackPosition; case NeuTube::COORD_RAW_STACK: return m_rawStackPosition; case NeuTube::COORD_SCREEN: return m_globalPosition.toPoint(); default: break; } return ZPoint(0, 0, 0); }
static ZRef<NPaintDataRep> sRead_NPaintDataRep(const ZStreamRPos& iStreamRPos, string& oFormat) { iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_BMP(iStreamRPos)) { oFormat = "bmp"; return theRep; } iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_GIF(iStreamRPos)) { oFormat = "gif"; return theRep; } iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_JPEG(iStreamRPos)) { oFormat = "jpg"; return theRep; } iStreamRPos.SetPosition(0); if (ZRef<NPaintDataRep> theRep = sTryRead_PNG(iStreamRPos)) { oFormat = "png"; return theRep; } iStreamRPos.SetPosition(0); ZRef<NPaintDataRep> theRep = new NPaintDataRep; theRep->FromStream(iStreamRPos); if (theRep->HasData()) { oFormat = "kf"; return theRep; } return new NPaintDataRep(ZPoint(320, 240)); }
ZPoint ZIntPoint::toPoint() const { return ZPoint(getX(), getY(), getZ()); }
void ZDCPixmapDecoder_JPEGLib::Imp_Read(const ZStreamR& iStream, ZDCPixmap& oPixmap) { struct jpeg_decompress_struct theJDS; JPEGErrorMgr theEM; theJDS.err = &theEM; ::jpeg_create_decompress(&theJDS); JPEGReader theJR(iStream); theJDS.src = &theJR; try { ::jpeg_read_header(&theJDS, TRUE); ::jpeg_start_decompress(&theJDS); ZDCPixmapNS::PixelDesc sourcePixelDesc; ZDCPixmapNS::PixvalDesc sourcePixvalDesc; vector<uint8> rowBufferVector; if (theJDS.out_color_space == JCS_GRAYSCALE) { sourcePixelDesc = ZDCPixmapNS::PixelDesc(ZDCPixmapNS::eFormatStandard_Gray_8); rowBufferVector.resize(theJDS.image_width); sourcePixvalDesc.fDepth = 8; sourcePixvalDesc.fBigEndian = true; oPixmap = ZDCPixmap(ZPoint(theJDS.image_width, theJDS.image_height), ZDCPixmapNS::eFormatEfficient_Gray_8); } else if (theJDS.out_color_space == JCS_RGB) { sourcePixelDesc = ZDCPixmapNS::PixelDesc(ZDCPixmapNS::eFormatStandard_RGB_24); rowBufferVector.resize(3 * theJDS.image_width); sourcePixvalDesc.fDepth = 24; sourcePixvalDesc.fBigEndian = true; oPixmap = ZDCPixmap(ZPoint(theJDS.image_width, theJDS.image_height), ZDCPixmapNS::eFormatEfficient_Color_24); } else { // TODO. What about other color spaces? ZUnimplemented(); } ZDCPixmapNS::PixelDesc destPixelDesc = oPixmap.GetPixelDesc(); ZDCPixmapNS::RasterDesc destRasterDesc = oPixmap.GetRasterDesc(); void* destBaseAddress = oPixmap.GetBaseAddress(); JSAMPROW rowPtr[1]; rowPtr[0] = &rowBufferVector[0]; while (theJDS.output_scanline < theJDS.output_height) { int scanlinesRead = ::jpeg_read_scanlines(&theJDS, rowPtr, 1); ZAssertStop(1, scanlinesRead == 1); void* destRowAddress = destRasterDesc.CalcRowAddress(destBaseAddress, theJDS.output_scanline - 1); ZDCPixmapNS::sBlitRow( rowPtr[0], sourcePixvalDesc, sourcePixelDesc, 0, destRowAddress, destRasterDesc.fPixvalDesc, destPixelDesc, 0, theJDS.image_width); } ::jpeg_finish_decompress(&theJDS); } catch (...) { ::jpeg_destroy_decompress(&theJDS); throw; } ::jpeg_destroy_decompress(&theJDS); }
Swc_Tree* ZNeuronTracer::trace(double x1, double y1, double z1, double r1, double x2, double y2, double z2, double r2) { if (x1 < 0 || y1 < 0 || z1 < 0 || x1 >= C_Stack::width(m_stack) || y1 >= C_Stack::height(m_stack) || z1 >= C_Stack::depth(m_stack)) { return NULL; } if (ZPoint(x1, y1, z1).distanceTo(x2, y2, z2) > MAX_P2P_TRACE_DISTANCE) { return NULL; } /* int start[3]; int end[3]; start[0] = iround(x1); start[1] = iround(y1); start[2] = iround(z1); end[0] = iround(x2); end[1] = iround(y2); end[2] = iround(z2); */ ZStackGraph stackGraph; stackGraph.setResolution(m_resolution); if (m_backgroundType == NeuTube::IMAGE_BACKGROUND_BRIGHT) { stackGraph.setWeightFunction(Stack_Voxel_Weight); } else { stackGraph.setWeightFunction(Stack_Voxel_Weight_S); } stackGraph.inferWeightParameter(m_stack); int startIndex = C_Stack::indexFromCoord(x1, y1, z1, C_Stack::width(m_stack), C_Stack::height(m_stack), C_Stack::depth(m_stack)); int endIndex = C_Stack::indexFromCoord(x2, y2, z2, C_Stack::width(m_stack), C_Stack::height(m_stack), C_Stack::depth(m_stack)); std::vector<int> path = stackGraph.computeShortestPath(m_stack, startIndex, endIndex); ZVoxelArray voxelArray; for (size_t i = path.size(); i > 0; --i) { int x, y, z; C_Stack::indexToCoord(path[i - 1], C_Stack::width(m_stack), C_Stack::height(m_stack), &x, &y, &z); voxelArray.append(ZVoxel(x, y, z)); } double length = voxelArray.getCurveLength(); double dist = 0.0; for (size_t i = 0; i < path.size(); ++i) { double ratio = dist / length; double r = r1 * ratio + r2 * (1 - ratio); voxelArray.setValue(i, r); if (i < path.size() - 1) { dist += voxelArray[i].distanceTo(voxelArray[i+1]); } } return voxelArray.toSwcTree(); }
ZPoint ZStTransform::getOffset() const { return ZPoint(getTx(), getTy(), getTz()); }
ZPoint ZStTransform::transform(const ZPoint &pt) const { return ZPoint(transformX(pt.x()), transformY(pt.y()), transformZ(pt.z())); }