Index: trunk/MagicSoft/Cosy/tpoint/TPointGui.cc
===================================================================
--- trunk/MagicSoft/Cosy/tpoint/TPointGui.cc	(revision 8937)
+++ trunk/MagicSoft/Cosy/tpoint/TPointGui.cc	(revision 8971)
@@ -5,4 +5,5 @@
 #include <TGLabel.h>
 #include <TGButton.h>
+#include <TGTextEntry.h>
 
 #include <TView.h>
@@ -32,5 +33,6 @@
 using namespace std;
 
-TPointGui::TPointGui(const char *fname) : TGMainFrame(gClient->GetRoot(), 750, 435, kHorizontalFrame), fExitLoopOnClose(kFALSE)
+TPointGui::TPointGui(const char *fname) : TGMainFrame(gClient->GetRoot(), 750, 435, kHorizontalFrame), fExitLoopOnClose(kFALSE),
+   fAzMin(-180), fAzMax(180), fZdMin(0), fZdMax(90), fLimit(0.05)
 {
     fCoordinates.SetOwner();
@@ -54,4 +56,5 @@
     AddFrame(grp2, hints1);
     fList->Add(grp2);
+
 
     TGLayoutHints *hints4 = new TGLayoutHints(kLHintsExpandX, 5, 5,  3);
@@ -68,4 +71,9 @@
 
 
+
+
+
+
+
     TGHorizontalFrame *comp = new TGHorizontalFrame(grp2, 1, 1);
     grp2->AddFrame(comp);
@@ -132,6 +140,9 @@
         AddLabel(vframe, fBending.GetDescription(i), h);
 
+    TGLayoutHints *hints6 = new TGLayoutHints(kLHintsExpandX, 5, 5, 4, 6);
+    fList->Add(hints6);
+
     l = new TGLabel(grp1, "0000000 Data Sets loaded.");
-    grp1->AddFrame(l, hints5);
+    grp1->AddFrame(l, hints6);
     fList->Add(l);
     fLabel.Add(l);
@@ -139,5 +150,5 @@
     l = new TGLabel(grp1, "");
     l->SetTextJustify(kTextLeft);
-    grp1->AddFrame(l, hints5);
+    grp1->AddFrame(l, hints6);
     fList->Add(l);
     fLabel.Add(l);
@@ -145,5 +156,5 @@
     l = new TGLabel(grp1, "");
     l->SetTextJustify(kTextLeft);
-    grp1->AddFrame(l, hints5);
+    grp1->AddFrame(l, hints6);
     fList->Add(l);
     fLabel.Add(l);
@@ -151,7 +162,89 @@
     l = new TGLabel(grp1, "");
     l->SetTextJustify(kTextLeft);
-    grp1->AddFrame(l, hints5);
+    grp1->AddFrame(l, hints6);
     fList->Add(l);
     fLabel.Add(l);
+
+    // ------------------------------------------------------------------
+
+    TGLayoutHints *hintse1 = new TGLayoutHints(kLHintsExpandX|kLHintsBottom);
+    TGLayoutHints *hintse2 = new TGLayoutHints(kLHintsExpandX, 2, 2);
+    TGLayoutHints *hintse3 = new TGLayoutHints(kLHintsExpandX);
+    TGLayoutHints *hintsl  = new TGLayoutHints(kLHintsExpandX, 1, 0, 5);
+    fList->Add(hintse1);
+    fList->Add(hintse2);
+    fList->Add(hintse3);
+
+    TGHorizontalFrame *entries = new TGHorizontalFrame(grp1, 1, 1);
+    grp1->AddFrame(entries, hintse1);
+    fList->Add(entries);
+
+    TGVerticalFrame *v1 = new TGVerticalFrame(entries);
+    TGVerticalFrame *v2 = new TGVerticalFrame(entries);
+    TGVerticalFrame *v3 = new TGVerticalFrame(entries);
+    entries->AddFrame(v1, hintse2);
+    entries->AddFrame(v2, hintse2);
+    entries->AddFrame(v3, hintse2);
+    fList->Add(v1);
+    fList->Add(v2);
+    fList->Add(v3);
+
+    TGLabel *label1 = new TGLabel(v1, "Az min/°");
+    TGLabel *label2 = new TGLabel(v2, "Az max/°");
+    TGLabel *label3 = new TGLabel(v3, "Limit/°");
+    TGLabel *label4 = new TGLabel(v1, "Zd min/°");
+    TGLabel *label5 = new TGLabel(v2, "Zd max/°");
+    TGLabel *label6 = new TGLabel(v3, "Limit/°");
+    label1->SetTextJustify(kTextLeft);
+    label2->SetTextJustify(kTextLeft);
+    label3->SetTextJustify(kTextLeft);
+    label4->SetTextJustify(kTextLeft);
+    label5->SetTextJustify(kTextLeft);
+    label6->SetTextJustify(kTextLeft);
+    fList->Add(label1);
+    fList->Add(label2);
+    fList->Add(label3);
+    fList->Add(label4);
+    fList->Add(label5);
+    fList->Add(label6);
+
+    TGTextEntry *entry1 = new TGTextEntry(v1, Form("%.1f", fAzMin), kIdAzMin);
+    TGTextEntry *entry2 = new TGTextEntry(v2, Form("%.1f", fAzMax), kIdAzMax);
+    TGTextEntry *entry3 = new TGTextEntry(v3, " ", -1);
+    TGTextEntry *entry4 = new TGTextEntry(v1, Form("%.1f", fZdMin), kIdZdMin);
+    TGTextEntry *entry5 = new TGTextEntry(v2, Form("%.1f", fZdMax), kIdZdMax);
+    TGTextEntry *entry6 = new TGTextEntry(v3, Form("%.3f", fLimit), kIdLimit);
+    entry3->SetEnabled(kFALSE);
+    entry1->SetToolTipText("TPoints with a real star located at Az<Az min are ignored in the fit.");
+    entry2->SetToolTipText("TPoints with a real star located at Az>Az max are ignored in the fit.");
+    entry4->SetToolTipText("TPoints with a real star located at Zd<Zd min are ignored in the fit.");
+    entry5->SetToolTipText("TPoints with a real star located at Zd>Zd max are ignored in the fit.");
+    entry6->SetToolTipText("TPoints with an residual after the fit > Limit are output.");
+    entry1->Associate(this);
+    entry2->Associate(this);
+    entry3->Associate(this);
+    entry4->Associate(this);
+    entry5->Associate(this);
+    entry6->Associate(this);
+    v1->AddFrame(label1, hintsl);
+    v1->AddFrame(entry1, hintse3);
+    v1->AddFrame(label4, hintsl);
+    v1->AddFrame(entry4, hintse3);
+    v2->AddFrame(label2, hintsl);
+    v2->AddFrame(entry2, hintse3);
+    v2->AddFrame(label5, hintsl);
+    v2->AddFrame(entry5, hintse3);
+    v3->AddFrame(label3, hintsl);
+    v3->AddFrame(entry3, hintse3);
+    v3->AddFrame(label6, hintsl);
+    v3->AddFrame(entry6, hintse3);
+    fList->Add(entry1);
+    fList->Add(entry2);
+    fList->Add(entry3);
+    fList->Add(entry4);
+    fList->Add(entry5);
+    fList->Add(entry6);
+
+    // ------------------------------------------------------------------
 
     // FIXME: Move this to the rc-file.
@@ -210,4 +303,8 @@
         TPointStar set = *(TPointStar*)fCoordinates.At(i);
 
+        if (set.GetStarZd()<fZdMin || set.GetStarZd()>fZdMax ||
+            set.GetStarAz()<fAzMin || set.GetStarAz()>fAzMax)
+            continue;
+
         set.Adjust(bend);
 
@@ -489,4 +586,5 @@
         "TPoint files",     "*.txt",
         "Collection files", "*.col",
+        "Model files",      "*.mod",
         "All files",        "*",
         NULL,           NULL
@@ -572,4 +670,7 @@
             break;
 
+//        if (set.GetRawZd()>60)
+//            continue;
+
         fOriginal.Add(new TPointStar(set));
     }
@@ -580,4 +681,9 @@
 
     fFileNameStars = fname;
+}
+
+Float_t TPointGui::GetFloat(Int_t id) const
+{
+    return atof(static_cast<TGTextEntry*>(fList->FindWidget(id))->GetText());
 }
 
@@ -636,4 +742,32 @@
         }
         return kTRUE;
+
+    case kC_TEXTENTRY:
+        switch (GET_SUBMSG(msg))
+        {
+        case kTE_TEXTCHANGED:
+            switch (mp1)
+            {
+            case kIdAzMin:
+                fAzMin = GetFloat(kIdAzMin);
+                return kTRUE;
+            case kIdAzMax:
+                fAzMax = GetFloat(kIdAzMax);
+                return kTRUE;
+            case kIdZdMin:
+                fZdMin = GetFloat(kIdZdMin);
+                return kTRUE;
+            case kIdZdMax:
+                fZdMax = GetFloat(kIdZdMax);
+                return kTRUE;
+            case kIdLimit:
+                fLimit = GetFloat(kIdLimit);
+                return kTRUE;
+            }
+            return kTRUE;
+
+        }
+        return kTRUE;
+
     }
     return kTRUE;
@@ -755,5 +889,5 @@
     b2.SetParameters(par);
 
-    gLog << inf << "Sets with Residual exceeding 0.13deg:" << endl;
+    gLog << all << endl << "Sets with Residual exceeding " << fLimit << "deg:" << endl;
 
     //
@@ -794,6 +928,6 @@
         grzd.SetPointError(i, 0, err);
 
-        if (resi>0.13)//orig.GetStarAz()>0 && orig.GetStarAz()<50 && set0.GetDZd()<-0.032 && orig.GetStarEl()<80) // 0.13
-            gLog << inf << " " << orig << "  <" << resi << ">" << endl;
+        if (resi>fLimit) // 0.13
+            gLog << all << " " << orig << "  <" << resi << ">" << endl;
 
         proaz.Fill(za.Az(), set0.GetResidual(&err));
@@ -811,4 +945,6 @@
         }
     }
+
+    gLog << "done." << endl << endl;
 
     //
Index: trunk/MagicSoft/Cosy/tpoint/TPointGui.h
===================================================================
--- trunk/MagicSoft/Cosy/tpoint/TPointGui.h	(revision 8937)
+++ trunk/MagicSoft/Cosy/tpoint/TPointGui.h	(revision 8971)
@@ -27,5 +27,11 @@
         kTbReset,
         kTbResetStars,
-        kTbReloadStars
+        kTbReloadStars,
+
+        kIdAzMin,
+        kIdAzMax,
+        kIdZdMin,
+        kIdZdMax,
+        kIdLimit,
     };
 
@@ -43,4 +49,11 @@
 
     Bool_t fExitLoopOnClose;
+
+    Float_t fAzMin;
+    Float_t fAzMax;
+    Float_t fZdMin;
+    Float_t fZdMax;
+
+    Float_t fLimit;
 
     void Fcn(Int_t &/*npar*/, Double_t */*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/);
@@ -70,4 +83,6 @@
     void Fit(Double_t &before, Double_t &after, Double_t &backw);
 
+    Float_t GetFloat(Int_t id) const;
+
 public:
     TPointGui(const char *fname=NULL);
