Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Region code to RegionState and RegionConverter #1352

Merged
merged 34 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5459b63
Rename spatial profiles test, for cursor only
pford Dec 7, 2023
8f2add5
Rename region (line and point) spatial profile test
pford Dec 7, 2023
f9d47cf
Remove unused methods, update test CMakeLists
pford Dec 7, 2023
e3f5966
Add region histogram and stats tests
pford Dec 8, 2023
760e940
Tweak tests and rename test suite
pford Dec 8, 2023
9de1192
Add tests for Region in reference image
pford Dec 9, 2023
213fd7b
Add tests for matched regions and rotbox
pford Dec 9, 2023
6dee2a7
Convert test utils CmpValues and CmpVectors to template
pford Jan 2, 2024
c000246
Add region spectral profile test
pford Jan 2, 2024
4a1fb69
Remove float versions of test utils CmpValues and CmpVectors
pford Jan 2, 2024
abaf732
Fix formatting
pford Jan 2, 2024
e21ff82
Merge branch 'dev' into pam/1347_region_converter
pford Jan 2, 2024
8180a13
Fix includes after removing Message.h from Region.cc
pford Jan 8, 2024
bed62df
Use FileFinder for image path in tests
pford Jan 8, 2024
e7c0044
Move rotbox tests into region and matched region tests
pford Jan 8, 2024
8452b43
Refactor Region into RegionConverter and add tests
pford Jan 17, 2024
cb91489
Remove debug output
pford Jan 17, 2024
d49bed0
Add performance time for line spatial profile
pford Jan 17, 2024
bbf1700
Merge branch 'dev' into pam/1347_region_converter
pford Jan 18, 2024
58a3fa8
Remove tab from CMakeLists
pford Jan 18, 2024
f7a525a
Add spatial profile test for point outside image
pford Jan 19, 2024
5c7955f
Add region import/export test and bug fixes from refactoring
pford Jan 22, 2024
ea65135
Fix formatting
pford Jan 23, 2024
4b9e148
Merge branch 'dev' into pam/1347_region_converter
pford Jan 23, 2024
9462ebd
Add changelog entry
pford Jan 23, 2024
b4f9be4
Fix PvPreviewCut profile using nchan in preview image
pford Jan 31, 2024
6a25678
Fix ellipse record from control points for export
pford Jan 31, 2024
224f9e0
Fix point region spectral profile and add test
pford Feb 1, 2024
ef64598
Fix format
pford Feb 1, 2024
6a3b0f2
Merge branch 'dev' into pam/1347_region_converter
pford Feb 1, 2024
1476e9e
Update protobuf
pford Feb 1, 2024
5697d51
Use double for ellipse angle in record for accurate unit conversion
pford Mar 7, 2024
0b965b4
Merge branch 'dev' into pam/1347_region_converter
pford Mar 20, 2024
a62fda6
Merge branch 'dev' into pam/1347_region_converter
confluence Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused methods, update test CMakeLists
  • Loading branch information
pford committed Dec 7, 2023
commit f9d47cf1e2b094187497b6ed02a9de5fa17fd038
5 changes: 3 additions & 2 deletions src/Region/Region.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void Region::SetReferenceRegion() {
casacore::IPosition pixel_axes(2, 0, 1);
casacore::Vector<casacore::Int> abs_rel;
auto type(region_state.type);

try {
switch (type) {
case CARTA::POINT:
Expand Down Expand Up @@ -212,7 +213,7 @@ void Region::SetReferenceRegion() {
}
case CARTA::ELLIPSE:
case CARTA::ANNELLIPSE: // [(cx, cy), (bmaj, bmin)]
case CARTA::ANNCOMPASS: { // [(cx, cy), (length, length)}
case CARTA::ANNCOMPASS: { // [(cx, cy), (length, length)]
float ellipse_rotation;
if (EllipsePointsToWorld(pixel_points, _wcs_control_points, ellipse_rotation)) {
// control points are in order: xcenter, ycenter, major axis, minor axis
Expand Down Expand Up @@ -822,7 +823,7 @@ casacore::TableRecord Region::GetImageRegionRecord(
}

if (record.empty()) {
// LCRegion failed, is outside the image or a rotated rectangle.
// LCRegion failed: is outside the image or a rotated rectangle.
// Manually convert control points and put in Record.
record = GetRegionPointsRecord(file_id, output_csys, output_shape);
}
Expand Down
13 changes: 1 addition & 12 deletions src/Region/Region.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,10 @@ struct RegionState {
RegionState(int ref_file_id_, CARTA::RegionType type_, const std::vector<CARTA::Point>& control_points_, float rotation_)
: reference_file_id(ref_file_id_), type(type_), control_points(control_points_), rotation(rotation_) {}

void operator=(const RegionState& other) {
reference_file_id = other.reference_file_id;
type = other.type;
control_points = other.control_points;
rotation = other.rotation;
}
bool operator==(const RegionState& rhs) {
return (reference_file_id == rhs.reference_file_id) && (type == rhs.type) && !RegionChanged(rhs);
}

bool operator!=(const RegionState& rhs) {
return (reference_file_id != rhs.reference_file_id) || (type != rhs.type) || RegionChanged(rhs);
}
Expand Down Expand Up @@ -103,10 +98,6 @@ class Region {
return region_state;
}

inline int GetReferenceFileId() {
return GetRegionState().reference_file_id;
}

inline bool RegionChanged() { // reference image, type, points, or rotation changed
return _region_changed;
}
Expand Down Expand Up @@ -152,8 +143,6 @@ class Region {
std::shared_mutex& GetActiveTaskMutex();

private:
bool SetPoints(const std::vector<CARTA::Point>& points);

// check points: number required for region type, and values are finite
bool CheckPoints(const std::vector<CARTA::Point>& points, CARTA::RegionType type);
bool PointsFinite(const std::vector<CARTA::Point>& points);
Expand Down
8 changes: 0 additions & 8 deletions src/Region/RegionHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ bool RegionHandler::SetRegion(int& region_id, RegionState& region_state, std::sh
return valid_region;
}

bool RegionHandler::RegionChanged(int region_id) {
// Used to trigger sending profiles etc., so not for annotation regions
if (!RegionSet(region_id, true)) {
return false;
}
return GetRegion(region_id)->RegionChanged();
}

void RegionHandler::RemoveRegion(int region_id) {
// Call destructor and erase from map
if (!RegionSet(region_id)) {
Expand Down
1 change: 0 additions & 1 deletion src/Region/RegionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class RegionHandler {

// Regions
bool SetRegion(int& region_id, RegionState& region_state, std::shared_ptr<casacore::CoordinateSystem> csys);
bool RegionChanged(int region_id);
void RemoveRegion(int region_id);
std::shared_ptr<Region> GetRegion(int region_id);

Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(TEST_SOURCES
CommonTestUtilities.cc
TestBlockSmooth.cc
TestContour.cc
TestCursorSpatialProfiles.cc
TestExprImage.cc
TestFileInfo.cc
TestFileList.cc
Expand All @@ -48,14 +49,13 @@ set(TEST_SOURCES
TestHdf5Image.cc
TestHistogram.cc
TestImageFitting.cc
TestLineSpatialProfiles.cc
TestMain.cc
TestMoment.cc
TestNormalizedUnits.cc
TestProgramSettings.cc
TestPvGenerator.cc
TestRegionSpatialProfiles.cc
TestRestApi.cc
TestSpatialProfiles.cc
TestTileEncoding.cc
TestUtil.cc
TestVoTable.cc)
Expand Down